Go Down

Topic: BLE communication timeout. (Read 33 times) previous topic - next topic

mantissa00

Dec 15, 2014, 02:53 pm Last Edit: Dec 15, 2014, 03:35 pm by mantissa00
Hi! I'm using an arduino compatible Blend Micro board (I got it from the Arduino Store): http://redbearlab.com/blendmicro .

I have installed the required libraries and the example are working correctly.

Now, I'd like to read datas from an IMU controls. For debugging purpose I've deleted everything about IMU via I2C and used some dumb values. The problem persists:

after some times (can be few minutes but can be also 20-30 seconds) in the arduino IDE serial monitor I read this message:

Code: [Select]
data transmmit success!  Length: 15    Data Credit available: 1
Evt Disconnected/Advertising timed out
Advertising started


and the connection closes.

To read them I'm using a node.js sketch made for using the Blend Micro: https://github.com/shokai/blendmicro-node

I'm using the echo.js example:
https://github.com/shokai/blendmicro-node/blob/master/samples/echo/echo.js

In the Arduino I have this sketch:

Code: [Select]
#include <SPI.h>
#include <boards.h>
#include <RBL_nRF8001.h>

long timer=0;   //general purpuse timer
long timer_old;

// Euler angles
float roll;
float pitch;
float yaw;

void setup()
{
  Serial.begin(115200);

  ble_begin();

  timer=millis();
  delay(20);

}

void loop() //Main Loop
{
  if((millis()-timer)>=20)
  {
    timer_old = timer;
    timer=millis();

    // fill the angles with right value from accellerometers
    roll = 3.14;
    pitch = 0.23;
    yaw = 0.42;

    printdata();
  }

  ble_do_events();

}

#define ToRad(x) ((x)*0.01745329252)  // *pi/180
#define ToDeg(x) ((x)*57.2957795131)  // *180/pi

void printdata(void)
{    
  Serial.print("!");
  Serial.print("ANG:");
  Serial.print(ToDeg(roll));  Serial.print(",");
  Serial.print(ToDeg(pitch)); Serial.print(",");
  Serial.print(ToDeg(yaw));   Serial.println();    

  ble_write('R');
  sendFloat(ToDeg(roll));
  ble_write('#');

  ble_write('P');
  sendFloat(ToDeg(pitch));
  ble_write('#');

  ble_write('Y');
  sendFloat(ToDeg(yaw));
  ble_write('#');

}

void sendFloat(float f) {
  char buff[10];
  dtostrf(f, 3, 0, buff);
  int index = 0;
  while (buff[index]) {
    ble_write( buff[index++]);
  }
}



I don't have anything attached to the Arduino Blend Micro board, but the problem persists. This is what I see in serial monitor:

Code: [Select]
!ANG:179.91,13.18,24.06
!ANG:179.91,13.18,24.06
....
!ANG:179.91,13.18,24.06
Evt Pipe Status
data transmmit success!  Length: 20    Data Credit available: 1
ACI_EVT_DATA_CREDIT     Data Credit available: 2
data transmmit success!  Length: 20    Data Credit available: 1
ACI_EVT_DATA_CREDIT     Data Credit available: 2
data transmmit success!  Length: 20    Data Credit available: 1
ACI_EVT_DATA_CREDIT     Data Credit available: 2
data transmmit success!  Length: 4    Data Credit available: 1
ACI_EVT_DATA_CREDIT     Data Credit available: 2
!ANG:179.91,13.18,24.06
data transmmit success!  Length: 15    Data Credit available: 1
ACI_EVT_DATA_CREDIT     Data Credit available: 2
!ANG:179.91,13.18,24.06
...
data transmmit success!  Length: 15    Data Credit available: 1
ACI_EVT_DATA_CREDIT     Data Credit available: 2
!ANG:179.91,13.18,24.06
data transmmit success!  Length: 15    Data Credit available: 1
ACI_EVT_DATA_CREDIT     Data Credit available: 2
!ANG:179.91,13.18,24.06
data transmmit success!  Length: 15    Data Credit available: 1
Evt Disconnected/Advertising timed out
Advertising started
!ANG:179.91,13.18,24.06
...
!ANG:179.91,13.18,24.06


I've never used BLE before and I think it is something I'm missing. What can it be?

Don't know if it matter but I'm on Mac OS/X 10.8.5 on a MacBook Pro.

EDIT: I have tried also with BLE Controller app from my Android device and.. same problem.

EDIT 2: and I have tried also with the Hello World example.. reducing the delay on the loop from 1000 to 100.. same problem after 6 minutes of communication:

Go Up