- My goal is: to connect to my ESP32 device with my iPhone running iOS 12.4.3
- My actions are: I’ve cloned the example-no-libs-c repo and tweaked main.c to be:
#include <stdio.h>
#include "mgos.h"
enum mgos_app_init_result mgos_app_init(void) {
return MGOS_APP_INIT_SUCCESS;
}
and mos.yml to be:
author: mongoose-os
# It is here mainly for use in tests to make sure this is possible.
description: Most minimal app - no libs, no networking, no RPC, nothing
version: 1.0
manifest_version: 2017-05-18
libs_version: ${mos_version}
modules_version: ${mos_version}
mongoose_os_version: ${mos_version}
sources:
- src
tags:
- c
libs:
- origin: https://github.com/mongoose-os-libs/boards
- origin: https://github.com/mongoose-os-libs/core
- origin: https://github.com/mongoose-os-libs/bt-common
platform: esp32
config_schema:
- ["bt.keep_enabled", true]
- ["bt.dev_name", "My Device"]
- ["bt.max_paired_devices", -1]
- ["bt.gatts.min_sec_level", 0]
- ["bt.gatts.require_pairing", true]
- The result I see is:
I’m using the BLEScanner app and a custom mobile app that I’ve been developing on both iOS and Android. Both apps act the same: fail on iOS and succeed on Android. The result I get on Android is:
[Dec 20 10:51:20.836] esp32_bt_gatts.c:856 CONNECT cid 0 addr 74:1e:1f:2f:a1:f5
[Dec 20 10:51:20.841] esp32_bt_gap.c:100 BT device name My Device, addr 74:ae:0c:6a:c7:ab,2
[Dec 20 10:51:20.850] esp32_bt_gatts.c:435 74:1e:1f:2f:a1:f5: Begin pairing
[Dec 20 10:51:20.856] esp32_bt_gap.c:280 BLE advertising started
[Dec 20 10:51:23.024] esp32_bt_gap.c:289 AUTH_CMPL peer 74:1e:1f:2f:a1:f5 at 1 dt 2 success 1 (fr 0) kp 0 kt 0
[Dec 20 10:51:23.030] mgos_mongoose.c:66 New heap free LWM: 128828
[Dec 20 10:51:23.036] esp32_bt_gatts.c:727 74:1e:1f:2f:a1:f5: auth completed, starting services
However, with iOS, I get:
[Dec 20 10:48:50.898] esp32_bt_gatts.c:856 CONNECT cid 0 addr 6b:26:4f:f3:e7:9e
[Dec 20 10:48:50.903] esp32_bt_gap.c:100 BT device name My Device, addr 74:ae:0c:6a:c7:ab,2
[Dec 20 10:48:50.910] mgos_mongoose.c:66 New heap free LWM: 130960
[Dec 20 10:48:50.915] esp32_bt_gatts.c:435 6b:26:4f:f3:e7:9e: Begin pairing
[Dec 20 10:48:50.934] esp32_bt_gap.c:280 BLE advertising started
[Dec 20 10:48:51.922] mgos_mongoose.c:66 New heap free LWM: 129264
[Dec 20 10:49:22.789] esp32_bt_gap.c:289 AUTH_CMPL peer 6b:26:4f:f3:e7:9e at 1 dt 2 success 0 (fr 99) kp 0 kt 0
[Dec 20 10:49:22.800] mgos_mongoose.c:66 New heap free LWM: 128868
[Dec 20 10:49:22.800] esp32_bt_gatts.c:730 6b:26:4f:f3:e7:9e: auth failed, closing connection
[Dec 20 10:49:22.811] W (127631) BT_BTM: btm_sec_clr_temp_auth_service() - no dev CB
[Dec 20 10:49:22.817]
[Dec 20 10:49:22.817] W (127641) BT_APPL: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0016
[Dec 20 10:49:22.823] esp32_bt_gatts.c:866 DISCONNECT cid 0 addr 6b:26:4f:f3:e7:9e
[Dec 20 10:49:22.879] E (127701) BT_BTM: Device not found
[Dec 20 10:49:22.879]
[Dec 20 10:49:22.879] E (127701) BT_APPL: bta_gattc_mark_bg_conn unable to find the bg connection mask for: 6b:26:4f:f3:e7:9e
If I set require_pairing: false
, the problem disappears. However, I’m using the pairing config items to only allow pairing during certain device states.
- My expectation & question is: I expect to be able to interact with my ESP32 device over Bluetooth, but there seems to be a problem with pairing iOS 12.4.3 devices. I suspect there’s an issue on the ESP32 side, but I’m not sure how to debug this, since I’m not deeply familiar with BLE.