I am trying to understand the code in MySensorBase.cpp.
In
Code: Select all
void MySensorsBase::ParseLine()
{
if (m_bufferpos<2)
return;
std::string sLine((char*)&m_buffer);
//_log.Log(LOG_STATUS, sLine.c_str());
std::vector<std::string> results;
StringSplit(sLine, ";", results);
if (results.size()<5)
return; //invalid data
int node_id = atoi(results[0].c_str());
int child_sensor_id = atoi(results[1].c_str());
_eMessageType message_type = (_eMessageType)atoi(results[2].c_str());
int ack = atoi(results[3].c_str());
int sub_type = atoi(results[4].c_str());
std::string payload = "";
if (results.size() >= 6)
{
for (size_t ip = 0; ip < results.size() - 5; ip++)
{
payload = results[5+ip];
}
}
[...]
If I understand the above code properly:
If the payload is a ";" separated list of values (like for a V_POSITION of a S_GPS for example) then only the last value will be considered as the "payload". Equally if on a V_TEXT, the text to be displayed contains a ";", then it will be truncated to the last "sub-string"
(cf MySensors website on the serial API:
V_POSITION 49 GPS position and altitude. Payload: latitude;longitude;altitude(m). E.g. "55.722526;13.017972;18" S_GPS)
Have I missed something?
Thanks for the clarification,
Pierre