Skip to content

Commit

Permalink
updated merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
tbec committed Oct 4, 2019
2 parents 0fcaf6a + 7cd6dd8 commit c35fb48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
20 changes: 10 additions & 10 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,10 @@ void data_task()
// only need to get it once
esp_app_desc_t *app_desc = esp_ota_get_app_description();

GPS_Tx(PMTK_SET_NMEA_OUTPUT_ALLDATA);
vTaskDelay(1000 / portTICK_PERIOD_MS);

while (1) {
vTaskDelay(CONFIG_DATA_UPLOAD_PERIOD*1000 / portTICK_PERIOD_MS);

vTaskDelay(60000 / portTICK_PERIOD_MS);
PMS_Poll(&pm_dat);
HDC1080_Poll(&temp, &hum);
MICS4514_Poll(&nox, &co);
Expand Down Expand Up @@ -195,9 +193,13 @@ void data_task()
ESP_LOGI(TAG, "MQTT PACKET:\n\r%s", pkt);
err = MQTT_Publish_Data(pkt);
if(err >= ESP_OK){
ESP_LOGI(TAG, "MQTT publish success");
ESP_LOGI(TAG, "MQTT publish success %d", err);
last_publish = uptime;
}
else{
ESP_LOGI(TAG, "MQTT publish fail %d", err);
wifi_manager_check_connection_async();
}

#ifdef CONFIG_SD_DATA_STORE
/************************************
Expand All @@ -206,7 +208,7 @@ void data_task()
time(&now);
localtime_r(&now, &tm);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &tm);
ESP_LOGI(TAG, "The current date/time is: %s", strftime_buf);
ESP_LOGI(TAG, "SD card datetime: %s", strftime_buf);

if (gps.year <= 18 || gps.year >= 80){
hr = uptime / 3600;
Expand Down Expand Up @@ -244,7 +246,7 @@ void data_task()
free(pkt);

/* this is a good place to do a ping test */
wifi_manager_check_connection_async();
// wifi_manager_check_connection_async();
}
}

Expand All @@ -269,10 +271,7 @@ void app_main()
HDC1080_Initialize();

/* Initialize the MICS Driver */
// MICS4514_Initialize();
MICS4514_GPIOEnable();
MICS4514_Disable();
MICS4514_HeaterDisable();
MICS4514_Initialize();

/* Initialize the SD Card Driver */
SD_Initialize();
Expand All @@ -296,6 +295,7 @@ void app_main()
xTaskCreate(&panic_task, "panic", 2096, NULL, 10, NULL);

vTaskDelay(1000 / portTICK_PERIOD_MS); /* the initialization functions below need to wait until the event groups are created in the above tasks */

/*
* These initializations need to be after the tasks, because necessary mutexs get
* created above and used below. Better ways to do this but this is simplest.
Expand Down
2 changes: 2 additions & 0 deletions main/pm_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ esp_err_t PMS_Initialize()
_pm_accum_rst();

PMS_GPIOEnable();
PMS_SET(1);
PMS_RESET(1);

// start the first timer
xTimerStart(pm_timer, 0);
Expand Down
13 changes: 10 additions & 3 deletions main/wifi_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,10 @@ esp_err_t wifi_manager_event_handler(void *ctx, system_event_t *event)
// & (event->event_info.disconnected.reason != WIFI_REASON_NO_AP_FOUND) /* No AP found */
)
{
xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_RECONNECT);
// xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_RECONNECT);
xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_STA_CONNECT_BIT);
}
// xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_STA_CONNECT_BIT);
xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_STA_DISCONNECT_BIT);
xEventGroupClearBits(wifi_manager_event_group, WIFI_MANAGER_WIFI_CONNECTED_BIT);
xEventGroupClearBits(wifi_manager_event_group, WIFI_MANAGER_HAVE_INTERNET_BIT);
Expand Down Expand Up @@ -690,6 +692,7 @@ void wifi_manager_filter_unique( wifi_ap_record_t * aplist, uint16_t * aps) {
}
/* update the length of the list */
*aps = total_unique;
esp_wifi_deinit();
}

void wifi_manager( void * pvParameters ){
Expand Down Expand Up @@ -857,6 +860,7 @@ void wifi_manager( void * pvParameters ){

/* if disconnected, there is no internet */
xEventGroupClearBits(wifi_manager_event_group, WIFI_MANAGER_HAVE_INTERNET_BIT);
LED_SetEventBit(LED_EVENT_WIFI_DISCONNECTED_BIT);

/*disconnect only if it was connected to begin with! */
if( uxBits & WIFI_MANAGER_WIFI_CONNECTED_BIT ){
Expand All @@ -871,7 +875,6 @@ void wifi_manager( void * pvParameters ){
ESP_LOGI(TAG, "WiFi was not connected to begin with!");
}

LED_SetEventBit(LED_EVENT_WIFI_DISCONNECTED_BIT);

xEventGroupClearBits(wifi_manager_event_group, WIFI_MANAGER_STA_DISCONNECT_BIT);

Expand Down Expand Up @@ -1071,6 +1074,9 @@ void wifi_manager( void * pvParameters ){
else {
ESP_LOGI(TAG, "xEventGroupWaitBits[%d] Timeout with Event Handler Event ID: %d", __LINE__, uxBits);
}
if((xEventGroupGetBits(wifi_manager_event_group) & WIFI_MANAGER_HAVE_INTERNET_BIT) == 0){
LED_SetEventBit(LED_EVENT_WIFI_DISCONNECTED_BIT);
}
} /* for(;;) */
vTaskDelay( (TickType_t)10);
} /*void wifi_manager*/
Expand All @@ -1081,6 +1087,7 @@ esp_err_t pingResults(ping_target_id_t msgType, esp_ping_found * pf){
if (pf->recv_count > 0){
ESP_LOGI("PING", "PING TEST SUCCESS");
xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_HAVE_INTERNET_BIT);
LED_SetEventBit(LED_EVENT_WIFI_CONNECTED_BIT);
xTimerStop(wifi_reconnect_timer, 0);
}
else{
Expand All @@ -1100,7 +1107,7 @@ static void wifi_manager_ping_test(){
ESP_LOGI("PING", "Issuing Ping test. IP binary: 0x%08x", ip.s_addr);

xEventGroupClearBits(wifi_manager_event_group, WIFI_MANAGER_HAVE_INTERNET_BIT);

LED_SetEventBit(LED_EVENT_WIFI_DISCONNECTED_BIT);
esp_ping_set_target(PING_TARGET_IP_ADDRESS_COUNT, &ping_count, sizeof(uint32_t));
esp_ping_set_target(PING_TARGET_RCV_TIMEO, &ping_timeout, sizeof(uint32_t));
esp_ping_set_target(PING_TARGET_IP_ADDRESS, &ip.s_addr, sizeof(uint32_t));
Expand Down

0 comments on commit c35fb48

Please sign in to comment.