ESP32 losing connection to iOs

scn-eng
Posts: 1
Joined: Mon Aug 12, 2024 5:49 pm

ESP32 losing connection to iOs

Postby scn-eng » Mon Aug 12, 2024 6:22 pm

I've developed an ESP32 application that uses NimBLE to connect to a cellphone app. One of the functionalities of the app is to update the ESP running partition with the ESP OTA update mechanism, where the app sends bytes packets containing a new ESP image. This has worked really when the cellphone is running an adroid os. However, when connecting the ESP32 to an iphone, a GAP disconnect event pops up as soon as the iphone starts sending the byte packets, while all the other functions of the app work just fine. Both iOs and android applications use the same MTU length and send me packets of the same size.

Heres my ble initialization code:

Code: Select all

	err = nimble_port_init();
	if (err != ESP_OK) {
		ESP_LOGE("BLE", "nimble_port_init() failed with error: %d", err);
		return;
	}
	
		ble_hs_cfg.reset_cb = bleprph_on_reset;
	ble_hs_cfg.sync_cb = bleprph_on_sync;
	ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb;
	ble_hs_cfg.store_status_cb = ble_store_util_status_rr;

	ble_hs_cfg.sm_io_cap = BLE_SM_IO_CAP_NO_IO;
	ble_hs_cfg.sm_sc = 0;
	
	rc = bleuart_gatt_svr_init();
	
	rc = ble_svc_gap_device_name_set(nameble);
	assert(rc == 0);


	nimble_port_freertos_init(ble_host_task);
	
	delay(100);
After this initialization, I proceed to call the blecent_scan() and bleprph_advertise() functions.

Heres a log I've saved from a disconnect:

Code: Select all

I (21643) BOOT: OTA initialized
I (48003) BLE: RX 15 bytes
I (48303) BOOT: Incoming 562048 bytes from the app, in 2342 packets
I (48993) BLE: RX 15 bytes
I (49303) BLE_app: tx 1 bytes

I (50393) BLE_app: >> BLE_GAP_EVENT_SUBSCRIBE
I (50393) BLE_app: subscribe event; conn_handle=0 attr_handle=8 reason=2 prevn=1 curn=0 previ=0 curi=0
I (50403) BLE_app:
I (50403) BLE_app: >> BLE_GAP_EVENT_DISCONNECT
I (50413) BLE_app: disconnect; reason=520

The code was initially written in ESP IDF 4.4.4 and later migrated to 5.2.2
The mobile application was developed using the flutter_reactive_ble library.
The IOS devices used were: iPhone 11 and iPhone 8 plus
Various android devices were used, none having the same problem as the iPhones.

Has anyone experienced similar problems?

Who is online

Users browsing this forum: No registered users and 158 guests