Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fsherratt opened this issue Sep 11, 2017 · 0 comments
Open

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

fsherratt opened this issue Sep 11, 2017 · 0 comments

Comments

@fsherratt
Copy link

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 **************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant