-
-
Notifications
You must be signed in to change notification settings - Fork 283
Closed
Description
I am using Intel Curie's Tiny Tile.
I have been trying to send Acceleration data at 10ms. I could send at 25 ms.
When the characteristic is updated at less than 25ms it get hanged in my nrf connect app.
#include <CurieBLE.h>
#include <CurieIMU.h>
#define MAX_IMU_RECORD 1
typedef struct {
int index;
unsigned int slot[3];
} imuFrameType;
// Buffer to hold IMU data
imuFrameType imuBuf[MAX_IMU_RECORD];
unsigned seqNum = 0;
BLEService bleImuService("A7580001-153E-D4F6-F26D-43D8D98EEB13"); // Tx IMU data Characteristic
BLECharacteristic bleImuChar("F7580003-153E-D4F6-F26D-43D8D98EEB13", // standard 128-bit characteristic UUID
BLERead | BLENotify, sizeof(imuBuf)); // remote clients will be able to
// get notifications if this characteristic changes
void setup()
{
Serial.begin(9600); // initialize serial communication
bool txpower_set = BLE.setTxPower(4);
BLE.begin();
CurieIMU.begin();
BLE.setLocalName("Imu");
BLE.setAdvertisedServiceUuid(bleImuService.uuid()); // add the service UUID
//Accelerometer sampling rate = 200Hz
CurieIMU.setAccelerometerRate(200);
//Minimum, Maximum connection interval 7.5ms- 10ms (0x06=7.5/1.25, 0x08= 10/1.25)
//0x028=50/1.25
BLE.setConnectionInterval(0x06,0x28);
BLE.addService(bleImuService); // Add the Imu service
bleImuService.addCharacteristic(bleImuChar); // add the Imu characteristic
bleImuService.addCharacteristic(bleImuChar1);
bleImuService.addCharacteristic(bleImuChar2);
bleImuService.addCharacteristic(bleImuChar3);
BLE.advertise();
}
void loop()
{
BLEDevice central = BLE.central();
// if a central is connected to peripheral:
if (central)
{
long currentMillis, sentTime;
// Send IMU data as long as the central is still connected
currentMillis = sentTime = millis();
while (central.connected())
{
while(bleImuChar.canNotify())
{
// update IMU data every 10ms
if ((millis() - sentTime) >= 10)
{
for(int i=0; i<=1; i++)
{
//Reads acc data
recordImuData(i);
delay(10);
}
bleImuChar.setValue((unsigned char *)&(imuBuf[0]), sizeof(imuBuf[0])); // Sets Tx buffer to
//the read acc data
sentTime = millis(); //note what time data was sent
for(int j=0;j<=1;j++)
{
for(int k=0; k<=2; k++)
{
Serial.println(imuBuf[j].slot[k]);
imuBuf[j].slot[k]=0;
}
}
}
}
}
} // end of while loop
}
// This function records the IMU data that we send to the central
void recordImuData(int index)
{
// Read IMU data.
int ax, ay, az;
imuBuf[index].index = seqNum++;
CurieIMU.readAccelerometer(ax, ay, az);
// the data into the buffer
imuBuf[index].slot[0] = (unsigned int)(ax);
imuBuf[index].slot[1] = (unsigned int)(ay);
imuBuf[index].slot[2] = (unsigned int)(az);
}`
```
Metadata
Metadata
Assignees
Labels
No labels