arduino / arduino/ArduinoCore-arc32

CurieBLE hang when a notify subscribed device moves out of range.

Open
#572 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
330
Forks
281
PR merge metrics
No merged PRs in 30d

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.

```#include

#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 **************************/
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Use the supplied Arduino101 sketch with CurieBLE 2.0.0 as the reproduction entry point. Run it with a subscribed central device, move the device out of range, and observe the GATT timeout and later hang; compare this with the unsubscribed behavior. Done means the peripheral times out and disconnects without hanging when the device leaves or returns to range.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.