IQRF Gateway Daemon
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
PrfCommonJson Class Reference

Implements common features of JsonDpaMessage. More...

#include <JsonSerializer.h>

Inheritance diagram for PrfCommonJson:
PrfFrcJson PrfIoJson PrfLedJson< L > PrfOsJson PrfPulseMeterJson PrfRawHdpJson PrfRawJson PrfThermometerJson ProtocolBridgeJson

Public Member Functions

int parseBinary (uint8_t *to, const std::string &from, int maxlen)
 Parse binary data encoded hexa. More...
 
template<typename T >
void parseHexaNum (T &to, const std::string &from)
 Parse templated ordinary type T encoded hexa. More...
 
void encodeHexaNum (std::string &to, uint8_t from)
 Encode uint_8 to hexa string. More...
 
void encodeHexaNum (std::string &to, uint16_t from)
 Encode uint_16 to hexa string. More...
 
void encodeBinary (std::string &to, const uint8_t *from, int len)
 Encode binary data to hexa string. More...
 
void encodeTimestamp (std::string &to, std::chrono::time_point< std::chrono::system_clock > from)
 Encode timestamp. More...
 

Public Attributes

bool m_has_ctype = false
 various flags to store presence of members of DPA request to be used in DPA response More...
 
bool m_has_type = false
 
bool m_has_nadr = false
 
bool m_has_hwpid = false
 
bool m_has_timeout = false
 
bool m_has_msgid = false
 
bool m_has_request = false
 
bool m_has_request_ts = false
 
bool m_has_response = false
 
bool m_has_response_ts = false
 
bool m_has_confirmation = false
 
bool m_has_confirmation_ts = false
 
bool m_has_cmd = false
 
bool m_has_rcode = false
 
bool m_has_rdata = false
 
bool m_has_dpaval = false
 
std::string m_ctype
 various flags to store members of DPA request to be used in DPA response More...
 
std::string m_type
 
std::string m_nadr = "0"
 
std::string m_hwpid = "0xffff"
 
int m_timeoutJ = 0
 
std::string m_msgid
 
std::string m_requestJ
 
std::string m_request_ts
 
std::string m_responseJ
 
std::string m_response_ts
 
std::string m_confirmationJ
 
std::string m_confirmation_ts
 
std::string m_cmdJ
 
std::string m_statusJ
 
std::string m_rcodeJ
 
std::string m_rdataJ
 
std::string m_dpavalJ
 
rapidjson::Document m_doc
 
bool m_dotNotation = true
 

Protected Member Functions

 PrfCommonJson ()
 
 PrfCommonJson (const PrfCommonJson &o)
 
void parseRequestJson (const rapidjson::Value &val, DpaTask &dpaTask)
 Parse common items. More...
 
void addResponseJsonPrio1Params (const DpaTask &dpaTask)
 Encode begining members of JSON. More...
 
void addResponseJsonPrio2Params (const DpaTask &dpaTask)
 Encode middle members of JSON. More...
 
std::string encodeResponseJsonFinal (const DpaTask &dpaTask)
 Encode final members of JSON and return it. More...
 

Detailed Description

Implements common features of JsonDpaMessage.

Copyright 2016-2017 MICRORISC s.r.o.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Common functions as parsing and encoding common items of JSON coded DPA messages

Constructor & Destructor Documentation

◆ PrfCommonJson() [1/2]

PrfCommonJson::PrfCommonJson ( )
protected

◆ PrfCommonJson() [2/2]

PrfCommonJson::PrfCommonJson ( const PrfCommonJson o)
protected

Member Function Documentation

◆ addResponseJsonPrio1Params()

void PrfCommonJson::addResponseJsonPrio1Params ( const DpaTask &  dpaTask)
protected

Encode begining members of JSON.

Parameters
[in]dpaTaskreference to be encoded

Gets DPA request common members to be stored at the very beginning of JSON message

◆ addResponseJsonPrio2Params()

void PrfCommonJson::addResponseJsonPrio2Params ( const DpaTask &  dpaTask)
protected

Encode middle members of JSON.

Parameters
[in]dpaTaskreference to be encoded

Gets DPA request common members to be stored in the middle of JSON message

◆ encodeBinary()

void PrfCommonJson::encodeBinary ( std::string &  to,
const uint8_t *  from,
int  len 
)

Encode binary data to hexa string.

Parameters
[out]toresult string
[in]fromdata to be encoded
[in]lenlength of dat to be encoded

Encode binary data to hexadecimal string in form e.g: "00 a5 b1" (space separation) or "00.a5.b1" (dot separation) Used separation is controlled by member m_dotNotation and it is hardcoded as dot separation it this version

◆ encodeHexaNum() [1/2]

void PrfCommonJson::encodeHexaNum ( std::string &  to,
uint8_t  from 
)

Encode uint_8 to hexa string.

Parameters
[out]toencoded string
[in]fromvalue to be encoded

◆ encodeHexaNum() [2/2]

