Librairie xbee.
Dependents: NerfUS-Coord NerfUSTarget
Fork of APP3_xbee by
xbee.h@9:04063c29ab43, 2017-02-14 (annotated)
- Committer:
- dupm2216
- Date:
- Tue Feb 14 05:02:45 2017 +0000
- Revision:
- 9:04063c29ab43
- Parent:
- 8:b9c096965c00
- Child:
- 11:d3811e37d89c
Parse remote command status; ; When the status is not "OK", blink the error led for 1 second and resent the remote at command (aka blink remote led)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dupm2216 | 0:8f5379c94a69 | 1 | #ifndef XBEE_HPP |
dupm2216 | 0:8f5379c94a69 | 2 | #define XBEE_HPP |
dupm2216 | 0:8f5379c94a69 | 3 | |
dupm2216 | 0:8f5379c94a69 | 4 | #include <vector> |
dupm2216 | 0:8f5379c94a69 | 5 | #include <cassert> |
dupm2216 | 0:8f5379c94a69 | 6 | #include "mbed.h" |
dupm2216 | 0:8f5379c94a69 | 7 | #include "rtos.h" |
dupm2216 | 0:8f5379c94a69 | 8 | |
dupm2216 | 8:b9c096965c00 | 9 | struct ingoing_value_t |
dupm2216 | 8:b9c096965c00 | 10 | { |
dupm2216 | 8:b9c096965c00 | 11 | char content[11]; |
dupm2216 | 8:b9c096965c00 | 12 | int size; |
dupm2216 | 8:b9c096965c00 | 13 | }; |
dupm2216 | 8:b9c096965c00 | 14 | |
dupm2216 | 3:37ea92feece2 | 15 | //See xbee document page 99 |
dupm2216 | 3:37ea92feece2 | 16 | const char FRAME_TYPE_RECEIVE_PACKET = 0x90; |
dupm2216 | 3:37ea92feece2 | 17 | const char FRAME_TYPE_TRANSMIT_STATUS = 0x8B; |
dupm2216 | 3:37ea92feece2 | 18 | const char FRAME_TYPE_AT_COMMAND_RESPONSE = 0x88; |
dupm2216 | 9:04063c29ab43 | 19 | const char FRAME_TYPE_REMOTE_COMMAND_RESPONSE = 0x97; |
dupm2216 | 3:37ea92feece2 | 20 | |
dupm2216 | 3:37ea92feece2 | 21 | const char TRANSMIT_STATUS_SUCCESS = 0x00; |
dupm2216 | 3:37ea92feece2 | 22 | const char AT_COMMAND_RESPONSE_STATUS_OK = 0x00; |
dupm2216 | 9:04063c29ab43 | 23 | const char REMOTE_COMMAND_RESPONSE_COMMAND_STATUS_OK = 0x00; |
dupm2216 | 3:37ea92feece2 | 24 | |
dupm2216 | 6:b70f32a80d51 | 25 | const char EVENT_TYPE_BUTTON = 0x00; |
dupm2216 | 6:b70f32a80d51 | 26 | const char EVENT_TYPE_ACCELEROMETER = 0x01; |
dupm2216 | 6:b70f32a80d51 | 27 | |
dupm2216 | 8:b9c096965c00 | 28 | const char BUTTON_PRESSED = 0x00; |
dupm2216 | 8:b9c096965c00 | 29 | const char BUTTON_RELEASED = 0x01; |
dupm2216 | 8:b9c096965c00 | 30 | |
dupm2216 | 8:b9c096965c00 | 31 | extern Mail<ingoing_value_t, 30> parsed_frames; |
dupm2216 | 5:cd3c79853dc8 | 32 | extern RawSerial xbee; |
dupm2216 | 4:e97cfe6cc18c | 33 | |
dupm2216 | 9:04063c29ab43 | 34 | extern DigitalOut error_led; |
dupm2216 | 9:04063c29ab43 | 35 | extern Thread error_led_thread; |
dupm2216 | 9:04063c29ab43 | 36 | |
dupm2216 | 9:04063c29ab43 | 37 | void manage_error_led(); |
dupm2216 | 9:04063c29ab43 | 38 | void send_blink_led_at_command(const bool toggle_current_command); |
dupm2216 | 9:04063c29ab43 | 39 | |
dupm2216 | 0:8f5379c94a69 | 40 | void send_message_via_xbee(const char* message, const int length); |
dupm2216 | 0:8f5379c94a69 | 41 | vector<char> generate_transmit_request(const char* message, const int length); |
dupm2216 | 5:cd3c79853dc8 | 42 | vector<char> generate_led_command(const bool power_on); |
dupm2216 | 0:8f5379c94a69 | 43 | void read_frame(); |
dupm2216 | 3:37ea92feece2 | 44 | vector<char> parse_receive_packet(const vector<char>& frame); |
dupm2216 | 3:37ea92feece2 | 45 | vector<char> parse_transmit_status(const vector<char>& frame); |
dupm2216 | 3:37ea92feece2 | 46 | vector<char> parse_at_command_response(const vector<char>& frame); |
dupm2216 | 4:e97cfe6cc18c | 47 | void handle_parsed_frames_from_mailbox(); |
dupm2216 | 4:e97cfe6cc18c | 48 | void handle_frame(const vector<char>& frame); |
dupm2216 | 0:8f5379c94a69 | 49 | |
dupm2216 | 6:b70f32a80d51 | 50 | void parsed_frame_to_string(const vector<char>& parsed_frame, char* readable_string_output); |
dupm2216 | 6:b70f32a80d51 | 51 | void parsed_button_event_frame_to_string(const vector<char>& parsed_frame, char* readable_string_output); |
dupm2216 | 6:b70f32a80d51 | 52 | void parsed_accelerometer_event_frame_to_string(const vector<char>& parsed_frame, char* readable_string_output); |
dupm2216 | 6:b70f32a80d51 | 53 | |
dupm2216 | 3:37ea92feece2 | 54 | //Simplify the frame to only contain the frame type and the relevant data for our application |
dupm2216 | 3:37ea92feece2 | 55 | vector<char> parse_frame(const vector<char>& frame); |
dupm2216 | 3:37ea92feece2 | 56 | |
dupm2216 | 8:b9c096965c00 | 57 | vector<char> ingoing_value_to_vector(const ingoing_value_t& value); |
dupm2216 | 8:b9c096965c00 | 58 | |
dupm2216 | 0:8f5379c94a69 | 59 | #endif |