LLAP Library for Ciseco wireless products.
Dependents: Ciseco_LLAP_Test Ciseco_SRF_Shield
Library for Ciseco wireless modules http://shop.ciseco.co.uk/rf-module-range/
Tested with Nucleo F401RE and http://shop.ciseco.co.uk/srf-shield-wireless-transciever-for-all-arduino-type-boards/
Diff: LLAPSerial.h
- Revision:
- 2:73b87761ce69
- Parent:
- 1:8f3ec117823d
- Child:
- 3:08f5e8989688
--- a/LLAPSerial.h Tue Apr 15 22:10:17 2014 +0000 +++ b/LLAPSerial.h Wed Apr 16 08:03:48 2014 +0000 @@ -1,5 +1,8 @@ /** LLAPSerial.h + * @author Andrew Lindsay * + * @section LICENSE + * * The MIT License (MIT) * * Copyright (c) 2014 Andrew Lindsay @@ -28,27 +31,69 @@ #include "mbed.h" +/** LLAP Serial class for communicating with Ciseco wireless devices + * + */ class LLAPSerial { private: char cMessage[13]; // Raw receive buffer - char* inPtr; + bool checkDevID = false; void processMessage(); void SerialEvent(); Serial srf; public: - LLAPSerial(PinName txPin, PinName rxPin, char *dID = "--" ); + /** Default Constructor + * @param txPin Pin name for UART TX + * @param rxPin Pin name for UART RX + * @param checkNodeID Check the incoming Device ID and ignore if it doesnt match + * @param dID ID for device, used in sending messages and if checkNodeID is true then only messages for this ID are accepted + */ + LLAPSerial(PinName txPin, PinName rxPin, bool checkDevID = false, char *dID = "--" ); + /** Send a message + * @param sToSend Character pointer to message to send, will be padded with - to full length or truncated if too long + */ void sendMessage(char* sToSend); + + /** Send a message with a value. Both are concatenated in the message with padding - if needed + * @param sToSend Character pointer to message to send + * @param valueToSend The value to send as a series of characters + */ void sendMessage(char* sToSend, char* valueToSend); + + /** Send an integer + * @param sToSend Character pointer to message to send + * @param value The value to send as a series of characters, will be padded with - to full length or truncated if too long + */ void sendInt(char *sToSend, int value); + + /** Send integer message to specified decimal places + * @param sToSend Character pointer to message to send + * @param value The value to send as a series of characters, will be padded with - to full length or truncated if too long + * @param decimalPlaces The number of decimal places to use. + */ void sendIntWithDP(char *sToSend, int value, int decimalPlaces); + + /** Set device ID + * @param cId New device ID to set + */ void setDeviceId(char* cId); - + + // Public variables for message processing by main application (ideally should be getter functions) + + /** ID of this device + */ char deviceId[2]; + + /** Received message buffer + */ char sMessage[15]; // Received message buffer + + /** Flag to indicate a new message has been received, must be cleared after message processed + */ bool bMsgReceived; };