myxbee

Fork of XBEE by GDP 4

XBEE.h

Committer:
RobinIsLeg
Date:
2016-10-18
Revision:
1:ce4058bc0913
Parent:
0:8cdf90642ef6
Child:
2:983d482357b9

File content as of revision 1:ce4058bc0913:

#include "mbed.h"
#include "CBuffer.h"
#define STARTBYTE0 'Y'
#define STARTBYTE1 'A'
#define STARTBYTE2 'R'

class XBEE{
    public:
XBEE(Serial* SerialAddress); // XBEE comms constructor
void sendCommand(char command, int sizeOfPayload,char payload[]); // Send a command and payload of chars
void sendCommand(char command); // Send a single command byte only
void sendCommand(const char* info); // Send a string to the status box on the laptop
void sendCommand(int info); // Send an int to the status box
void sendCommand(float info); // Send a float to the status box
void sendCommand(double info); // Send a double to the status box
void checkForCommand(); // Reads through the Serial buffer executing any pending commands. call this function regularly to avoid buffer overflow 
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
             // Note this function does not use the comms protocol so won't appear on the status text box, you will have to use putty


   private:
bool scanForStartBytes(); // Synchronise comms
void switchCase(char command); // Process inbound commands
CBuffer* cBuffer; // Pointer to circular buffer storing inbound serial data
Serial* xbeeSerial; // Pointer to serial class
char startBytes[3]; // Temp variables to store inbound start bytes for comms synchronisation



};