Search code examples
iphoneobjective-ciosexternal-accessoryiphone-accessory

External Accessory reading problem


I need to receive data periodically through a BlueTooth External Accessory.

I implemented an event-driven model of EA's streams. However, the initial transmission from bluetooth is always delayed. For example, if each packet was 15 bytes long, the stream delegate would not fires until about 150 bytes.

Will polling help?

EDIT:

Also I found it hard to recover the session after the app switching back from background to foreground. Trying to open session again would fail. Any idea?


Solution

  • Read every bytes when NSStreamEventHasBytesAvailable arrives.

    Did you develop your own Bluetooth accessory? May be the MCU only flushes after sending every 150 bytes.

    Also you mentioned initial transmission. Do you know once the Bluetooth device is paired and connected to iPhone, it has to go through some identification process, handshaking some secret certificate. This may take few and even 10 seconds, depending on signal quality. This may be the cause of delay.