Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NerfUS-Coord NerfUSTarget
Fork of APP3_xbee by
Diff: xbee.cpp
- Revision:
- 5:cd3c79853dc8
- Parent:
- 4:e97cfe6cc18c
- Child:
- 6:b70f32a80d51
diff -r e97cfe6cc18c -r cd3c79853dc8 xbee.cpp
--- a/xbee.cpp Sun Feb 12 21:33:48 2017 +0000
+++ b/xbee.cpp Sun Feb 12 22:42:45 2017 +0000
@@ -5,6 +5,9 @@
Mail<vector<char>, 30> parsed_frames;
RawSerial xbee(p13, p14);
const int FRAME_SPECIFIC_DATA_BEGIN[14] = {0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00};
+const int AT_COMMAND_LED_FRAME_SPECIFIC_DATA_BEGIN[15] = {0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x02, 0x50, 0x32};
+const char LED_COMMAND_POWER_ON = 0x05;
+const char LED_COMMAND_POWER_OFF = 0x04;
const int RECEIVE_PACKET_MESSAGE_START_INDEX = 15;
const char START_DELIMITER = 0x7E;
@@ -50,6 +53,35 @@
return request;
}
+vector<char> generate_led_command(const bool power_on)
+{
+ vector<char> request;
+
+ unsigned char checksum = 0xFF;
+
+ request.push_back(START_DELIMITER);
+
+ const uint16_t frame_length = 0x10;
+ const uint8_t frame_length_msb = frame_length >> 8;
+ const uint8_t frame_length_lsb = (frame_length << 8) >> 8;
+ request.push_back(frame_length_msb);
+ request.push_back(frame_length_lsb);
+
+ for(int i=0; i<15; i++)
+ {
+ request.push_back(AT_COMMAND_LED_FRAME_SPECIFIC_DATA_BEGIN[i]);
+ checksum -= AT_COMMAND_LED_FRAME_SPECIFIC_DATA_BEGIN[i];
+ }
+
+ const char led_power_state = power_on ? LED_COMMAND_POWER_ON : LED_COMMAND_POWER_OFF;
+ request.push_back(led_power_state);
+ checksum -= led_power_state;
+
+ request.push_back(checksum);
+
+ return request;
+}
+
void read_frame()
{
while(true)
