Search code examples
swiftbluetoothbluetooth-lowenergycore-bluetooth

'Activate' Bluetooth LE Energy Data stream


For a student project, we're working on connecting a Bluetooth LE device (that both transmits and receives) to an iPhone or iPad in order to read data from it to display to the user in realtime. We have proof that this is doable by the company that made the device and we've actually managed to get a connection and get some data.. however it pings every 5-10 seconds and seems to be a random subset of numbers with minimal changes after changing something on the device which is making us none the wiser.

Now, of course, we went to the company that made the device and app first and we do have approval for us to use their hardware, but haven't been able to get a SDK / API from them to use with the application. So, our plan is to make our own way through it and find what we need.

This is where we're getting stuck. We have the following:

  • Connection based on Name or Bluetooth Device Address
  • Scan services (and cascading scan in case the services have services within them as specified in the CoreBluetooth documentation)
  • Read Characteristics from said services.
  • Decrypt value into 8bit UInt so we get some actual readable data.

This is an example of what we've got with the value still as it comes in.

Service: 0x1c0476440, is Primary = yes. UUID: 058d0001-ca72-4c8b-8084-25e049936b31
value <53636da1 7a616c74 73616c74 73616c74 73616c27>

Now, looking at this all, I presume the service here is some kind of 'staying alive' ping and it's giving some auxiliary info about the device's current state.

The question we have then boils down to this:

How can we further 'explore' the device? We don't seem to be getting any additional output aside from this however looking in the device manager from windows we get a couple of hits that look like this (Example):

 {058d0001-ca72-4c8b-8084-25e049936b31}[6]

Which have values in either a hexidecimal value, boolean or datetime without clear identifiers. Is there a way for us to send a message to the device to change the value in that uuid using Swift, or is this impossible?


Solution

  • While solved now, I'm not accepting this as the answer. My solution? Try things. Stupid 'Needle in a haybale' things.

    I changed the uuid from 058d0001-ca72-4c8b-8084-25e049936b31 to 058d0002-ca72-4c8b-8084-25e049936b31

    and voila. I could do more. I tried 3, and again, a new result and a working data stream...

    @Paulw11's comment is also a good way to solve this issue we found out.