![](/media/cache/group/ep_srxDLMd.webp.50x50_q85.jpg)
CoAP Device Server Client mit leshan Server
Dependencies: EthernetInterface mbed-rtos mbed nsdl_lib
Fork of COAPmbed by
Sandbox Server
Eclipse stellt einen Testserver unter http://leshan.eclipse.org/ zur Verfügung. Das Programm verbindet sich mit diesem und ist unter mbed-k64f... erreichbar.
Installation lokale Version leshan
wget https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar java -jar ./leshan-server-demo.jar
cURL
Die Funktionen können mittels cURL oder Browser wie folgt getestet werden:
# Alle Clients abfragen (Antwort im JSON Format) curl -X GET http://localhost:8080/api/clients # Wert von LED2 abfragen (Antwort im text/plain Format) curl -X GET http://localhost:8080/api/clients/mbed-k64f-1234/10/0/2 # Wert für LED2 setzen curl -X GET -vvv http://localhost:8080/api/clients/mbed-k64f-1234/10/0/2 -H "Content-Type: text/plain" -d "10"
resources/PwmOutResource.h@22:6d4c96af70e3, 2015-10-15 (annotated)
- Committer:
- marcel1691
- Date:
- Thu Oct 15 07:53:35 2015 +0000
- Revision:
- 22:6d4c96af70e3
- Parent:
- 15:fba25b7e63cd
Standard zurueckgesetzt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stefan1691 | 15:fba25b7e63cd | 1 | /** |
stefan1691 | 15:fba25b7e63cd | 2 | * PwmOut Resourcen Abhandlung - Klassen Definition |
stefan1691 | 15:fba25b7e63cd | 3 | */ |
stefan1691 | 15:fba25b7e63cd | 4 | |
stefan1691 | 15:fba25b7e63cd | 5 | #ifndef PWMOUT_RESOURCE_H |
stefan1691 | 15:fba25b7e63cd | 6 | #define PWMOUT_RESOURCE_H |
stefan1691 | 15:fba25b7e63cd | 7 | |
stefan1691 | 15:fba25b7e63cd | 8 | #include "nsdl_support.h" |
stefan1691 | 15:fba25b7e63cd | 9 | |
stefan1691 | 15:fba25b7e63cd | 10 | class PwmOutResource |
stefan1691 | 15:fba25b7e63cd | 11 | { |
stefan1691 | 15:fba25b7e63cd | 12 | public: |
stefan1691 | 15:fba25b7e63cd | 13 | /** Default Konstruktor |
stefan1691 | 15:fba25b7e63cd | 14 | * @param pin Pin fuer PwmOut |
stefan1691 | 15:fba25b7e63cd | 15 | * @param id Path zur Resource |
stefan1691 | 15:fba25b7e63cd | 16 | * @param name Name welcher angezeigt werden soll |
stefan1691 | 15:fba25b7e63cd | 17 | */ |
stefan1691 | 15:fba25b7e63cd | 18 | PwmOutResource( PinName pin, char *name, char *id ); |
stefan1691 | 15:fba25b7e63cd | 19 | |
stefan1691 | 15:fba25b7e63cd | 20 | /** Erstellt die Resource |
stefan1691 | 15:fba25b7e63cd | 21 | * @param sn_nsdl_resource_info_s CoAP struct |
stefan1691 | 15:fba25b7e63cd | 22 | * @return 0 wenn ohne Fehler |
stefan1691 | 15:fba25b7e63cd | 23 | */ |
stefan1691 | 15:fba25b7e63cd | 24 | int create( sn_nsdl_resource_info_s *resource_ptr ); |
stefan1691 | 15:fba25b7e63cd | 25 | |
stefan1691 | 15:fba25b7e63cd | 26 | /** Callback wenn die Resource gelesen oder geaendert werden soll |
stefan1691 | 15:fba25b7e63cd | 27 | * @param sn_coap_hdr_s |
stefan1691 | 15:fba25b7e63cd | 28 | * @param sn_nsdl_addr_s |
stefan1691 | 15:fba25b7e63cd | 29 | * @param sn_proto_info_s |
stefan1691 | 15:fba25b7e63cd | 30 | * @return 0 wenn ohne Fehler |
stefan1691 | 15:fba25b7e63cd | 31 | */ |
stefan1691 | 15:fba25b7e63cd | 32 | static uint8_t callback( sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto ); |
stefan1691 | 15:fba25b7e63cd | 33 | |
stefan1691 | 15:fba25b7e63cd | 34 | private: |
stefan1691 | 15:fba25b7e63cd | 35 | /** naechste verkettete Resource, (PwmOutResource) * 0 = Ende der Kette */ |
stefan1691 | 15:fba25b7e63cd | 36 | PwmOutResource *next; |
stefan1691 | 15:fba25b7e63cd | 37 | /** Effektive Resource */ |
stefan1691 | 15:fba25b7e63cd | 38 | PwmOut *resource; |
stefan1691 | 15:fba25b7e63cd | 39 | /** Id / Path */ |
stefan1691 | 15:fba25b7e63cd | 40 | char *id; |
stefan1691 | 15:fba25b7e63cd | 41 | /** Name */ |
stefan1691 | 15:fba25b7e63cd | 42 | char *name; |
stefan1691 | 15:fba25b7e63cd | 43 | }; |
stefan1691 | 15:fba25b7e63cd | 44 | |
stefan1691 | 15:fba25b7e63cd | 45 | #endif /* PWMOUT_RESOURCE_H */ |