How to use basic bluetooth modules to receive data?

I am working on a basic iOS Bluetooth application, I can connect a Bluetooth device to iphone4S, but I do not know how to communicate with the device. I want to read information from the device.

I also see this source code https://github.com/sergiomtzlosa/CoreBluetooth-Demo/

and this article How to read information from the main Bluetooth device

but I do not understand how to transfer data.

Can someone help me? thanks

+6
source share
2 answers

To use CoreBluetooth, your device must first support Bluetooth Low Energy in Bluetooth 4.0. You cannot connect to the device through the iOS UI for LE, you will have to develop your own interface for it, because your application should only connect to devices that interest you.

After that, you can sign up for a notification about the device when updating the attribute value, and then read the value using the CoreBluetooth API. If the device has a characteristic that can be recorded, then your application can write the characteristic using the CoreBluetooth API.

This is a general idea, I hope that answers your question.

Edit: check these samples:

+9
source

A very similar question was asked and answered .

Read the framework and find methods and callbacks with very descriptive names, for example:

- (void) centralManagerDidUpdateState:central - (void) centralManager:central didDiscoverPeripheral - (void) peripheral:peripheral didDiscoverServices:error 
0
source

Source: https://habr.com/ru/post/921317/


All Articles