简体   繁体   中英

iOS BLE Bluetooth - send/receive HEX data

I am creating an iOS application that should connect to a custom BLE device. I need to iOS app to send 2 HEX commands, one to enable a part of the device and another to request for Data.

Is there any way in iOS to send/receive custom HEX data, other than working with services & characteristics?

No that is not possible, but the reason for this is not iOS but that the 'services' and 'characteristics' are just part of how the BLE protocol is defined.

Official spec: https://developer.bluetooth.org/TechnologyOverview/Pages/BLE.aspx

Generic Attribute Profile

The latest Bluetooth specification uses a service-based architecture based on the attribute protocol (ATT). All communication in low energy takes place over the Generic Attribute Profile (GATT). An application or another profile uses the GATT profile so a client and server can interact in a structured way.

The server contains a number of attributes, and the GATT Profile defines how to use the Attribute Protocol to discover, read, write and obtain indications. These features support a service-based architecture. The services are used as defined in the profile specifications. GATT enables you to expose service and characteristics defined in the profile specification.

The other answer is accidentally right, but for the wrong reasons.

Of course it is possible in BLE to send any kind of data, not just GATT. It's just that iOS forces you to work with GATT . There are no iOS APIs for anything else. So, yes, it is iOS that prevents you from doing it.

If you wouldn't be forced to work with GATT, there would be some other options:

  • L2CAP Credit-Based Channels - you create a channel that allows you to send full 23 octets of data per packet (that's in BLE 4.0 and 4.1; 4.2 allows more than that), in whatever format you choose to.
  • With access to the HCI, you can send a custom ACL Data Packet to avoid the L2CAP header. But you need to also modify the other side to make sure it parses it correctly.

Yes you can send data over ble device. I've implemented already. By implementing peripheral object's writevalue method to send data on given characteristics of your ble devices. And also for getting data back from the BLE devices you could use peripheral object's readValue method. Data will be started in update delegate method of bluetooth framework

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM