I currently working on android app, i wan to add BLE application in to my app, that is , i wanna send data into nrf51822/8001.
Please provide me a simple example.
Thank you.
I currently working on android app, i wan to add BLE application in to my app, that is , i wanna send data into nrf51822/8001.
Please provide me a simple example.
Thank you.
You can find the official tutorial here : http://developer.android.com/guide/topics/connectivity/bluetooth-le.html it will explain everything you need to know (scan, connexion and read/write..)
First you will need a BluetoothAdapter : final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter();
To get devices arround you you have to perform a scan(don t forget to stop it when you find the device because it takes lot of resources) mBluetoothAdapter.startLeScan(mLeScanCallback);
To do the connexion use connectGatt(context, boolean connection auto,BluetoothGattCallback mGattCallback) mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
In the tutotial they use a Services to get update when there is a new device, or a new connection or when read/write.
You can ddl the projet here : https://android.googlesource.com/platform/development/+/cefd49aae65dc85161d08419494071d74ffb982f/samples/BluetoothLeGatt
for read and write, go check about services, characteristics and UUID