I wrote source code for OAT update via BLE. We use react-native for Update application.
In GAP, ESP32 - peripheral, Phone(Application) - central
In GATT, ESP32- GATTS, Phone - GATTC
Here is sequence of OAT Update.
1. Connect Bluetooth on GAP.
2. Enable notify on ESP32. (Write 0x0001) <- Here
3. ESP32 ready to OTA Update(etc. call esp_ota_begin())
4. Notify it to Phone when ready for OTA update.
5. Phone write(without response) OTA data.
6. ...
Problem
In android, it working good.
But in IOS, the connection is always disconnected when enable notify (2.).
Actually, disconnected when call `esp_ota_begin()` function.
Can you help me?
Write callback for Notify
Code: Select all
case 0x0001:
EPS_LOGI(TAG, "Start Notification & OTA Update Request");
err = ota_init();
if (err == ESP_OK)
{
memcpy(value, "OK", sizeof(value));
}
else
{
memcpy(value, "NO", sizeof(value));
}
esp_ble_gatts_send_indicate(gatts_service_list_array[OTA_APP_ID].gatts_if,
param->conn_id,
gatts_service_list_array[OTA_APP_ID].characteristic[1].handle,
sizeof(value),
value,
false);
ESP_LOGD(TAG, "Sent notification");
break;
Code: Select all
esp_partition_iterator_t partition_iterator = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, "ota_0");
partition = esp_partition_get(partition_iterator);
ESP_LOGI(TAG, "label: %s, address = 0x%08X, size = 0x%08X, type = %d, subtype = %d, chip_id = 0x%08X, size = 0x%08X",
partition->label,
partition->address,
partition->size,
partition->subtype,
partition->type,
partition->flash_chip->chip_id,
partition->flash_chip->size);
// Disconnect In Here!
esp_ota_begin(partition, OTA_PARTITION_SIZE, &ota_handle);