1
TinyDuino Processors & TinyShields / Re: How to expose sensor data by defining readable characteristics in BGLib?
« 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
I have a rev2 TinyDuino BLE shield FWIW.
You would read this on the master side from the Read/Notify characteristic.
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);