myxbee

Fork of XBEE by GDP 4

Committer:
RobinIsLeg
Date:
Tue Oct 18 03:58:55 2016 +0000
Revision:
1:ce4058bc0913
Parent:
0:8cdf90642ef6
Child:
2:983d482357b9
minor fix... so minor i forgot what it was. Main change is added instructions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobinIsLeg 0:8cdf90642ef6 1 #include "mbed.h"
RobinIsLeg 0:8cdf90642ef6 2 #include "CBuffer.h"
RobinIsLeg 0:8cdf90642ef6 3 #define STARTBYTE0 'Y'
RobinIsLeg 0:8cdf90642ef6 4 #define STARTBYTE1 'A'
RobinIsLeg 0:8cdf90642ef6 5 #define STARTBYTE2 'R'
RobinIsLeg 0:8cdf90642ef6 6
RobinIsLeg 0:8cdf90642ef6 7 class XBEE{
RobinIsLeg 0:8cdf90642ef6 8 public:
RobinIsLeg 0:8cdf90642ef6 9 XBEE(Serial* SerialAddress); // XBEE comms constructor
RobinIsLeg 0:8cdf90642ef6 10 void sendCommand(char command, int sizeOfPayload,char payload[]); // Send a command and payload of chars
RobinIsLeg 0:8cdf90642ef6 11 void sendCommand(char command); // Send a single command byte only
RobinIsLeg 0:8cdf90642ef6 12 void sendCommand(const char* info); // Send a string to the status box on the laptop
RobinIsLeg 0:8cdf90642ef6 13 void sendCommand(int info); // Send an int to the status box
RobinIsLeg 0:8cdf90642ef6 14 void sendCommand(float info); // Send a float to the status box
RobinIsLeg 0:8cdf90642ef6 15 void sendCommand(double info); // Send a double to the status box
RobinIsLeg 0:8cdf90642ef6 16 void checkForCommand(); // Reads through the Serial buffer executing any pending commands. call this function regularly to avoid buffer overflow
RobinIsLeg 1:ce4058bc0913 17 void test(); // Test function to test low level comms. This will send "Receiving the following data:" and then mirror back everything currently in the serial buffer
RobinIsLeg 1:ce4058bc0913 18 // Note this function does not use the comms protocol so won't appear on the status text box, you will have to use putty
RobinIsLeg 0:8cdf90642ef6 19
RobinIsLeg 0:8cdf90642ef6 20
RobinIsLeg 0:8cdf90642ef6 21 private:
RobinIsLeg 1:ce4058bc0913 22 bool scanForStartBytes(); // Synchronise comms
RobinIsLeg 1:ce4058bc0913 23 void switchCase(char command); // Process inbound commands
RobinIsLeg 0:8cdf90642ef6 24 CBuffer* cBuffer; // Pointer to circular buffer storing inbound serial data
RobinIsLeg 0:8cdf90642ef6 25 Serial* xbeeSerial; // Pointer to serial class
RobinIsLeg 0:8cdf90642ef6 26 char startBytes[3]; // Temp variables to store inbound start bytes for comms synchronisation
RobinIsLeg 0:8cdf90642ef6 27
RobinIsLeg 0:8cdf90642ef6 28
RobinIsLeg 0:8cdf90642ef6 29
RobinIsLeg 0:8cdf90642ef6 30 };