Skip to content

Commit

Permalink
coap: get version
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanndroid committed Jun 4, 2024
1 parent d37ec34 commit 9c436c4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "esp_event.h"
#include "esp_http_client.h"
#include "esp_netif.h"
#include "esp_ota_ops.h"
#include "location.h"
#include "lwip/apps/sntp.h"
#include "pending_task.h"
Expand Down Expand Up @@ -245,14 +246,15 @@ void coap_get_handler(cJSON *request, cJSON *response) {
cJSON *device = cJSON_CreateObject();
cJSON_AddItemToObject(response, "device", device);
cJSON_AddStringToObject(device, "name", settings.device_name);
cJSON_AddNumberToObject(device, "heap", esp_get_free_heap_size());
cJSON_AddStringToObject(device, "version", esp_ota_get_app_description()->version);

uint8_t mac[6];
esp_read_mac(mac, ESP_MAC_WIFI_STA);
char mac_str[18];
snprintf(mac_str, sizeof(mac_str), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
cJSON_AddStringToObject(device, "mac", mac_str);

cJSON_AddNumberToObject(device, "heap", esp_get_free_heap_size());
} else if (strcmp(item->valuestring, "wifi") == 0) {
cJSON *wifi = cJSON_CreateObject();
cJSON_AddItemToObject(response, "wifi", wifi);
Expand Down

0 comments on commit 9c436c4

Please sign in to comment.