How to expose sensor data by defining readable characteristics in BGLib?

countkaushik

  • Newbie
  • *
    • Posts: 2
    • View Profile
I was able to run the slave example (BGLib_stub_slave.ino) on my TinyDuino. But it only shows how to handle a writable characteristics. Can any anybody help me with readable characteristics? Which BGLib callback should I define for a readable characteristics? For example, I have an accelerometer Tinyshield, and I want to make the x,y,z and temp data available over the Bluetooth LE by exposing a readable characteristics. Does anybody have any idea about how to do that? Any help or pointer to example code would be appreciated.


Hi
I am trying to do the same.
Any luck on your end?

I have been reviewing the BG Lib code and trying to see how to connect the TX from the processor to the RX of the BLE chip (Think that is right) using the accelerometer example as well.
Instead of sending it over serial send it to BLE.

If you have discovered anything please post. I will do same.



jetdillo

  • Newbie
  • *
    • Posts: 1
    • View Profile
You use the GATT_C_TX_DATA  handle to transmit data.
Here's a brief example of sending random bytes over the TinyDuino BLE shield.
This goes inside the
Code: [Select]
void loop() function of the BGLib_stub_slave() demo code.
I have a rev2 TinyDuino BLE shield FWIW.

You would read this on the master side from the Read/Notify characteristic.

Code: [Select]

         for(int i=0;i < 11;i++) {
             ble_rand_arr[i]= random(255);
             Serial.print("ble_rand_arr:");
             Serial.println(ble_rand_arr[i]);
         }
         
         //copy over to another array just to keep things clean
         uint8_t ble_tx_arr[11];
         memcpy(ble_tx_arr+0,ble_rand_arr,11);
         for (int i=0; i< 11;i++) {
              Serial.print("ble_tx_arr=");
              Serial.println(ble_tx_arr[i]);
         }

          uint8_t result = ble112.ble_cmd_attributes_write(GATT_HANDLE_C_TX_DATA,0, 11,ble_tx_arr);
         //delay a bit to make sure the other side isn't flooded.
         delay(1000);


Ariel

  • Jr. Member
  • **
    • Posts: 5
    • View Profile
Hey Thanks a lot. I was myself looking for a way to transmit data from the BLE to a my android.
the handler works fine.
uint8_t result = ble112.ble_cmd_attributes_write(GATT_HANDLE_C_TX_DATA,0, 11,ble_tx_arr);


tjdah10

  • Jr. Member
  • **
    • Posts: 6
    • View Profile
You do not need to do anything Gatt Server (TinyDuino) side to read the characteristic, it's handled internally by BGLib. If you want to update the data to be read however, you're better off using notifications. The RX characteristic on the BLE shield has notifications enabled by default, so you're good to go in that regard.

For a simple sketch, refer to this: https://github.com/tunjid/BLE

For a more complex sketch showing how to read to a characteristic and different firmware that can be used with BLE, refer to this: https://github.com/WuMRC/drive

That repository also has the source for an Android app along with it's APK should you want to write one.

Good luck.


artlover5781

  • Newbie
  • *
    • Posts: 2
    • View Profile
does anyone know how i would deal with his on the gatt client side of things like a phonegap application?


danielkyler

  • Newbie
  • *
    • Posts: 0
    • View Profile
You do not need to do anything Gatt Server (TinyDuino) side to read the characteristic, it's handled internally by BGLib. If you want to update the data to be read however, you're better off using notifications. The RX characteristic on the BLE shield has notifications enabled by default, so you're good to go in that regard.

For a simple sketch, refer to this: https://github.com/tunjid/BLE

For a more complex sketch showing how to read to a characteristic and different firmware that can be used with BLE, refer to this: https://github.com/WuMRC/drive iq test free

That repository also has the source for an Android app along with it's APK should you want to write one.

Good luck.

Nice, thank u so much


 

SMF spam blocked by CleanTalk