void PrfCommonJson::encodeHexaNum ( std::string &  to,
uint16_t  from 
)

Encode uint_16 to hexa string.

Parameters
[out]toencoded string
[in]fromvalue to be encoded

◆ encodeResponseJsonFinal()

std::string PrfCommonJson::encodeResponseJsonFinal ( const DpaTask &  dpaTask)
protected

Encode final members of JSON and return it.

Parameters
[in]dpaTaskreference to be encoded
Returns
complete JSON encoded message

Gets DPA request common parameters to be stored at the end of JSON message and return complete JSON

◆ encodeTimestamp()

void PrfCommonJson::encodeTimestamp ( std::string &  to,
std::chrono::time_point< std::chrono::system_clock >  from 
)

Encode timestamp.

Parameters
[out]toresult string
[in]fromtimestamp to be encoded

◆ parseBinary()

int PrfCommonJson::parseBinary ( uint8_t *  to,
const std::string &  from,
int  maxlen 
)

Parse binary data encoded hexa.

Parameters
[out]tobuffer for result binary data
[in]fromhexadecimal string
[in]maxlenmaximal length of binary data
Returns
length of result

Gets hexadecimal string in form e.g: "00 a5 b1" (space separation) or "00.a5.b1" (dot separation) and parses to binary data

◆ parseHexaNum()

template<typename T >
void PrfCommonJson::parseHexaNum ( T &  to,
const std::string &  from 
)
inline

Parse templated ordinary type T encoded hexa.

Parameters
[out]tobuffer for result binary data
[in]fromhexadecimal string
Returns
length of result

Gets hexadecimal string in form e.g: "00a5b1" and inerpret it as templated ordinary type

◆ parseRequestJson()

void PrfCommonJson::parseRequestJson ( const rapidjson::Value &  val,
DpaTask &  dpaTask 
)
protected

Parse common items.

Parameters
[in]valJSON structure to be parsed
[out]dpaTaskreference to be set according parsed data

Gets JSON encoded DPA request, parse it and set DpaTask object accordingly

Member Data Documentation

◆ m_cmdJ

std::string PrfCommonJson::m_cmdJ

◆ m_confirmation_ts

std::string PrfCommonJson::m_confirmation_ts

◆ m_confirmationJ

std::string PrfCommonJson::m_confirmationJ

◆ m_ctype

std::string PrfCommonJson::m_ctype

various flags to store members of DPA request to be used in DPA response

◆ m_doc

rapidjson::Document PrfCommonJson::m_doc

◆ m_dotNotation

bool PrfCommonJson::m_dotNotation = true

◆ m_dpavalJ

std::string PrfCommonJson::m_dpavalJ

◆ m_has_cmd

bool PrfCommonJson::m_has_cmd = false

◆ m_has_confirmation

bool PrfCommonJson::m_has_confirmation = false

◆ m_has_confirmation_ts

bool PrfCommonJson::m_has_confirmation_ts = false

◆ m_has_ctype

bool PrfCommonJson::m_has_ctype = false

various flags to store presence of members of DPA request to be used in DPA response

◆ m_has_dpaval

bool PrfCommonJson::m_has_dpaval = false

◆ m_has_hwpid

bool PrfCommonJson::m_has_hwpid = false

◆ m_has_msgid

bool PrfCommonJson::m_has_msgid = false

◆ m_has_nadr

bool PrfCommonJson::m_has_nadr = false

◆ m_has_rcode

bool PrfCommonJson::m_has_rcode = false

◆ m_has_rdata

bool PrfCommonJson::m_has_rdata = false

◆ m_has_request

bool PrfCommonJson::m_has_request = false

◆ m_has_request_ts

bool PrfCommonJson::m_has_request_ts = false

◆ m_has_response

bool PrfCommonJson::m_has_response = false

◆ m_has_response_ts

bool PrfCommonJson::m_has_response_ts = false

◆ m_has_timeout

bool PrfCommonJson::m_has_timeout = false

◆ m_has_type

bool PrfCommonJson::m_has_type = false

◆ m_hwpid

std::string PrfCommonJson::m_hwpid = "0xffff"

◆ m_msgid

std::string PrfCommonJson::m_msgid

◆ m_nadr

std::string PrfCommonJson::m_nadr = "0"

◆ m_rcodeJ

std::string PrfCommonJson::m_rcodeJ

◆ m_rdataJ

std::string PrfCommonJson::m_rdataJ

◆ m_request_ts

std::string PrfCommonJson::m_request_ts

◆ m_requestJ

std::string PrfCommonJson::m_requestJ

◆ m_response_ts

std::string PrfCommonJson::m_response_ts

◆ m_responseJ

std::string PrfCommonJson::m_responseJ

◆ m_statusJ

std::string PrfCommonJson::m_statusJ

◆ m_timeoutJ

int PrfCommonJson::m_timeoutJ = 0

◆ m_type

std::string PrfCommonJson::m_type

The documentation for this class was generated from the following files: