juliansteenbakker / flutter_ble_peripheral

A Flutter package for advertising BLE data in peripheral mode
BSD 3-Clause "New" or "Revised" License
75 stars 52 forks source link

[flutter_ble_peripheral] didStartAdvertising: Error "Advertising has already started" on iOS #205

Open Kat-Whitehouse opened 1 month ago

Kat-Whitehouse commented 1 month ago

I have picked up the development on an app which uses a phone to send BLE data to an IOT device. The app works as it should on Android, but as we all know, it works completely differently on iOS.

I can only seem to send one advertiseData packet and then the iPhone just continues to send it. I have a sniffer (using Tera Term) and so I can see what is being sent. If I then send another advertiseData packet, it is just ignored by the IOT device. I cannot find a way of stopping the iPhone from advertising so that I can send the new packet to the device. The .stop() doesn't seem to do anything and the iPhone just continuously advertises the original advertiseData packet.

Does anyone have any ideas? How do I use .stop() please? Incidentally, the Android code does not need to use .stop(). When I send new advertiseData, it just does it and the device responds as it should.

Kat-Whitehouse commented 1 month ago

Figured this out eventually.

You have to call the .stop before the .start().

huzaifa846 commented 1 month ago

facing same issue