Note : Examples have been updated to prevent invocation of bluedroid/wifi APIs from inside timer callback when stopping provisioning. Workaround is to spawn new task from inside the timer callback.
case SYSTEM_EVENT_STA_GOT_IP:
ESP_LOGI(TAG, "STA Got IP");
- /* Station got IP. That means configuraion is successful.
+ /* Station got IP. That means configuration is successful.
* Schedule timer to stop provisioning app after 30 seconds. */
g_prov->wifi_state = WIFI_PROV_STA_CONNECTED;
if (g_prov && g_prov->timer) {
return ESP_ERR_NO_MEM;
}
- /* Initialise app data */
+ /* Initialize app data */
g_prov->pop = pop;
g_prov->security = security;
protocomm_delete(g_prov->pc);
}
-/* Callback to be invoked by timer */
-static void _stop_prov_cb(void * arg)
+/* Task spawned by timer callback */
+static void stop_prov_task(void * arg)
{
ESP_LOGI(TAG, "Stopping provisioning");
app_prov_stop_service();
free(g_prov);
g_prov = NULL;
ESP_LOGI(TAG, "Provisioning stopped");
+
+ vTaskDelete(NULL);
+}
+
+/* Callback to be invoked by timer */
+static void _stop_prov_cb(void * arg)
+{
+ xTaskCreate(&stop_prov_task, "stop_prov", 2048, NULL, tskIDLE_PRIORITY, NULL);
}
/* Event handler for starting/stopping provisioning.
case SYSTEM_EVENT_STA_GOT_IP:
ESP_LOGI(TAG, "STA Got IP");
- /* Station got IP. That means configuraion is successful.
+ /* Station got IP. That means configuration is successful.
* Schedule timer to stop provisioning app after 30 seconds. */
g_prov->wifi_state = WIFI_PROV_STA_CONNECTED;
if (g_prov && g_prov->timer) {
return ESP_ERR_NO_MEM;
}
- /* Initialise app data */
+ /* Initialize app data */
g_prov->pop = pop;
g_prov->security = security;
.callback = _stop_prov_cb,
.arg = NULL,
.dispatch_method = ESP_TIMER_TASK,
- .name = "stop_softap_tm"
+ .name = "stop_console_tm"
};
esp_err_t err = esp_timer_create(&timer_conf, &g_prov->timer);
if (err != ESP_OK) {
protocomm_delete(g_prov->pc);
}
-/* Callback to be invoked by timer */
-static void _stop_softap_cb(void * arg)
+/* Task spawned by timer callback */
+static void stop_prov_task(void * arg)
{
ESP_LOGI(TAG, "Stopping provisioning");
app_prov_stop_service();
free(g_prov);
g_prov = NULL;
ESP_LOGI(TAG, "Provisioning stopped");
+
+ vTaskDelete(NULL);
+}
+
+/* Callback to be invoked by timer */
+static void _stop_prov_cb(void * arg)
+{
+ xTaskCreate(&stop_prov_task, "stop_prov", 2048, NULL, tskIDLE_PRIORITY, NULL);
}
/* Event handler for starting/stopping provisioning.
case SYSTEM_EVENT_STA_GOT_IP:
ESP_LOGI(TAG, "STA Got IP");
- /* Station got IP. That means configuraion is successful.
+ /* Station got IP. That means configuration is successful.
* Schedule timer to stop provisioning app after 30 seconds. */
g_prov->wifi_state = WIFI_PROV_STA_CONNECTED;
if (g_prov && g_prov->timer) {
* to reconnect and get STA connection status from the device.
* Otherwise, the AP will be turned off before the user can
* reconnect and thus the user app will see connection timed out,
- * signalling a failure in provisioning. */
+ * signaling a failure in provisioning. */
esp_timer_start_once(g_prov->timer, 30000*1000U);
}
break;
static esp_err_t start_wifi_ap(const char *ssid, const char *pass)
{
- /* Initialise WiFi with default configuration */
+ /* Initialize WiFi with default configuration */
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
esp_err_t err = esp_wifi_init(&cfg);
if (err != ESP_OK) {
/* Create timer object as a member of app data */
esp_timer_create_args_t timer_conf = {
- .callback = _stop_softap_cb,
+ .callback = _stop_prov_cb,
.arg = NULL,
.dispatch_method = ESP_TIMER_TASK,
.name = "stop_softap_tm"
protocomm_delete(g_prov->pc);
}
-/* Callback to be invoked by timer */
-static void _stop_softap_cb(void * arg)
+/* Task spawned by timer callback */
+static void stop_prov_task(void * arg)
{
ESP_LOGI(TAG, "Stopping provisioning");
app_prov_stop_service();
free(g_prov);
g_prov = NULL;
ESP_LOGI(TAG, "Provisioning stopped");
+
+ vTaskDelete(NULL);
+}
+
+/* Callback to be invoked by timer */
+static void _stop_prov_cb(void * arg)
+{
+ xTaskCreate(&stop_prov_task, "stop_prov", 2048, NULL, tskIDLE_PRIORITY, NULL);
}
/* Event handler for starting/stopping provisioning.
case SYSTEM_EVENT_STA_GOT_IP:
ESP_LOGI(TAG, "STA Got IP");
- /* Station got IP. That means configuraion is successful.
+ /* Station got IP. That means configuration is successful.
* Schedule timer to stop provisioning app after 30 seconds. */
g_prov->wifi_state = WIFI_PROV_STA_CONNECTED;
if (g_prov && g_prov->timer) {
* to reconnect and get STA connection status from the device.
* Otherwise, the AP will be turned off before the user can
* reconnect and thus the user app will see connection timed out,
- * signalling a failure in provisioning. */
+ * signaling a failure in provisioning. */
esp_timer_start_once(g_prov->timer, 30000*1000U);
}
break;
static esp_err_t start_wifi_ap(const char *ssid, const char *pass)
{
- /* Initialise WiFi with default configuration */
+ /* Initialize WiFi with default configuration */
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
esp_err_t err = esp_wifi_init(&cfg);
if (err != ESP_OK) {
return ESP_ERR_NO_MEM;
}
- /* Initialise app data */
+ /* Initialize app data */
g_prov->pop = pop;
g_prov->security = security;
/* Create timer object as a member of app data */
esp_timer_create_args_t timer_conf = {
- .callback = _stop_softap_cb,
+ .callback = _stop_prov_cb,
.arg = NULL,
.dispatch_method = ESP_TIMER_TASK,
.name = "stop_softap_tm"