Small Testprogram to have WebAccess via Webserver to a 433Mhz tranmitter to control remotly some devices from remote, with TFTP, NTP and RMF. This could be a base to develop applications.

Dependencies:   ChaNFSSD TFTPServer RMFWeb

Dependents:   RMFWeb

Committer:
ED7418
Date:
Mon Jun 16 07:40:08 2014 +0000
Revision:
1:809b59c7a800
Parent:
0:51f1ef89ec7b
mbed-lib and other libs are a based on a project, published in a Elektor-book "ARM-microkontroller Part II".

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ED7418 0:51f1ef89ec7b 1 /**
ED7418 0:51f1ef89ec7b 2 * @section LICENSE
ED7418 0:51f1ef89ec7b 3 *Copyright (c) 2010 ARM Ltd.
ED7418 0:51f1ef89ec7b 4 *
ED7418 0:51f1ef89ec7b 5 *Permission is hereby granted, free of charge, to any person obtaining a copy
ED7418 0:51f1ef89ec7b 6 *of this software and associated documentation files (the "Software"), to deal
ED7418 0:51f1ef89ec7b 7 *in the Software without restriction, including without limitation the rights
ED7418 0:51f1ef89ec7b 8 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
ED7418 0:51f1ef89ec7b 9 *copies of the Software, and to permit persons to whom the Software is
ED7418 0:51f1ef89ec7b 10 *furnished to do so, subject to the following conditions:
ED7418 0:51f1ef89ec7b 11 *
ED7418 0:51f1ef89ec7b 12 *The above copyright notice and this permission notice shall be included in
ED7418 0:51f1ef89ec7b 13 *all copies or substantial portions of the Software.
ED7418 0:51f1ef89ec7b 14 *
ED7418 0:51f1ef89ec7b 15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
ED7418 0:51f1ef89ec7b 16 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ED7418 0:51f1ef89ec7b 17 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
ED7418 0:51f1ef89ec7b 18 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
ED7418 0:51f1ef89ec7b 19 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ED7418 0:51f1ef89ec7b 20 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
ED7418 0:51f1ef89ec7b 21 *THE SOFTWARE.
ED7418 0:51f1ef89ec7b 22 *
ED7418 0:51f1ef89ec7b 23 *
ED7418 0:51f1ef89ec7b 24 * @section DESCRIPTION
ED7418 0:51f1ef89ec7b 25 *
ED7418 0:51f1ef89ec7b 26 *This class sets up RPC communication. This allows objects on mbed to be controlled. Objects can be created or existing objects can be used
ED7418 0:51f1ef89ec7b 27 */
ED7418 0:51f1ef89ec7b 28 #include "SerialRPCInterface.h"
ED7418 0:51f1ef89ec7b 29
ED7418 0:51f1ef89ec7b 30 using namespace mbed;
ED7418 0:51f1ef89ec7b 31
ED7418 0:51f1ef89ec7b 32 //Requires multiple contstructors for each type, serial to set different pin numbers, TCP for port.
ED7418 0:51f1ef89ec7b 33 SerialRPCInterface::SerialRPCInterface(PinName tx, PinName rx, int baud):pc(tx, rx) {
ED7418 0:51f1ef89ec7b 34 _RegClasses();
ED7418 0:51f1ef89ec7b 35 _enabled = true;
ED7418 0:51f1ef89ec7b 36 pc.attach(this, &SerialRPCInterface::_RPCSerial, Serial::RxIrq);
ED7418 0:51f1ef89ec7b 37 if(baud != 9600)pc.baud(baud);
ED7418 0:51f1ef89ec7b 38 }
ED7418 0:51f1ef89ec7b 39
ED7418 0:51f1ef89ec7b 40 void SerialRPCInterface::_RegClasses(void){
ED7418 0:51f1ef89ec7b 41 //Register classes with base
ED7418 0:51f1ef89ec7b 42 Base::add_rpc_class<AnalogIn>();
ED7418 0:51f1ef89ec7b 43 Base::add_rpc_class<AnalogOut>();
ED7418 0:51f1ef89ec7b 44 Base::add_rpc_class<DigitalIn>();
ED7418 0:51f1ef89ec7b 45 Base::add_rpc_class<DigitalOut>();
ED7418 0:51f1ef89ec7b 46 Base::add_rpc_class<DigitalInOut>();
ED7418 0:51f1ef89ec7b 47 Base::add_rpc_class<PwmOut>();
ED7418 0:51f1ef89ec7b 48 Base::add_rpc_class<Timer>();
ED7418 0:51f1ef89ec7b 49 Base::add_rpc_class<BusOut>();
ED7418 0:51f1ef89ec7b 50 Base::add_rpc_class<BusIn>();
ED7418 0:51f1ef89ec7b 51 Base::add_rpc_class<BusInOut>();
ED7418 0:51f1ef89ec7b 52 Base::add_rpc_class<Serial>();
ED7418 0:51f1ef89ec7b 53 }
ED7418 0:51f1ef89ec7b 54
ED7418 0:51f1ef89ec7b 55 void SerialRPCInterface::Disable(void){
ED7418 0:51f1ef89ec7b 56 _enabled = false;
ED7418 0:51f1ef89ec7b 57 }
ED7418 0:51f1ef89ec7b 58 void SerialRPCInterface::Enable(void){
ED7418 0:51f1ef89ec7b 59 _enabled = true;
ED7418 0:51f1ef89ec7b 60 }
ED7418 0:51f1ef89ec7b 61 void SerialRPCInterface::_MsgProcess(void) {
ED7418 0:51f1ef89ec7b 62 if(_enabled == true){
ED7418 0:51f1ef89ec7b 63 rpc(_command, _response);
ED7418 0:51f1ef89ec7b 64 }
ED7418 0:51f1ef89ec7b 65 }
ED7418 0:51f1ef89ec7b 66
ED7418 0:51f1ef89ec7b 67 void SerialRPCInterface::_RPCSerial() {
ED7418 0:51f1ef89ec7b 68 _RPCflag = true;
ED7418 0:51f1ef89ec7b 69 if(_enabled == true){
ED7418 0:51f1ef89ec7b 70 pc.gets(_command, 256);
ED7418 0:51f1ef89ec7b 71 _MsgProcess();
ED7418 0:51f1ef89ec7b 72 pc.printf("%s\n", _response);
ED7418 0:51f1ef89ec7b 73 }
ED7418 0:51f1ef89ec7b 74 _RPCflag = false;
ED7418 0:51f1ef89ec7b 75 }