-1

How to store the logs of a connected device in BLE android app in android studio ? Does it use sqlite or something else ? steps will be really helpful , thanks .

1 Answers1

0
  • If you'd like to store the raw BLE log on Android:

    Take a look at this answer.

  • If you wish to just read/write/receive notifications from a BLE peripheral device:

    On your app, once you have found the device you wish to connect to, you will run something similar to gattInstance = device.connectGatt(context, false, gattCallback), where gattCallback is an instance of class BluetoothGattCallback.

    This instance is where you get a handle of all the data from BLE. You may use onCharacteristicRead(...) and onCharacteristicChanged(...) to process the data received form the device.

    All of this information is available on the Android documentation, here.

Community
  • 1
  • 1
AmiguelS
  • 805
  • 2
  • 10
  • 28
  • Thanks a lot , but i wanted to store the BLE device's data like the readings on it , not just a normal bluetooth connection . – Mahima Makhija Feb 01 '17 at 10:52
  • I do not understand your question. The method I present above works for Bluetooth Low Energy as well. So you want to log the received packet on the application? What OS are you developing for? – AmiguelS Feb 01 '17 at 12:03
  • I am developing on android studio and I wanted to log some data from a ble device into a database . By log I meant the general information of the device or readings and not packets , dont want to decipher the packet data . – Mahima Makhija Feb 02 '17 at 11:31
  • If I understood correctly, you wish to collect data from a BLE device that is connected to the Android device. And once you receive such data you want to add it to a database. Is this it? – AmiguelS Feb 02 '17 at 15:06
  • @MahimaMakhija I have edited my original answer. Please check that. – AmiguelS Feb 06 '17 at 15:15
  • Thanks a lot :) @AmiguelS – Mahima Makhija Feb 07 '17 at 05:53
  • I read the documentation you stated above , that helps but one more thing once i read the characteristic/data how do i put the same into the database , does BLE app use the default sqlite database ? or do i need to do add some other code ? – Mahima Makhija Feb 07 '17 at 06:03
  • @MahimaMakhija BLE does not use any database at all. In the methods I stated, you receive an array of bytes containing the characteristics value. You can do with it what ever you please. – AmiguelS Feb 07 '17 at 09:16