Search code examples
swiftbluetoothbluetooth-lowenergycore-bluetootheddystone

Connecting and sending data to Eddystone beacon from Core Bluetooth central?


I am currently working with a sensor that uses an Eddystone beacon to send 31 byte data packets to a Core Bluetooth iPhone app acting as a central that breaks apart and processes the received packet. The central is set up as scannable and non-connectable. I would like to send a turn sensor on/off signal from the central to the beacon, but I am not sure how to proceed given that Core Bluetooth uses different protocols than Eddystone. Potential solutions I have considered are:

  1. Create button in app that toggle connectable setting to connect with beacon. Write condition in sensor beacon code to turn off power once connection established. Potentially implement the converse by keeping the sensor in a deep sleep mode that is exited once a connection is re-established.
  2. Essentially make a request from the central to write to the Eddystone equivalent of a characteristic on the peripheral sensor side.

The problem is, I am not sure how to match up Core Bluetooth and Eddystone in such a way that I create a properly formatted 31 byte packet from the iPhone central that can be sent to, picked up, and then read by the peripheral to toggle it's power on/off state. How can I approach this problem, if it is at all possible? If it is not possible, what are some workarounds for Core Bluetooth scanner to Eddystone beacon peripheral communication?


Solution

  • According to Eddystone documentation, Eddystone is a protocol specification that defines a Bluetooth low energy (BLE) message format for proximity beacon messages (data from your sensor) and farther specifies a Configuration GATT Service that allow to make some configurations.

    In BLE terms, the Eddystone sensor is a peripheral that should expose the Eddystone Configuration GATT Service and advertise data according to the Eddystone format.

    In order to use the Eddystone Configuration GATT Service you have to establish a BLE connection from central (your IPhone) and the peripheral (your sensor) and to write the parameters in the characteristics.

    According to documentation of Eddystone Configuration GATT Service, to stop the advertisement write an empty array, or a single 0x00 in the charatecistic with UUID a3c8750a-8ed3-4bdf-8a39-a01bebede295.

    This is possible if your sensor exposes this service.