Incorrect BLE Peripheral Name with iOS

后端 未结 4 512
生来不讨喜
生来不讨喜 2021-01-31 19:19

I am writing an iOS app to communicate with a BLE device. The device can change names between connections (not during the BLE connection), but iOS refuses to change the device n

4条回答
  •  深忆病人
    2021-01-31 20:09

    Your guessing is correct.
    It is because of the core-blutetooth cache.

    Generally changing name / services / characteristics on BLE devices are "not supported". All these parameters are getting cached.

    There are two ways of solving this:

    • restart bluetooth adapter, so bluetooth cache gets cleared (I'm afraid there is no way to do this programatically, but i might be wrong)
    • your device BLE implements the GATT Service Changed characteristic: read about this here: core_v4.1.zip
      Vol 3, Part G, 2.5.2, and Vol 3, Part G, 7.1.

    Alternatively check the advertisement data of your BLE device. It might have a name property which should get refreshed every time the BLE device is advertising data (advertising data doesn't get cachced).

提交回复
热议问题