void SenMLPack::fromJson(Stream *source, SenMLStreamMethod format) { JsonStreamingParser parser; SenMLJsonListener listener(this); parser.setListener(&listener); char data; if(format == SENML_RAW) { #ifdef __MBED__ data = source->getc(); #else data = source->read(); #endif } else{ data = readHexChar(source); } while(data != -1){ parser.parse(data); if(format == SENML_RAW){ #ifdef __MBED__ data = source->getc(); #else data = source->read(); #endif } else data = readHexChar(source); } // when we get here, all the data is stored in the document and callbacks have been called. }
int readHexByte(const char *str) { dAssert(atLeastLength(str, 2)); int returnVal = 0; returnVal += readHexChar(str[0]) * 16; returnVal += readHexChar(str[1]); return returnVal; }