@@ -59,8 +59,8 @@ typedef struct sensor_t {
59
59
60
60
char device_id[19 ];
61
61
char *edge_pub_topic;
62
- char * mqtt_hello = "NO HELLO" ;
63
- sensor sensors [MAX_DEVICES ] = {0 };
62
+ char *mqtt_hello;
63
+ sensor sensors[MAX_DEVICES] = {};
64
64
65
65
struct hello {
66
66
const char *entity_type;
@@ -234,8 +234,8 @@ void onewire_start(void)
234
234
235
235
ESP_LOGI (TAG, " [1-Wire] looking for connected devices on pin %d..." , GPIO_DS18B20_0);
236
236
237
- OneWireBus_ROMCode device_rom_codes [MAX_DEVICES ] = {0 };
238
- OneWireBus_SearchState search_state = {0 };
237
+ OneWireBus_ROMCode device_rom_codes[MAX_DEVICES] = {};
238
+ OneWireBus_SearchState search_state = {};
239
239
bool found = false ;
240
240
owb_search_first (owb, &search_state, &found);
241
241
while (found) {
@@ -322,7 +322,7 @@ void onewire_poll(void)
322
322
// Read the results immediately after conversion otherwise it may fail
323
323
// (using printf before reading may take too long)
324
324
float readings[MAX_DEVICES] = { 0 };
325
- DS18B20_ERROR errors [MAX_DEVICES ] = { 0 };
325
+ DS18B20_ERROR errors[MAX_DEVICES] = {};
326
326
327
327
for (int offset = 0 ; offset < devices_found; ++offset) {
328
328
errors[offset] = ds18b20_read_temp (devices[offset], &readings[offset]);
@@ -399,21 +399,20 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
399
399
static void mqtt_event_handler (void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
400
400
{
401
401
ESP_LOGD (TAG, " Event dispatched from event loop base=%s, event_id=%d" , base, event_id);
402
- mqtt_event_handler_cb (event_data );
402
+ mqtt_event_handler_cb (( esp_mqtt_event_handle_t ) event_data);
403
403
}
404
404
405
405
void mqtt_start (void )
406
406
{
407
- esp_mqtt_client_config_t mqtt_cfg = {
408
- .uri = CONFIG_BROKER_URL ,
409
- };
407
+ esp_mqtt_client_config_t mqtt_cfg = {};
408
+ mqtt_cfg.uri = CONFIG_BROKER_URL;
410
409
411
410
mqtt_client = esp_mqtt_client_init (&mqtt_cfg);
412
- esp_mqtt_client_register_event (mqtt_client , ESP_EVENT_ANY_ID , mqtt_event_handler , mqtt_client );
411
+ esp_mqtt_client_register_event (mqtt_client, ( esp_mqtt_event_id_t ) ESP_EVENT_ANY_ID, mqtt_event_handler, mqtt_client);
413
412
esp_mqtt_client_start (mqtt_client);
414
413
}
415
414
416
- void app_main (void )
415
+ extern " C " void app_main (void )
417
416
{
418
417
ESP_LOGI (TAG, " [core] Oh, hai" );
419
418
ESP_LOGI (TAG, " [core] free memory: %d bytes" , esp_get_free_heap_size ());
0 commit comments