IQRF Gateway Daemon
|
Implements common features of JsonDpaMessage. More...
#include <JsonSerializer.h>
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... | |
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
|
protected |
|
protected |
|
protected |
Encode begining members of JSON.
[in] | dpaTask | reference to be encoded |
Gets DPA request common members to be stored at the very beginning of JSON message
|
protected |
Encode middle members of JSON.
[in] | dpaTask | reference to be encoded |
Gets DPA request common members to be stored in the middle of JSON message
void PrfCommonJson::encodeBinary | ( | std::string & | to, |
const uint8_t * | from, | ||
int | len | ||
) |
Encode binary data to hexa string.
[out] | to | result string |
[in] | from | data to be encoded |
[in] | len | length 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
void PrfCommonJson::encodeHexaNum | ( | std::string & | to, |
uint8_t | from | ||
) |
Encode uint_8 to hexa string.
[out] | to | encoded string |
[in] | from | value to be encoded |
void PrfCommonJson::encodeHexaNum | ( | std::string & | to, |
uint16_t | from | ||
) |
Encode uint_16 to hexa string.
[out] | to | encoded string |
[in] | from | value to be encoded |
|
protected |
Encode final members of JSON and return it.
[in] | dpaTask | reference to be encoded |
Gets DPA request common parameters to be stored at the end of JSON message and return complete JSON
void PrfCommonJson::encodeTimestamp | ( | std::string & | to, |
std::chrono::time_point< std::chrono::system_clock > | from | ||
) |
Encode timestamp.
[out] | to | result string |
[in] | from | timestamp to be encoded |
int PrfCommonJson::parseBinary | ( | uint8_t * | to, |
const std::string & | from, | ||
int | maxlen | ||
) |
Parse binary data encoded hexa.
[out] | to | buffer for result binary data |
[in] | from | hexadecimal string |
[in] | maxlen | maximal length of binary data |
Gets hexadecimal string in form e.g: "00 a5 b1" (space separation) or "00.a5.b1" (dot separation) and parses to binary data
|
inline |
Parse templated ordinary type T encoded hexa.
[out] | to | buffer for result binary data |
[in] | from | hexadecimal string |
Gets hexadecimal string in form e.g: "00a5b1" and inerpret it as templated ordinary type
|
protected |
Parse common items.
[in] | val | JSON structure to be parsed |
[out] | dpaTask | reference to be set according parsed data |
Gets JSON encoded DPA request, parse it and set DpaTask object accordingly
std::string PrfCommonJson::m_cmdJ |
std::string PrfCommonJson::m_confirmation_ts |
std::string PrfCommonJson::m_confirmationJ |
std::string PrfCommonJson::m_ctype |
various flags to store members of DPA request to be used in DPA response
rapidjson::Document PrfCommonJson::m_doc |
bool PrfCommonJson::m_dotNotation = true |
std::string PrfCommonJson::m_dpavalJ |
bool PrfCommonJson::m_has_cmd = false |
bool PrfCommonJson::m_has_confirmation = false |
bool PrfCommonJson::m_has_confirmation_ts = false |
bool PrfCommonJson::m_has_ctype = false |
various flags to store presence of members of DPA request to be used in DPA response
bool PrfCommonJson::m_has_dpaval = false |
bool PrfCommonJson::m_has_hwpid = false |
bool PrfCommonJson::m_has_msgid = false |
bool PrfCommonJson::m_has_nadr = false |
bool PrfCommonJson::m_has_rcode = false |
bool PrfCommonJson::m_has_rdata = false |
bool PrfCommonJson::m_has_request = false |
bool PrfCommonJson::m_has_request_ts = false |
bool PrfCommonJson::m_has_response = false |
bool PrfCommonJson::m_has_response_ts = false |
bool PrfCommonJson::m_has_timeout = false |
bool PrfCommonJson::m_has_type = false |
std::string PrfCommonJson::m_hwpid = "0xffff" |
std::string PrfCommonJson::m_msgid |
std::string PrfCommonJson::m_nadr = "0" |
std::string PrfCommonJson::m_rcodeJ |
std::string PrfCommonJson::m_rdataJ |
std::string PrfCommonJson::m_request_ts |
std::string PrfCommonJson::m_requestJ |
std::string PrfCommonJson::m_response_ts |
std::string PrfCommonJson::m_responseJ |
std::string PrfCommonJson::m_statusJ |
int PrfCommonJson::m_timeoutJ = 0 |
std::string PrfCommonJson::m_type |