
An example HTTP Server using new Ethernet Interface and localfilesystem.
Dependencies: EthernetInterface HttpServer mbed-rpc mbed-rtos mbed
Fork of giken9_HTMLServer_Sample by
mbed-rpc/RPCFunction.cpp@0:7766f6712673, 2014-03-12 (annotated)
- Committer:
- yueee_yt
- Date:
- Wed Mar 12 04:19:54 2014 +0000
- Revision:
- 0:7766f6712673
???????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yueee_yt | 0:7766f6712673 | 1 | /* mbed Microcontroller Library |
yueee_yt | 0:7766f6712673 | 2 | * Copyright (c) 2006-2013 ARM Limited |
yueee_yt | 0:7766f6712673 | 3 | * |
yueee_yt | 0:7766f6712673 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
yueee_yt | 0:7766f6712673 | 5 | * you may not use this file except in compliance with the License. |
yueee_yt | 0:7766f6712673 | 6 | * You may obtain a copy of the License at |
yueee_yt | 0:7766f6712673 | 7 | * |
yueee_yt | 0:7766f6712673 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
yueee_yt | 0:7766f6712673 | 9 | * |
yueee_yt | 0:7766f6712673 | 10 | * Unless required by applicable law or agreed to in writing, software |
yueee_yt | 0:7766f6712673 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
yueee_yt | 0:7766f6712673 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
yueee_yt | 0:7766f6712673 | 13 | * See the License for the specific language governing permissions and |
yueee_yt | 0:7766f6712673 | 14 | * limitations under the License. |
yueee_yt | 0:7766f6712673 | 15 | */ |
yueee_yt | 0:7766f6712673 | 16 | #include "RPCFunction.h" |
yueee_yt | 0:7766f6712673 | 17 | |
yueee_yt | 0:7766f6712673 | 18 | namespace mbed { |
yueee_yt | 0:7766f6712673 | 19 | |
yueee_yt | 0:7766f6712673 | 20 | //Custom rpc method caller for execute so that the string will not be delimited by anything |
yueee_yt | 0:7766f6712673 | 21 | void rpc_method_caller_run(RPC *this_ptr, Arguments *arguments, Reply *result) { |
yueee_yt | 0:7766f6712673 | 22 | ((static_cast<RPCFunction*>(this_ptr))->run)(arguments, result); |
yueee_yt | 0:7766f6712673 | 23 | } |
yueee_yt | 0:7766f6712673 | 24 | |
yueee_yt | 0:7766f6712673 | 25 | RPCFunction::RPCFunction(void (*f)(Arguments*, Reply*), const char* name) : RPC(name) { |
yueee_yt | 0:7766f6712673 | 26 | _ftr = f; |
yueee_yt | 0:7766f6712673 | 27 | } |
yueee_yt | 0:7766f6712673 | 28 | |
yueee_yt | 0:7766f6712673 | 29 | //Just run the attached function using the string thats in private memory - or just using null values, |
yueee_yt | 0:7766f6712673 | 30 | void RPCFunction::run(Arguments* args, Reply* r) { |
yueee_yt | 0:7766f6712673 | 31 | (*_ftr)(args, r); |
yueee_yt | 0:7766f6712673 | 32 | } |
yueee_yt | 0:7766f6712673 | 33 | |
yueee_yt | 0:7766f6712673 | 34 | const rpc_method *RPCFunction::get_rpc_methods() { |
yueee_yt | 0:7766f6712673 | 35 | static const rpc_method rpc_methods[] = { |
yueee_yt | 0:7766f6712673 | 36 | {"run", rpc_method_caller_run }, //Run using custom caller, all characters accepted in string |
yueee_yt | 0:7766f6712673 | 37 | RPC_METHOD_SUPER(RPC) |
yueee_yt | 0:7766f6712673 | 38 | }; |
yueee_yt | 0:7766f6712673 | 39 | return rpc_methods; |
yueee_yt | 0:7766f6712673 | 40 | } |
yueee_yt | 0:7766f6712673 | 41 | |
yueee_yt | 0:7766f6712673 | 42 | } |