We have added new sensors to the Smart Home application. In order to handle all incoming messages correctly, we need to be able to parse messages correctly to inform the user. When we added new command classes, we needed to handle their values separately. A part of the message parser, which handles sensor commands, is shown here. We also used a part of this in the previous chapter to handle energy meter values such as illumination and temperature:
int parse_incoming_mesage(uint8_t* message, int length) { //Message Length uint8_t length_of_rest = message[1]; uint8_t message_type = message[2]; uint8_t message_function = message[3]; else if (message_function == RESPONSE_RECEIVED) { printf("Response From "); if (message[5] == MultiSensorNodeID) { printf("Multi-Sensor Node Received: "); } else if (message[5] == WallPlugNodeID) { printf("Wall Plug Node Received: "); } else if (message[5] == LampHolderNodeID) { ...