bugID:19068933:[breeze] Fix OTA issue, when OTA is done, avoid adv again for reconnection issue.
@@ -24,6 +24,7 @@ static apinfo_ready_cb m_apinfo_handler;
#if BZ_ENABLE_OTA
static ota_dev_cb m_ota_dev_handler;
+static bool g_disconnect_by_ota = false;
#endif
struct adv_data_s {
@@ -49,6 +50,9 @@ static void event_handler(ali_event_t *p_event)
switch (p_event->type) {
case BZ_EVENT_CONNECTED:
notify_status(CONNECTED);
+#if BZ_ENABLE_OTA
+ g_disconnect_by_ota = false;
+#endif
break;
case BZ_EVENT_DISCONNECTED:
@@ -59,7 +63,13 @@ static void event_handler(ali_event_t *p_event)
m_disc_evt.cmd_evt.m_evt.evt = ALI_OTA_ON_DISCONNECTED;
m_disc_evt.cmd_evt.m_evt.d = 0;
b_notify_upper = true;
+ if(g_disconnect_by_ota == true){
+ //do nothing here as expected
+ } else
#endif
+ {
+ breeze_restart_advertising();
+ }
break;
case BZ_EVENT_AUTHENTICATED:
@@ -82,6 +92,12 @@ static void event_handler(ali_event_t *p_event)
m_disc_evt.cmd_evt.m_evt.d = cmd;
b_notify_upper = true;
}
+
+ /*there is a special case here to handle, for the last disconnected event caused by OTA,
+ * advertising will be confusing, which will be postponed till reboot*/
+ if(cmd ==BZ_CMD_OTA_CHECK_RESULT){
+ g_disconnect_by_ota = true;
+ }
#endif
break;
