How to retrive the information of BLEs which are connected to a BLE - ios

I'm new to Core Bluetooth. Using custom GATT my BLE device will exchange the information with other BLE devices, What I have to do is collect the information that my BLE device got and need to send it to cloud and after that need to clear that data.
I mostly saw Central Manager(Phone) and Peripheral(BLE device) examples but not sure how to get the connected BLE devices information. Do I need to use CBPeripheralManager? Please suggest the approach to handle it. Thanks.

Related

How to clone BLE device (configurations,charcterstics etc)and share it with other

I am working on an app that gets data from the BLE device, I am able to code to get the app to connect with the BLE device. But further characteristics read is an issue as I don't physically have the device
i came across an app named nRF Connect for Mobile . It has the functionality to clone BLE if paired. the video for a BLE clone is shown here but export and import is not avaible
Is there any way I can get the BLE cloned say some configuration file, which then imported in certain app create then same BLE device .i can use to read all the characteristics and other properties
Why don't you just connect to the device in for example nRF Connect, write down the services, characteristics and descriptors you see (usually isn't that many). Then just set up a local GATT server with the same content.
If I understood your question and your video correctly, you would like to copy the advertisement data of a BLE peripheral and use it to advertise on an iOS device yourself.
Maybe CBPeripheralManager can help you do that.
You can call startAdvertising([String:Any]?) and advertise a BLE peripheral.
But iOS limits on a system level which keys you can advertise.
From a short look in the documentation, it seems only the keys
CBAdvertisementDataLocalNameKey
CBAdvertisementDataServiceUUIDsKey
are supported.
But if you'd want to include more information about your peripheral, you could still create an own CBMutableService "deviceInfo" and send information within a characteristic after having established a connection.

Sending data from computer to iOS using Core Bluetooth

Is it possible to send data from any computer the supports BLE (Windows or Mac) to an iOS app's CBCentralManager?
The data I want to send is purely text based. I'm searching for it but I am not being able to find if it is possible or a tutorial of how to do it.
Any help would be greatly appreciated.
Yes, normally you can do that. What you have to do is:
From the peripheral device (transmitter), advertise an CBService
(iOS) with a CBCharacteristic that support write value.
From the receiver, you create a CBCentralManager to search for the service created by the transmitter, then discover the right CBCharacteristic. Once the CBCharacteristic discovered, you can try to write value to that characteristic.
The processus look simple, but you have to do step by step on the receiver's side:
first, look for device
if device found, try to connect
then once connected to that device, try to discover the service
then once the service discovered, try to discover the characteristic
then once the characteristic is discovered, try to send
then you will receive the result of sending (ok or failed)
Take a look at my project in github, it's not complete but it show you how to exchange data between 2 BLE devices. The application is for iOS, but I'm pretty sure that you have the same code in Mac OS. I don't know how it works on PC.

iOS Bluetooth Device in pheripheral mode send request to one central device

iOS Bluetooth Smart.
We have few central devices and one pheripheral devices. How to send from pheripheral device request to one of centrals?
iOS support something like "direct advertising"?
Bluetooth peripherals are supposed to be used as advertisers that the Centrals can find and connect to. Not the other way around. Basically you need to set up your peripheral with service/s that the Central is scanning for. After the central discovers the peripheral, it can then choose to connect, and then exchange additional data between the devices.
Check out the Bluetooth Developer Site for more information.

Transmitting data with CoreBluetooth

I'm developing an iOS app with an accompanying Bluetooth LE peripheral. The one step I don't seem to be able to solve is how to actually transmit the data from my app to the peripheral or vice versa.
What I've built so far is a test app that can connect to my sample Bluetooth peripheral, and read all of its services/characteristics/descriptors. It can toggle notifications for a given characteristic, and write to given characteristics. It is just this last step of "transmit n bytes to the peripheral, and receive m bytes from the peripheral" that I can't seem to figure out.
Looking at the External Accessory Framework (what I would use if Apple would actually give me MFi approval for this project), they give you input and output streams on a given session to communicate with the accessory, but no such object exists for CoreBluetooth.
Is this simply an oversight on Apple's part on the functionality of CoreBluetooth? Or do I simply need to develop my own Bluetooth service profile to handle the inflow/outflow of data to and from the peripheral?
LE is fundamentally designed to work with these GATT based profiles, which are suited for monitoring sensors, not for data streams. While LE does allow for additional L2CAP streams to be opened for custom protocols, Apple's CoreBluetooth doesn't provide access to do so.
You can build a custom profile with private services and characteristics and have it work kind of like SSP; that's the way I'm using my BLE module to get data from some sensors to my app. The module I bought (Microchip's RN-4020) already has a custom profile made specifically for this known as MLDP (Microchip Low-energy Data Profile).
The way I get the data in my iOS app is by subscribing to the private characteristic, thus being notified when the values are updated. So far it has been working great, and the data rate can go up to 20 kbps according to Microchip (I haven't tested its limits, since I don't need much speed). Here's a link to Microchip's product page: http://www.microchip.com/wwwproducts/Devices.aspx?product=RN4020
Good luck!
You can use the bluetooth.org 'Immediate Alert Service' uuid=1802 with characteristic uuid=2A06 with property=write_no_response to send one byte values to your peripheral device from your iPhone. The peripheral device must be programmed to act on the data that is sent. For example, you might use a button on an iPhone app to send a hex address that causes one or more port pins to turn on or off on the peripheral. While this is not using the Alert Service as it was intended, it does provide an easy way to test out data transfer to a peripheral device. The same process could be used to send sequential data bytes similar to a serial data stream. I have not yet tried sending more complex data streams. The write_no_response does not provide any feedback to the app as to whether the data was received by the peripheral.
The IOS TemperatureSensor.xproj is an example of code for reading temperature data from a peripheral. The OSX HealthThermometerClient.xproj has the code needed to decode the somewhat complex thermometer data structure. The IOS TI-BLE-Demo.xproj TIBLECBKeyfob.m has code for reading and writing characteristic values, such as, reading temperature or battery levels from a peripheral device.

How to use core bluetooth framework get data?

I am working on an iOS core Bluetooth application, i can connect the bluetooth device use iphone4S , but i dont know how to communication with the device. i want to read information form the device.
i also see this sources code https://github.com/sergiomtzlosa/CoreBluetooth-Demo/
and this article How to read information from core bluetooth device
but i dont understand how to transfer data.
can some one help me? thank you
To use CoreBluetooth, first your device must support Bluetooth Low Energy in Bluetooth 4.0. You can't connect to the device through iOS's UI for LE, you will have to develop your own UI for it because your application need to connect to only the devices with the services that you are interested in.
After that, you can subscribe to notification of the device when a characteristic value is updated, and then read the value using CoreBluetooth API. If the device has a characteristic that can be written to, then your application can write to the characteristic using CoreBluetooth API.
That's the general idea, hope that answers your question.
Edit: check out these samples:
Heart Rate Monitor
Temperature Sensor
A very similiar question has been asked and answered.
Read through the framework and find methods and callbacks with very descriptive names like:
- (void) centralManagerDidUpdateState:central
- (void) centralManager:central didDiscoverPeripheral
- (void) peripheral:peripheral didDiscoverServices:error

Resources