Coordinator v2

Dependencies:   NerfUSXbee PinDetect EthernetInterface JSON MFRC522 WebSocketClient mbed-rtos mbed

Committer:
Ismael Balafrej
Date:
Mon Apr 10 15:02:24 2017 -0400
Revision:
1:e1c5259b7d9a
Child:
2:019d8848cf7e
V1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ismael Balafrej 1:e1c5259b7d9a 1 #include "Target.hpp"
Ismael Balafrej 1:e1c5259b7d9a 2
Ismael Balafrej 1:e1c5259b7d9a 3 RealXbeeTransmitter xbee_transmitter;
Ismael Balafrej 1:e1c5259b7d9a 4
Ismael Balafrej 1:e1c5259b7d9a 5 Target::Target(int address_msb, int address_lsb, int target_number)
Ismael Balafrej 1:e1c5259b7d9a 6 {
Ismael Balafrej 1:e1c5259b7d9a 7 get_address_for_xbee(address_msb, address_lsb);
Ismael Balafrej 1:e1c5259b7d9a 8 this->target_number = target_number;
Ismael Balafrej 1:e1c5259b7d9a 9 }
Ismael Balafrej 1:e1c5259b7d9a 10
Ismael Balafrej 1:e1c5259b7d9a 11 void Target::rise(int mode, int timeout)
Ismael Balafrej 1:e1c5259b7d9a 12 {
Ismael Balafrej 1:e1c5259b7d9a 13 toPc("Rising target %i!", target_number);
Ismael Balafrej 1:e1c5259b7d9a 14 vector<uint8_t> message;
Ismael Balafrej 1:e1c5259b7d9a 15 message.push_back(target_number);
Ismael Balafrej 1:e1c5259b7d9a 16 message.push_back(mode);
Ismael Balafrej 1:e1c5259b7d9a 17 message.push_back((timeout >> 8) & 0xFF);
Ismael Balafrej 1:e1c5259b7d9a 18 message.push_back(timeout && 0xFF);
Ismael Balafrej 1:e1c5259b7d9a 19 xbee_transmitter.transmit(message, addr_table);
Ismael Balafrej 1:e1c5259b7d9a 20 }
Ismael Balafrej 1:e1c5259b7d9a 21
Ismael Balafrej 1:e1c5259b7d9a 22 void Target::get_address_for_xbee(int address_msb, int address_lsb)
Ismael Balafrej 1:e1c5259b7d9a 23 {
Ismael Balafrej 1:e1c5259b7d9a 24 addr_table[0] = address_msb >> 24;
Ismael Balafrej 1:e1c5259b7d9a 25 addr_table[1] = (address_msb >> 16) & 0xFF;
Ismael Balafrej 1:e1c5259b7d9a 26 addr_table[2] = (address_msb >> 8) & 0xFF;
Ismael Balafrej 1:e1c5259b7d9a 27 addr_table[3] = (address_msb) & 0xFF;
Ismael Balafrej 1:e1c5259b7d9a 28 addr_table[4] = address_lsb >> 24;
Ismael Balafrej 1:e1c5259b7d9a 29 addr_table[5] = (address_lsb >> 16) & 0xFF;
Ismael Balafrej 1:e1c5259b7d9a 30 addr_table[6] = (address_lsb >> 8) & 0xFF;
Ismael Balafrej 1:e1c5259b7d9a 31 addr_table[7] = (address_lsb) & 0xFF;
Ismael Balafrej 1:e1c5259b7d9a 32 }