mbed RPC

Dependents:   RPC_Serial_OVFZ RPCHTTPServer SerialRPC_rtos_example RPC_HTTP ... more

Fork of mbed-rpc by mbed official

Committer:
mbed_official
Date:
Tue May 03 00:16:10 2016 +0100
Revision:
16:33e21ae4d434
Parent:
1:6919289a5946
Synchronized with git revision 9cef243de23875778f461bbe9a8c1bc47e65212b

Full URL: https://github.com/mbedmicro/mbed/commit/9cef243de23875778f461bbe9a8c1bc47e65212b/

Switch to KSDK 2.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:efe8172b4113 1 /* mbed Microcontroller Library
emilmont 1:6919289a5946 2 * Copyright (c) 2006-2013 ARM Limited
mbed_official 0:efe8172b4113 3 *
emilmont 1:6919289a5946 4 * Licensed under the Apache License, Version 2.0 (the "License");
emilmont 1:6919289a5946 5 * you may not use this file except in compliance with the License.
emilmont 1:6919289a5946 6 * You may obtain a copy of the License at
mbed_official 0:efe8172b4113 7 *
emilmont 1:6919289a5946 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 0:efe8172b4113 9 *
emilmont 1:6919289a5946 10 * Unless required by applicable law or agreed to in writing, software
emilmont 1:6919289a5946 11 * distributed under the License is distributed on an "AS IS" BASIS,
emilmont 1:6919289a5946 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
emilmont 1:6919289a5946 13 * See the License for the specific language governing permissions and
emilmont 1:6919289a5946 14 * limitations under the License.
mbed_official 0:efe8172b4113 15 */
mbed_official 0:efe8172b4113 16 #include "RPCFunction.h"
mbed_official 0:efe8172b4113 17
mbed_official 0:efe8172b4113 18 namespace mbed {
mbed_official 0:efe8172b4113 19
mbed_official 0:efe8172b4113 20 //Custom rpc method caller for execute so that the string will not be delimited by anything
mbed_official 0:efe8172b4113 21 void rpc_method_caller_run(RPC *this_ptr, Arguments *arguments, Reply *result) {
mbed_official 0:efe8172b4113 22 ((static_cast<RPCFunction*>(this_ptr))->run)(arguments, result);
mbed_official 0:efe8172b4113 23 }
mbed_official 0:efe8172b4113 24
mbed_official 0:efe8172b4113 25 RPCFunction::RPCFunction(void (*f)(Arguments*, Reply*), const char* name) : RPC(name) {
mbed_official 0:efe8172b4113 26 _ftr = f;
mbed_official 0:efe8172b4113 27 }
mbed_official 0:efe8172b4113 28
emilmont 1:6919289a5946 29 //Just run the attached function using the string thats in private memory - or just using null values,
mbed_official 0:efe8172b4113 30 void RPCFunction::run(Arguments* args, Reply* r) {
mbed_official 0:efe8172b4113 31 (*_ftr)(args, r);
mbed_official 0:efe8172b4113 32 }
mbed_official 0:efe8172b4113 33
mbed_official 0:efe8172b4113 34 const rpc_method *RPCFunction::get_rpc_methods() {
mbed_official 0:efe8172b4113 35 static const rpc_method rpc_methods[] = {
mbed_official 0:efe8172b4113 36 {"run", rpc_method_caller_run }, //Run using custom caller, all characters accepted in string
mbed_official 0:efe8172b4113 37 RPC_METHOD_SUPER(RPC)
mbed_official 0:efe8172b4113 38 };
mbed_official 0:efe8172b4113 39 return rpc_methods;
mbed_official 0:efe8172b4113 40 }
mbed_official 0:efe8172b4113 41
mbed_official 0:efe8172b4113 42 }