HTTP RPC Server mit vordefinierten Objekten
Dependencies: EthernetInterface HttpServer Servo mbed-rtos mbed
Fork of RPCHTTPServerVariable by
Mittels RPCVariable lassen sich lokale Variablen setzen. Diese Variablen können gesetzt write oder gelesen read werden.
Mittels Ticker u.ä. Varianten lassen sich damit auch Objektwerte setzen, welche von RPC nicht unterstützt werden, z.B. Servo's.
Client
Wert setzen: http://<IP-Adresse mbed>/rpc/servo2/write+0.5
mbed-rpc/RPCFunction.h@17:752e17b9aab4, 2016-03-20 (annotated)
- Committer:
- stefan1691
- Date:
- Sun Mar 20 07:39:09 2016 +0000
- Revision:
- 17:752e17b9aab4
- Parent:
- 14:3835863bc412
https statt http verhindert Fehler
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stefan1691 | 14:3835863bc412 | 1 | /* mbed Microcontroller Library |
stefan1691 | 14:3835863bc412 | 2 | * Copyright (c) 2006-2013 ARM Limited |
stefan1691 | 14:3835863bc412 | 3 | * |
stefan1691 | 14:3835863bc412 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
stefan1691 | 14:3835863bc412 | 5 | * you may not use this file except in compliance with the License. |
stefan1691 | 14:3835863bc412 | 6 | * You may obtain a copy of the License at |
stefan1691 | 14:3835863bc412 | 7 | * |
stefan1691 | 14:3835863bc412 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
stefan1691 | 14:3835863bc412 | 9 | * |
stefan1691 | 14:3835863bc412 | 10 | * Unless required by applicable law or agreed to in writing, software |
stefan1691 | 14:3835863bc412 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
stefan1691 | 14:3835863bc412 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
stefan1691 | 14:3835863bc412 | 13 | * See the License for the specific language governing permissions and |
stefan1691 | 14:3835863bc412 | 14 | * limitations under the License. |
stefan1691 | 14:3835863bc412 | 15 | */ |
stefan1691 | 14:3835863bc412 | 16 | #ifndef RPCFUNCTION_RPC |
stefan1691 | 14:3835863bc412 | 17 | #define RPCFUNCTION_RPC |
stefan1691 | 14:3835863bc412 | 18 | |
stefan1691 | 14:3835863bc412 | 19 | #include "rpc.h" |
stefan1691 | 14:3835863bc412 | 20 | #define STR_LEN 64 |
stefan1691 | 14:3835863bc412 | 21 | |
stefan1691 | 14:3835863bc412 | 22 | namespace mbed { |
stefan1691 | 14:3835863bc412 | 23 | |
stefan1691 | 14:3835863bc412 | 24 | /** |
stefan1691 | 14:3835863bc412 | 25 | * |
stefan1691 | 14:3835863bc412 | 26 | *Class to call custom functions over RPC |
stefan1691 | 14:3835863bc412 | 27 | * |
stefan1691 | 14:3835863bc412 | 28 | */ |
stefan1691 | 14:3835863bc412 | 29 | class RPCFunction: public RPC { |
stefan1691 | 14:3835863bc412 | 30 | public: |
stefan1691 | 14:3835863bc412 | 31 | /** |
stefan1691 | 14:3835863bc412 | 32 | * Constructor |
stefan1691 | 14:3835863bc412 | 33 | * |
stefan1691 | 14:3835863bc412 | 34 | *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output) |
stefan1691 | 14:3835863bc412 | 35 | *@param name The name of this object |
stefan1691 | 14:3835863bc412 | 36 | */ |
stefan1691 | 14:3835863bc412 | 37 | RPCFunction(void (*f)(Arguments*, Reply*), const char* = NULL); |
stefan1691 | 14:3835863bc412 | 38 | |
stefan1691 | 14:3835863bc412 | 39 | /** |
stefan1691 | 14:3835863bc412 | 40 | *run |
stefan1691 | 14:3835863bc412 | 41 | * |
stefan1691 | 14:3835863bc412 | 42 | *Calls the attached function passing the string in but doesn't return the result. |
stefan1691 | 14:3835863bc412 | 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 |
stefan1691 | 14:3835863bc412 | 44 | *@return A string output from the function |
stefan1691 | 14:3835863bc412 | 45 | */ |
stefan1691 | 14:3835863bc412 | 46 | void run(Arguments* args, Reply* r); |
stefan1691 | 14:3835863bc412 | 47 | |
stefan1691 | 14:3835863bc412 | 48 | virtual const struct rpc_method *get_rpc_methods(); |
stefan1691 | 14:3835863bc412 | 49 | |
stefan1691 | 14:3835863bc412 | 50 | private: |
stefan1691 | 14:3835863bc412 | 51 | void (*_ftr)(Arguments*, Reply*); |
stefan1691 | 14:3835863bc412 | 52 | |
stefan1691 | 14:3835863bc412 | 53 | char _input[STR_LEN]; |
stefan1691 | 14:3835863bc412 | 54 | char _output[STR_LEN]; |
stefan1691 | 14:3835863bc412 | 55 | }; |
stefan1691 | 14:3835863bc412 | 56 | |
stefan1691 | 14:3835863bc412 | 57 | } |
stefan1691 | 14:3835863bc412 | 58 | |
stefan1691 | 14:3835863bc412 | 59 | #endif |