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.
include/xbee.h@15:ab3e0d32e578, 2017-03-29 (annotated)
- Committer:
- GaiSensei
- Date:
- Wed Mar 29 17:00:14 2017 +0000
- Revision:
- 15:ab3e0d32e578
- Parent:
- 14:cc65f603e659
- Child:
- 16:f4df01448b59
Transmitter done, receiver coded but not tested
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| GaiSensei | 13:b5d0f491d465 | 1 | ///////////////////////////////////////////////////////////// |
| GaiSensei | 13:b5d0f491d465 | 2 | // APP 3 // |
| GaiSensei | 13:b5d0f491d465 | 3 | // // |
| GaiSensei | 13:b5d0f491d465 | 4 | // Université de Sherbrooke // |
| GaiSensei | 13:b5d0f491d465 | 5 | // Génie informatique // |
| GaiSensei | 13:b5d0f491d465 | 6 | // Session 5, Hiver 2017 // |
| GaiSensei | 13:b5d0f491d465 | 7 | // // |
| GaiSensei | 13:b5d0f491d465 | 8 | // Date: 14 février 2017 // |
| GaiSensei | 13:b5d0f491d465 | 9 | // // |
| GaiSensei | 13:b5d0f491d465 | 10 | // Auteurs: Maxime Dupuis, dupm2216 // |
| GaiSensei | 13:b5d0f491d465 | 11 | // Bruno Allaire-Lemay, allb2701 // |
| GaiSensei | 13:b5d0f491d465 | 12 | ///////////////////////////////////////////////////////////// |
| GaiSensei | 13:b5d0f491d465 | 13 | |
| dupm2216 | 0:8f5379c94a69 | 14 | #ifndef XBEE_HPP |
| dupm2216 | 0:8f5379c94a69 | 15 | #define XBEE_HPP |
| dupm2216 | 0:8f5379c94a69 | 16 | |
| dupm2216 | 0:8f5379c94a69 | 17 | #include <vector> |
| GaiSensei | 11:d3811e37d89c | 18 | #include <string> |
| dupm2216 | 0:8f5379c94a69 | 19 | #include <cassert> |
| dupm2216 | 0:8f5379c94a69 | 20 | #include "mbed.h" |
| dupm2216 | 0:8f5379c94a69 | 21 | #include "rtos.h" |
| dupm2216 | 0:8f5379c94a69 | 22 | |
| dupm2216 | 8:b9c096965c00 | 23 | struct ingoing_value_t |
| dupm2216 | 8:b9c096965c00 | 24 | { |
| dupm2216 | 8:b9c096965c00 | 25 | char content[11]; |
| dupm2216 | 8:b9c096965c00 | 26 | int size; |
| dupm2216 | 8:b9c096965c00 | 27 | }; |
| dupm2216 | 8:b9c096965c00 | 28 | |
| dupm2216 | 3:37ea92feece2 | 29 | //See xbee document page 99 |
| dupm2216 | 3:37ea92feece2 | 30 | const char FRAME_TYPE_RECEIVE_PACKET = 0x90; |
| dupm2216 | 3:37ea92feece2 | 31 | const char FRAME_TYPE_TRANSMIT_STATUS = 0x8B; |
| dupm2216 | 3:37ea92feece2 | 32 | const char FRAME_TYPE_AT_COMMAND_RESPONSE = 0x88; |
| dupm2216 | 9:04063c29ab43 | 33 | const char FRAME_TYPE_REMOTE_COMMAND_RESPONSE = 0x97; |
| dupm2216 | 3:37ea92feece2 | 34 | |
| dupm2216 | 3:37ea92feece2 | 35 | const char TRANSMIT_STATUS_SUCCESS = 0x00; |
| dupm2216 | 3:37ea92feece2 | 36 | const char AT_COMMAND_RESPONSE_STATUS_OK = 0x00; |
| dupm2216 | 9:04063c29ab43 | 37 | const char REMOTE_COMMAND_RESPONSE_COMMAND_STATUS_OK = 0x00; |
| dupm2216 | 3:37ea92feece2 | 38 | |
| dupm2216 | 8:b9c096965c00 | 39 | const char BUTTON_PRESSED = 0x00; |
| dupm2216 | 8:b9c096965c00 | 40 | const char BUTTON_RELEASED = 0x01; |
| dupm2216 | 8:b9c096965c00 | 41 | |
| dupm2216 | 8:b9c096965c00 | 42 | extern Mail<ingoing_value_t, 30> parsed_frames; |
| dupm2216 | 5:cd3c79853dc8 | 43 | extern RawSerial xbee; |
| dupm2216 | 4:e97cfe6cc18c | 44 | |
| dupm2216 | 9:04063c29ab43 | 45 | extern DigitalOut error_led; |
| dupm2216 | 9:04063c29ab43 | 46 | extern Thread error_led_thread; |
| dupm2216 | 9:04063c29ab43 | 47 | |
| dupm2216 | 9:04063c29ab43 | 48 | void manage_error_led(); |
| dupm2216 | 9:04063c29ab43 | 49 | void send_blink_led_at_command(const bool toggle_current_command); |
| dupm2216 | 9:04063c29ab43 | 50 | |
| dupm2216 | 0:8f5379c94a69 | 51 | void send_message_via_xbee(const char* message, const int length); |
| dupm2216 | 0:8f5379c94a69 | 52 | vector<char> generate_transmit_request(const char* message, const int length); |
| dupm2216 | 5:cd3c79853dc8 | 53 | vector<char> generate_led_command(const bool power_on); |
| dupm2216 | 0:8f5379c94a69 | 54 | void read_frame(); |
| dupm2216 | 3:37ea92feece2 | 55 | vector<char> parse_receive_packet(const vector<char>& frame); |
| dupm2216 | 3:37ea92feece2 | 56 | vector<char> parse_transmit_status(const vector<char>& frame); |
| dupm2216 | 3:37ea92feece2 | 57 | vector<char> parse_at_command_response(const vector<char>& frame); |
| dupm2216 | 4:e97cfe6cc18c | 58 | void handle_parsed_frames_from_mailbox(); |
| dupm2216 | 4:e97cfe6cc18c | 59 | void handle_frame(const vector<char>& frame); |
| dupm2216 | 0:8f5379c94a69 | 60 | |
| dupm2216 | 6:b70f32a80d51 | 61 | void parsed_frame_to_string(const vector<char>& parsed_frame, char* readable_string_output); |
| dupm2216 | 6:b70f32a80d51 | 62 | void parsed_button_event_frame_to_string(const vector<char>& parsed_frame, char* readable_string_output); |
| dupm2216 | 6:b70f32a80d51 | 63 | void parsed_accelerometer_event_frame_to_string(const vector<char>& parsed_frame, char* readable_string_output); |
| dupm2216 | 6:b70f32a80d51 | 64 | |
| dupm2216 | 3:37ea92feece2 | 65 | //Simplify the frame to only contain the frame type and the relevant data for our application |
| dupm2216 | 3:37ea92feece2 | 66 | vector<char> parse_frame(const vector<char>& frame); |
| dupm2216 | 3:37ea92feece2 | 67 | |
| dupm2216 | 8:b9c096965c00 | 68 | vector<char> ingoing_value_to_vector(const ingoing_value_t& value); |
| dupm2216 | 8:b9c096965c00 | 69 | |
| GaiSensei | 12:78d0f5119d2e | 70 | vector<string> read_file(string path); |
| GaiSensei | 11:d3811e37d89c | 71 | char hexa_char_to_dec(char hexa_char); |
| GaiSensei | 11:d3811e37d89c | 72 | vector<char> string_to_data(string pan_id); |
| GaiSensei | 11:d3811e37d89c | 73 | void set_pan_id(string pan_id); |
| GaiSensei | 11:d3811e37d89c | 74 | |
| dupm2216 | 0:8f5379c94a69 | 75 | #endif |