Differences

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

Link to this comparison view

iothings:laboratoare:2025:lab12 [2026/01/03 18:45]
dan.tudose [Goal]
iothings:laboratoare:2025:lab12 [2026/01/03 23:05] (current)
dan.tudose [Build, flash, test]
Line 169: Line 169:
     * verify ''​CONFIG_FS_SHELL''​ (and any related symbols) are enabled     * verify ''​CONFIG_FS_SHELL''​ (and any related symbols) are enabled
  
 +<​note>​Assignment:​ Add a BME680 logging service with a new "​bme_log"​ shell command, plus a background thread that appends CSV entries with uptime timestamps to a file named bme_log.dat. ​
  
-===== 4. Wi‑Fi Webserver ​+ BME680 Sensor Data =====+Usage examples: 
 + 
 +> bme_log start 5 
 +> bme_log status 
 +> bme_log interval 10 
 +> bme_log stop 
 +> fs cat /​lfs/​logs/​bme_log.dat 
 + 
 +</​note>​ 
 +===== 4. Wi‑Fi Webserver =====
  
 ==== Goal ==== ==== Goal ====
Line 176: Line 186:
   * connects to Wi‑Fi (WPA2‑PSK)   * connects to Wi‑Fi (WPA2‑PSK)
   * obtains an IPv4 address via DHCP   * obtains an IPv4 address via DHCP
-  ​* reads BME680 sensor data periodically +  * serves ​a web page to a browser ​
-  ​* serves ​the latest sensor values ​to a browser ​+
  
  
Line 188: Line 197:
 ==== Configure the Project ==== ==== Configure the Project ====
  
-Create a new folder, e.g. ''​sparrow_web_bme''​ and unzip the project {{:​iothings:​laboratoare:​2025:​sparrow_web_bme.zip|here}}.+Create a new folder, e.g. ''​sparrow_web''​ and unzip the project {{:​iothings:​laboratoare:​2025:​sparrow_littlefs_ws.zip|here}}.
  
 ====  Build, flash, test ==== ====  Build, flash, test ====
Line 203: Line 212:
 </​code>​ </​code>​
  
-Open serial output and note the printed IP address. 
-From a machine on the same LAN, open: 
  
-  * ''​http:​//<device-ip>:<port>/''​+The code runs a HTTP static file server backed by LittleFS and auto-started at boot; it serves files from /lfs/www on port 8080 and uses the HTTP server’s static_fs handler. 
 + 
 +In the serial shell, you need to run the following commands: 
 + 
 +1. Connect to WiFi: 
 +<code> 
 +wifi scan 
 +wifi connect ​-s "​SSID"​ -p "​PASS"​ -k 1 
 +wifi status 
 +</code> 
 + 
 +2. Check the webserver is up and running and get the board IP address: 
 +<code> 
 +net http 
 +net iface 
 +</code> 
 + 
 +3. Write a simple index.html file into ''​/​lfs/​www'':​ 
 +<​code>​fs write /​lfs/​www/​index.html -o 0 3c 68 31 3e 48 69 3c 2f 68 31 3e</​code>​ 
 + 
 +4. Browse: http://​[board-ip]:​8080/​ 
  
 Expected: Expected:
-  * browser receives a response containing ​the latest sensor values+  * browser receives a response containing ​"​Hi"​
  
-==== Troubleshooting ==== +<​note>​AssignmentAdd a dynamic HTTP endpoint that serves the current contents of bme_log.dat as an HTML page with a 10second autorefresh. So, if you conect to http://[board-ip]:8080/​bme_log it will automatically serve the contents of the log file.</​note>​
-  * No Wi‑Fi logs: +
-    * raise log level (e.g. default level or module-specific) +
-    * ensure WiFi mgmt is enabled +
-  * No IP address: +
-    * verify DHCP is enabled +
-    * ensure DHCP is started after link is up +
-  * “memory allocation failed” from WiFi adapter: +
-    * reduce concurrent HTTP clients +
-    * reduce buffer sizes (HTTP response buffer) +
-    * avoid repeated dynamic allocations in the HTTP thread +
-    * consider increasing heap pool size only if you have flash/RAM headroom +
-  * Browser connects but gets no response: +
-    * verify socket calls are using Zephyr’s socket headers +
-    * verify server binds to INADDR_ANY on the chosen port +
-    * ensure response includes valid HTTP headers and CRLF+
  
  
iothings/laboratoare/2025/lab12.1767458713.txt.gz · Last modified: 2026/01/03 18:45 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