Curie TinyTile: Can't update BLE characteristics <25ms?

Board Name: Intel Curie鈥檚 Tiny Tile

Trying to update two characteristic every 10ms.

The nrf Connect app which is used to receive data gets hanged after few receiving few data packets.

I have also asked the question in GitHub. Here鈥檚 the link,

Can anyone please find the mistake/bug in the below code :confused:

#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);

}

Also posted at:

If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.

pert:
Also posted at:

If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.

Sorry about that Pert, I didn't know.
I have updated now.
Will follow from now on.
Merci!
Tim