Skip to content

Commit c737cac

Browse files
committed
report wifi + uptime
1 parent f205283 commit c737cac

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ To deploy run `make r`.
1616

1717
## TODO
1818

19+
* [x] report Wi-Fi RSSI from tsagg
20+
* [ ] deal with Discrete from motion sensor
21+
* [ ] watchdog feature
22+
23+
* [ ] save program in flash
24+
* [ ] multiple Wi-Fi networks saved
25+
1926
* [x] add HF2 over USB Serial (CDC)
2027
* [x] set "CLIENT" flag in announce
2128

main/dmesg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ extern struct CodalLogStore codalLogStore;
4545
* DMESG("USB: Error #%d at %X", k, ptr);
4646
* @endcode
4747
*/
48+
__attribute__((format(printf, 1, 2)))
4849
void codal_dmesg(const char *format, ...);
50+
__attribute__((format(printf, 1, 2)))
4951
void codal_dmesgf(const char *format, ...);
5052

5153
void codal_dmesg_set_flush_fn(void (*fn)(void));
5254
void codal_dmesg_flush(void);
5355

5456
void codal_vdmesg(const char *format, va_list ap);
5557

56-
int codal_vsprintf(char *dst, unsigned dstsize, const char *format, va_list ap);
57-
5858
#define DMESG codal_dmesg
5959
#define DMESGF codal_dmesgf
6060

main/wifi.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,17 @@ static void wifi_disconnect(srv_t *state) {
293293
ESP_ERROR_CHECK(esp_wifi_disconnect());
294294
}
295295

296+
static int8_t wifi_rssi(srv_t *state) {
297+
wifi_ap_record_t info;
298+
if (!state->is_connected || esp_wifi_sta_get_ap_info(&info) != 0)
299+
return -128;
300+
return info.rssi;
301+
}
302+
296303
void wifi_process(srv_t *state) {
297304
if (jd_should_sample(&state->next_scan, 5000000)) {
305+
tsagg_update("wifi", wifi_rssi(state));
306+
tsagg_update("uptime", (double)now_ms_long / 1000);
298307
if (!state->is_connected)
299308
wifi_scan(state);
300309
}
@@ -371,15 +380,10 @@ void wifi_handle_packet(srv_t *state, jd_packet_t *pkt) {
371380
case JD_WIFI_CMD_RECONNECT:
372381
state->rescan_requested = true;
373382
wifi_disconnect(state);
374-
375383
return;
376384

377-
case JD_GET(JD_WIFI_REG_RSSI): {
378-
wifi_ap_record_t info;
379-
if (!state->is_connected || esp_wifi_sta_get_ap_info(&info) != 0)
380-
info.rssi = -128;
381-
jd_respond_u8(pkt, info.rssi);
382-
}
385+
case JD_GET(JD_WIFI_REG_RSSI):
386+
jd_respond_u8(pkt, wifi_rssi(state));
383387
return;
384388

385389
case JD_GET(JD_WIFI_REG_IP_ADDRESS): {

0 commit comments

Comments
 (0)