You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Intel Curie's Tiny-Tile board crashes when three or more characteristics are updated every 30ms.
#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;
// Tx IMU data Characteristic
// remote clients will be able to
// get notifications if this characteristic changes
// standard 128-bit characteristic UUID
BLEService bleImuService("A7580001-153E-D4F6-F26D-43D8D98EEB13");
BLECharacteristic bleImuChar("F7580003-153E-D4F6-F26D-43D8D98EEB13",
BLERead | BLENotify, sizeof(imuBuf));
BLECharacteristic bleImuChar1("B7580003-153E-D4F6-F26D-43D8D98EEB13",
BLERead | BLENotify, sizeof(imuBuf));
BLECharacteristic bleImuChar2("C7580003-153E-D4F6-F26D-43D8D98EEB13",
BLERead | BLENotify, sizeof(imuBuf));
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);
BLE.advertise();
}
void loop()
{
// listen for BLE peripherals to connect:
// Since we are a peripheral we need a central object to connect to
BLEDevice central = BLE.central();
BLE.poll();
// 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()&bleImuChar1.canNotify()&bleImuChar2.canNotify())
{
// Take IMU data every 25 msec
if ((millis() - sentTime) >= 33)
{
for(int i=0; i<=2; i++)
{
//Reads acc data
recordImuData(i);
delay(10);
}
delay(2);
// Sets Tx buffer to the read acc data
bleImuChar.setValue((unsigned char *)&(imuBuf[0]), sizeof(imuBuf[0]));
bleImuChar1.setValue((unsigned char *)&(imuBuf[1]), sizeof(imuBuf[1]));
bleImuChar2.setValue((unsigned char *)&(imuBuf[2]), sizeof(imuBuf[2]));
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 if( time> update time) loop
} // end of While( The Char.CanNotify())loop
} //end of While(central.connnected()) loop
} // end of if(central) loop
}
// This function records the IMU data that we send to the central
void recordImuData(int index)
{
/* Read IMU data.
*/
int ax, ay, az;
int gx, gy, gz;
imuBuf[index].index = seqNum++;
CurieIMU.readAccelerometer(ax, ay, az);
//ax=10;
//Serial.println(ax);
// Encode 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);
}
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Intel Curie's Tiny-Tile board crashes when three or more characteristics are updated every 30ms.
The text was updated successfully, but these errors were encountered: