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 * @section Description
ED7418 0:51f1ef89ec7b 24 *This class provides an object to which a variable can be attached. Any type
ED7418 0:51f1ef89ec7b 25 *for which a parse_args function specilisation exists can be attached. This includes
ED7418 0:51f1ef89ec7b 26 *all of the standard types.
ED7418 0:51f1ef89ec7b 27 *
ED7418 0:51f1ef89ec7b 28 */
ED7418 0:51f1ef89ec7b 29 #ifndef RPCVARIABLE_H_
ED7418 0:51f1ef89ec7b 30 #define RPCVARIABLE_H_
ED7418 0:51f1ef89ec7b 31
ED7418 0:51f1ef89ec7b 32 #include "mbed.h"
ED7418 0:51f1ef89ec7b 33 #include "platform.h"
ED7418 0:51f1ef89ec7b 34 #include "rpc.h"
ED7418 0:51f1ef89ec7b 35 /**
ED7418 0:51f1ef89ec7b 36 *Class to read and set an attached variable using the RPC
ED7418 0:51f1ef89ec7b 37 *
ED7418 0:51f1ef89ec7b 38 */
ED7418 0:51f1ef89ec7b 39 template<class T>
ED7418 0:51f1ef89ec7b 40 class RPCVariable : public Base{
ED7418 0:51f1ef89ec7b 41 public:
ED7418 0:51f1ef89ec7b 42 /**
ED7418 0:51f1ef89ec7b 43 * Constructor
ED7418 0:51f1ef89ec7b 44 *
ED7418 0:51f1ef89ec7b 45 *@param ptr Pointer to the variable to make accessible over RPC. Any type of
ED7418 0:51f1ef89ec7b 46 *variable can be connected
ED7418 0:51f1ef89ec7b 47 *@param name The name of that this object will be over RPC
ED7418 0:51f1ef89ec7b 48 */
ED7418 0:51f1ef89ec7b 49 template<class A>
ED7418 0:51f1ef89ec7b 50 RPCVariable(A * ptr, const char * name) : Base(name){
ED7418 0:51f1ef89ec7b 51 _ptr = ptr;
ED7418 0:51f1ef89ec7b 52 }
ED7418 0:51f1ef89ec7b 53 /**
ED7418 0:51f1ef89ec7b 54 *Read the variable over RPC.
ED7418 0:51f1ef89ec7b 55 *
ED7418 0:51f1ef89ec7b 56 *@return The value of the variable
ED7418 0:51f1ef89ec7b 57 */
ED7418 0:51f1ef89ec7b 58 T read(){
ED7418 0:51f1ef89ec7b 59 return(*_ptr);
ED7418 0:51f1ef89ec7b 60 }
ED7418 0:51f1ef89ec7b 61 /**
ED7418 0:51f1ef89ec7b 62 *Write a value to the variable over RPC
ED7418 0:51f1ef89ec7b 63 *
ED7418 0:51f1ef89ec7b 64 *@param The value to be written to the attached variable.
ED7418 0:51f1ef89ec7b 65 */
ED7418 0:51f1ef89ec7b 66 void write(T value){
ED7418 0:51f1ef89ec7b 67 *_ptr = value;
ED7418 0:51f1ef89ec7b 68 }
ED7418 0:51f1ef89ec7b 69
ED7418 0:51f1ef89ec7b 70 #ifdef MBED_RPC
ED7418 0:51f1ef89ec7b 71 virtual const struct rpc_method *get_rpc_methods();
ED7418 0:51f1ef89ec7b 72 static struct rpc_class *get_rpc_class();
ED7418 0:51f1ef89ec7b 73 #endif
ED7418 0:51f1ef89ec7b 74
ED7418 0:51f1ef89ec7b 75 private:
ED7418 0:51f1ef89ec7b 76 T * _ptr;
ED7418 0:51f1ef89ec7b 77
ED7418 0:51f1ef89ec7b 78 };
ED7418 0:51f1ef89ec7b 79
ED7418 0:51f1ef89ec7b 80 //Set up RPC methods
ED7418 0:51f1ef89ec7b 81 #ifdef MBED_RPC
ED7418 0:51f1ef89ec7b 82 template <class T>
ED7418 0:51f1ef89ec7b 83 const rpc_method *RPCVariable<T>::get_rpc_methods() {
ED7418 0:51f1ef89ec7b 84 static const rpc_method rpc_methods[] = {
ED7418 0:51f1ef89ec7b 85 { "read", rpc_method_caller<T, RPCVariable, &RPCVariable::read> },
ED7418 0:51f1ef89ec7b 86 { "write", rpc_method_caller<RPCVariable, T, &RPCVariable::write> },
ED7418 0:51f1ef89ec7b 87 RPC_METHOD_SUPER(Base)
ED7418 0:51f1ef89ec7b 88 };
ED7418 0:51f1ef89ec7b 89 return rpc_methods;
ED7418 0:51f1ef89ec7b 90 }
ED7418 0:51f1ef89ec7b 91 template <class T>
ED7418 0:51f1ef89ec7b 92 rpc_class *RPCVariable<T>::get_rpc_class() {
ED7418 0:51f1ef89ec7b 93 static const rpc_function funcs[] = {"new", rpc_function_caller<const char*, T,const char* , &Base::construct<RemoteVar, T ,const char*> >,RPC_METHOD_END};
ED7418 0:51f1ef89ec7b 94 static rpc_class c = { "RPCVariable", funcs, NULL };
ED7418 0:51f1ef89ec7b 95 return &c;
ED7418 0:51f1ef89ec7b 96 }
ED7418 0:51f1ef89ec7b 97 #endif
ED7418 0:51f1ef89ec7b 98
ED7418 0:51f1ef89ec7b 99 //There could be specialisation for integer, to also give increment and decrements
ED7418 0:51f1ef89ec7b 100
ED7418 0:51f1ef89ec7b 101
ED7418 0:51f1ef89ec7b 102 #endif //RPCVARIABLE_H_