Home Automation with Intel Galileo by 2015

Home Automation with Intel Galileo by 2015

Author:2015
Language: eng
Format: epub
Publisher: Packt Publishing


Let's parse the received message. The first byte is 0x1, which is the start of the message. 0x9 is the length of the rest. The Node ID is the sixth byte, which is the lamp holder node ID. The next byte is 0x3, which shows the length of the command. If the 0x25 command class is received, we have 0x3, which means the report from the sensor. Finally, we have the 0xff value to indicate the status of the device, which is on here.

Switching the lamp holder on/off with Intel Galileo

Let's switch off the lamp holder and then check its status. We will execute the function given below. The following message is similar to the one we examined in the previous chapter:

int binary_switch_on_off(int serial_device, uint8_t nodeID, uint8_t on_off, uint8_t callbackID) { int message_length = 12; uint8_t checksum = 0x00; uint8_t message_buffer[] = { SOF, 0x0a, REQUEST, SEND_DATA, nodeID, 0x03, COMMAND_CLASS_SWITCH_BINARY, BINARY_SET, on_off, TRANSMIT_OPTION, callbackID, checksum }; checksum = generate_checksum(message_buffer, message_length); message_buffer[message_length - 1] = checksum; return write_to_serial_device(serial_device, message_buffer, message_length); }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.