TinyCircuits Forum

TinyCircuits Products => TinyDuino Processors & TinyShields => Topic started by: countkaushik on August 12, 2014, 12:13:44 AM

Title: How to expose sensor data by defining readable characteristics in BGLib?
Post by: countkaushik on August 12, 2014, 12:13:44 AM
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.
Title: Re: How to expose sensor data by defining readable characteristics in BGLib?
Post by: michael.a.sorensen@gmail. on September 02, 2014, 10:18:14 PM
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.

Title: Re: How to expose sensor data by defining readable characteristics in BGLib?
Post by: jetdillo on December 21, 2014, 05:13:14 PM
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);
Title: Re: How to expose sensor data by defining readable characteristics in BGLib?
Post by: Ariel on January 30, 2015, 07:36:01 PM
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);
Title: Re: How to expose sensor data by defining readable characteristics in BGLib?
Post by: tjdah10 on February 10, 2015, 07:44:11 PM
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.
Title: Re: How to expose sensor data by defining readable characteristics in BGLib?
Post by: artlover5781 on February 24, 2015, 12:56:07 AM
does anyone know how i would deal with his on the gatt client side of things like a phonegap application?
Title: Re: How to expose sensor data by defining readable characteristics in BGLib?
Post by: danielkyler on January 09, 2024, 09:22:30 PM
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 (https://iqtestfree.io/)

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