Re: Reconnecting with peripheral
Re: Reconnecting with peripheral
- Subject: Re: Reconnecting with peripheral
- From: Etan Kissling <email@hidden>
- Date: Mon, 10 Feb 2014 13:48:03 +0000
- Thread-topic: Reconnecting with peripheral
Viswanathreddy,
There is an official programming guide for CoreBluetooth by Apple:
https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/AboutCoreBluetooth/Introduction.html
What you need to do, is the following
1. Allocate a CBCentralManager with [-CBCentralManager initWithDelegate:queue:].
2. In your CBCentralManagerDelegate, wait for [-CBCentralManagerDelegate centralManagerDidUpdateState:] and confirm that [-CBCentralManager state] is CBCentralManagerStatePoweredOn.
3. Scan for your peripheral tag with [-CBCentralManager scanForPeripheralsWithServices:options:].
4. Wait for [-CBCentralManagerDelegate centralManager:didDiscoverPeripheral:advertisementData:RSSI:] and verify that it is your peripheral.
5. Retain the peripheral by copying it to a property of your object.
6. Stop scanning with [-CBCentralManager stopScan].
7. Set the CBPeripheral’s delegate property.
8. Connect to your peripheral tag: [-CBCentralManager connectPeripheral:options:].
9. As soon as your peripheral is in range and connected, you will receive [-CBCentralManagerDelegate centralManager:didConnectPeripheral:].
10. You can now access the peripheral via the various CBPeripheral methods.
11. Once your peripheral tag goes out of range, you will receive [-CBCentralManagerDelegate centralManager:didDisconnectPeripheral:error:].
The error code will indicate the reason of the disconnect and should be non-nil for out of range connection aborts.
12. Issue another [-CBCentralManager connectPeripheral:options:] request to reconnect to the peripheral. This connect request does not time out,
and will complete when the peripheral tag is back in range.
The required classes are documented here:
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CoreBluetooth_Framework/_index.html
Hoping that this may help you :-)
Etan
On 05.02.2014, at 04:07, Viswanathreddy <email@hidden> wrote:
> I need a requirement that keep a connection with peripheral tag from application,
> I need one specific requirement is maintains the connection with
> Peripheral tag with in the range and reconnecting to the peripheral if the peripheral went to out of range and come back into range. How it is possible with our core bluetooth framework.
> I was struck here .please help me.this is urgent requirement
>
> Thanks
> Viswanathreddy
>
> Sent from my iPhone
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Bluetooth-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden