myxbee

Fork of XBEE by GDP 4

Committer:
FatCookies
Date:
Thu Nov 03 13:06:07 2016 +0000
Revision:
2:983d482357b9
Parent:
1:ce4058bc0913
made things public?

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
FatCookies 2:983d482357b9 21 Serial* xbeeSerial; // Pointer to serial class
FatCookies 2:983d482357b9 22 CBuffer* cBuffer; // Pointer to circular buffer storing inbound serial data
FatCookies 2:983d482357b9 23
RobinIsLeg 0:8cdf90642ef6 24 private:
RobinIsLeg 1:ce4058bc0913 25 bool scanForStartBytes(); // Synchronise comms
RobinIsLeg 1:ce4058bc0913 26 void switchCase(char command); // Process inbound commands
FatCookies 2:983d482357b9 27
FatCookies 2:983d482357b9 28
RobinIsLeg 0:8cdf90642ef6 29 char startBytes[3]; // Temp variables to store inbound start bytes for comms synchronisation
RobinIsLeg 0:8cdf90642ef6 30
RobinIsLeg 0:8cdf90642ef6 31
RobinIsLeg 0:8cdf90642ef6 32
RobinIsLeg 0:8cdf90642ef6 33 };