]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/rpc/RPCFunction.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / rpc / RPCFunction.h
1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef RPCFUNCTION_RPC
17 #define RPCFUNCTION_RPC
18
19 #include "rpc.h"
20 #define STR_LEN 64
21
22 namespace mbed {
23
24 /**
25 *
26 *Class to call custom functions over RPC
27 *
28 */
29 class RPCFunction: public RPC {
30 public:
31 /**
32 * Constructor
33 *
34 *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output)
35 *@param name The name of this object
36 */
37 RPCFunction(void (*f)(Arguments*, Reply*), const char* = NULL);
38
39 /**
40 *run
41 *
42 *Calls the attached function passing the string in but doesn't return the result.
43 *@param str The string to be passed into the attached function. This string can consist of any ASCII characters apart from escape codes. The usual limtations on argument content for RPC strings has been removed
44 *@return A string output from the function
45 */
46 void run(Arguments* args, Reply* r);
47
48 virtual const struct rpc_method *get_rpc_methods();
49
50 private:
51 void (*_ftr)(Arguments*, Reply*);
52
53 char _input[STR_LEN];
54 char _output[STR_LEN];
55 };
56
57 }
58
59 #endif
Imprint / Impressum