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/
LLAPSerial.h
- Committer:
- SomeRandomBloke
- Date:
- 2014-04-16
- Revision:
- 3:08f5e8989688
- Parent:
- 2:73b87761ce69
- Child:
- 4:34499a4a4ec7
File content as of revision 3:08f5e8989688:
/** LLAPSerial.h * @author Andrew Lindsay * * @section LICENSE * * The MIT License (MIT) * * Copyright (c) 2014 Andrew Lindsay * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef _LLAPSERIAL_h #define _LLAPSERIAL_h #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: /** 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 checkDevIDin = 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; }; #endif