Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:laboratoare:2025:lab4 [2025/10/21 11:38]
dan.tudose [CoAP Server]
iothings:laboratoare:2025:lab4 [2025/10/28 11:29] (current)
dan.tudose [CoAP Server]
Line 80: Line 80:
 On the CoAP side, the library handles all the protocol details—message type, message ID, token management, options, and parsing—so your sketch only deals with high-level actions. You issue a client request with coap.get(remoteIP,​ 5683, ""​),​ and when the server replies, the callback receives a parsed CoapPacket. The code prints the CoAP code (e.g., 2.xx success), basic header info, and the payload as text.  On the CoAP side, the library handles all the protocol details—message type, message ID, token management, options, and parsing—so your sketch only deals with high-level actions. You issue a client request with coap.get(remoteIP,​ 5683, ""​),​ and when the server replies, the callback receives a parsed CoapPacket. The code prints the CoAP code (e.g., 2.xx success), basic header info, and the payload as text. 
  
 +[[iothings:​laboratoare:​2025_code:​lab4_1|Click here to get the code example]]
  
 After building, you should get a similar print-out in the console: After building, you should get a similar print-out in the console:
Line 123: Line 123:
 </​note>​ </​note>​
  
 +[[iothings:​laboratoare:​2025_code:​lab4_2|Click here to get the code example.]]
  
 +
 +Test it from your computer with the following commands, where esp-ip is the IP the node prints after connecting in the serial terminal:
 +
 +<​code>​
 +# discovery
 +coap-client -v9 -m get -A 40 coap://<​esp-ip>/​.well-known/​core
 +
 +# other resources
 +coap-client -v9 -m get coap://<​esp-ip>/​sys/​uptime
 +coap-client -v9 -m get coap://<​esp-ip>/​net/​rssi
 +coap-client -v9 -m get coap://<​esp-ip>/​led
 +coap-client -v9 -m put -e "​on" ​ coap://<​esp-ip>/​led
 +coap-client -v9 -m put -e "​off"​ coap://<​esp-ip>/​led
 +coap-client -v9 -m post -e "​hello"​ coap://<​esp-ip>/​echo
 +
 +</​code>​
  
 <​note>​**Assignment 1:** <​note>​**Assignment 1:**
Line 130: Line 147:
  
 <​note>​**Assignment 2:** <​note>​**Assignment 2:**
-Build a web page that acts as a GUI for your coap-client queries (e.g. you can do discovery, get and put/post from the page.+Build a web page that acts as a GUI for your coap-client queries (e.g. you can do discovery, get and put/post from the page. You will probably need a proxy to translate coap datagrams to WS or HTTP.
 </​note>​ </​note>​
 +
  
 <​hidden>​ <​hidden>​
iothings/laboratoare/2025/lab4.1761035895.txt.gz · Last modified: 2025/10/21 11:38 by dan.tudose
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0