Accepts RPC commands over bluetooth (RN42)

Dependencies:   mbed m3pi

Committer:
chris
Date:
Thu May 12 15:46:41 2011 +0000
Revision:
3:be428c849e1c

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 3:be428c849e1c 1 /**
chris 3:be428c849e1c 2 * @section LICENSE
chris 3:be428c849e1c 3 *Copyright (c) 2010 ARM Ltd.
chris 3:be428c849e1c 4 *
chris 3:be428c849e1c 5 *Permission is hereby granted, free of charge, to any person obtaining a copy
chris 3:be428c849e1c 6 *of this software and associated documentation files (the "Software"), to deal
chris 3:be428c849e1c 7 *in the Software without restriction, including without limitation the rights
chris 3:be428c849e1c 8 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
chris 3:be428c849e1c 9 *copies of the Software, and to permit persons to whom the Software is
chris 3:be428c849e1c 10 *furnished to do so, subject to the following conditions:
chris 3:be428c849e1c 11 *
chris 3:be428c849e1c 12 *The above copyright notice and this permission notice shall be included in
chris 3:be428c849e1c 13 *all copies or substantial portions of the Software.
chris 3:be428c849e1c 14 *
chris 3:be428c849e1c 15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
chris 3:be428c849e1c 16 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
chris 3:be428c849e1c 17 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
chris 3:be428c849e1c 18 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
chris 3:be428c849e1c 19 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
chris 3:be428c849e1c 20 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
chris 3:be428c849e1c 21 *THE SOFTWARE.
chris 3:be428c849e1c 22 *
chris 3:be428c849e1c 23 *
chris 3:be428c849e1c 24 * @section DESCRIPTION
chris 3:be428c849e1c 25 *
chris 3:be428c849e1c 26 *This class sets up RPC communication over serial.
chris 3:be428c849e1c 27 */
chris 3:be428c849e1c 28 #ifndef INTERFACE
chris 3:be428c849e1c 29 #define INTERFACE
chris 3:be428c849e1c 30
chris 3:be428c849e1c 31 /**
chris 3:be428c849e1c 32 *Includes
chris 3:be428c849e1c 33 */
chris 3:be428c849e1c 34 #include "mbed.h"
chris 3:be428c849e1c 35 #include "platform.h"
chris 3:be428c849e1c 36 #include "rpc.h"
chris 3:be428c849e1c 37 #include "RPCFunction.h"
chris 3:be428c849e1c 38 #include "RPCVariable.h"
chris 3:be428c849e1c 39
chris 3:be428c849e1c 40
chris 3:be428c849e1c 41 namespace mbed{
chris 3:be428c849e1c 42 /**
chris 3:be428c849e1c 43 *Provides an Interface to mbed over RPC.
chris 3:be428c849e1c 44 *
chris 3:be428c849e1c 45 *For the chosen communication type this class sets up the necessary interrupts to receive RPC messages. Receives the messages, passes them to the rpc function and then returns the result.
chris 3:be428c849e1c 46 */
chris 3:be428c849e1c 47 class SerialRPCInterface{
chris 3:be428c849e1c 48 public:
chris 3:be428c849e1c 49 /**
chris 3:be428c849e1c 50 *Constructor
chris 3:be428c849e1c 51 *
chris 3:be428c849e1c 52 *Sets up RPC communication using serial communication.
chris 3:be428c849e1c 53 *
chris 3:be428c849e1c 54 *@param tx The transmit pin of the serial port.
chris 3:be428c849e1c 55 *@param rx The receive pin of the serial port.
chris 3:be428c849e1c 56 *@param baud Set the baud rate, default is 9600.
chris 3:be428c849e1c 57 */
chris 3:be428c849e1c 58 SerialRPCInterface(PinName tx, PinName rx, int baud = 9600);
chris 3:be428c849e1c 59
chris 3:be428c849e1c 60 /**
chris 3:be428c849e1c 61 *Disable the RPC.
chris 3:be428c849e1c 62 *
chris 3:be428c849e1c 63 *This will stop RPC messages being recevied and interpreted by this library. This might be used to prevent RPC commands interrupting an important piece of code on mbed.
chris 3:be428c849e1c 64 */
chris 3:be428c849e1c 65 void Disable(void);
chris 3:be428c849e1c 66
chris 3:be428c849e1c 67 /**
chris 3:be428c849e1c 68 *Enable the RPC
chris 3:be428c849e1c 69 *
chris 3:be428c849e1c 70 *This will set this class to receiving and executing RPC commands. The class starts in this mode so this function only needs to be called if you have previosuly disabled the RPC.
chris 3:be428c849e1c 71 *
chris 3:be428c849e1c 72 */
chris 3:be428c849e1c 73 void Enable(void);
chris 3:be428c849e1c 74
chris 3:be428c849e1c 75 //The Serial Port
chris 3:be428c849e1c 76 Serial pc;
chris 3:be428c849e1c 77
chris 3:be428c849e1c 78
chris 3:be428c849e1c 79 private:
chris 3:be428c849e1c 80 //Handle messgaes and take appropriate action
chris 3:be428c849e1c 81 void _MsgProcess(void);
chris 3:be428c849e1c 82 void _RegClasses(void);
chris 3:be428c849e1c 83 void _RPCSerial();
chris 3:be428c849e1c 84 bool _enabled;
chris 3:be428c849e1c 85 char _command[256];
chris 3:be428c849e1c 86 char _response[256];
chris 3:be428c849e1c 87 bool _RPCflag;
chris 3:be428c849e1c 88 };
chris 3:be428c849e1c 89 }
chris 3:be428c849e1c 90 #endif