Open
Description
When I set my Arduino101 up as a peripheral and subscribed to notifications from it the Arduino hangs when the central devices moves out of range and a GATT timeout event occurs. It hangs when either the devices moves back in range or after ~25 seconds.
When not subscribed the Arduino times out when out of range and disconnect from the Arduino when it comes back in range as expected.
This is using version 2.0.0 of the BLE library. The following code can be used to replicate this.
#define SERVICE_UUID "00002902-93e0-48ca-5898-af76b9f93f85"
#define VALUE_UUID "00002902-93e1-48ca-5898-af76b9f93f85"
#define HEARTBEAT_PIN 0
BLEPeripheral mBLE_Peripheral;
BLEService mBLE_Service(SERVICE_UUID);
BLEIntCharacteristic mBLE_Value( VALUE_UUID, \
BLERead | BLENotify);
/*--------------------------------------------------------*/
/* Function: setup */
/*--------------------------------------------------------*/
void setup()
{
Serial.begin(9600);
pinMode(HEARTBEAT_PIN, OUTPUT);
mBLE_Peripheral.setLocalName( "TEST_BLE" );
mBLE_Peripheral.setAdvertisedServiceUuid( \
mBLE_Service.uuid() );
mBLE_Peripheral.addAttribute( mBLE_Service );
mBLE_Peripheral.addAttribute( mBLE_Value );
mBLE_Peripheral.setEventHandler(BLEConnected, \
bleConnectHandler );
mBLE_Peripheral.setEventHandler( BLEDisconnected, \
bleDisonnectHandler );
mBLE_Peripheral.begin();
}
/*--------------------------------------------------------*/
/* Function: loop */
/*--------------------------------------------------------*/
void loop()
{
if ( mBLE_Peripheral.connected() )
{
digitalWrite(HEARTBEAT_PIN, digitalRead(HEARTBEAT_PIN) \
? LOW : HIGH );
static int i = 0;
mBLE_Value.setValue( i++ );
delay(100);
}
}
/*--------------------------------------------------------*/
/* Function: bleConnectHandler */
/*--------------------------------------------------------*/
void bleConnectHandler( BLECentral& central )
{
Serial.println("Connected");
}
/*--------------------------------------------------------*/
/* Function: bleDisonnectHandler */
/*--------------------------------------------------------*/
void bleDisonnectHandler( BLECentral& central )
{
Serial.println("Disconnected");
}
/*************************** EOF **************************/
Metadata
Metadata
Assignees
Labels
No labels