Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

begin() doesn't work after end() on Nano BLE 33, have to power cycle #65

Closed
Labels
@rmlearney-digicatapult

Description

@rmlearney-digicatapult

Hi,

Thebegin() function does not behave as expected following anend() and instead I have to power cycle. This is similar to#33

I've created two minimal examples for people to try below:

Example 1:

  1. Initialise BLE
  2. CallBLE.disconnect() 10 seconds after connected to central
  3. Re-advertise 15 seconds later to allow reconnection

Expected behaviour - disconnect from central and allow reconnection after re-advertising
Actual behaviour - works as expected

#include<ArduinoBLE.h>BLEServiceTestService("DEAD");BLECharacteristicTestData("BEEF", BLEIndicate | BLENotify,2,true);BLEDescriptorTestDescriptor("BEEF","Test");uint32_t genericTimer =0;bool wasConnected =false;voidsetup(){initBLE();}voidloop(){    BLEDevice central = BLE.central();// begin listening for centrals to connectif(central){        genericTimer =millis();while(central.connected()){if(millis() - genericTimer >=10000){// Wait 10 seconds after connect                BLE.disconnect();// Disconnect BLE                wasConnected =true;            }        }    }if(wasConnected){        genericTimer =millis();while(millis() - genericTimer <=15000){}// Wait 15 seconds after disconnect        wasConnected =false;        BLE.advertise();    }}voidinitBLE(void){    BLE.begin();    BLE.setEventHandler(BLEConnected, blePeripheralConnectHandler);    BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);    BLE.setLocalName("TestName");    BLE.setDeviceName("Test Device Name");    TestService.addCharacteristic(TestData);    TestData.addDescriptor(TestDescriptor);    BLE.addService(TestService);    BLE.setAdvertisedService(TestService);    BLE.advertise();}

Example 2:

  1. Initialise BLE
  2. Disconnect andend() after 10 seconds of connection to central
  3. Wait 15 seconds and try to re-start BLE system again

Expected behaviour - system disconnects, then ends BLE service, and restarts it correctly
Actual behaviour - unable to restart BLE withbegin() after callingend()

#include<ArduinoBLE.h>BLEServiceTestService("DEAD");BLECharacteristicTestData("BEEF", BLEIndicate | BLENotify,2,true);BLEDescriptorTestDescriptor("BEEF","Test");uint32_t genericTimer =0;bool wasConnected =false;voidsetup(){initBLE();}voidloop(){    BLEDevice central = BLE.central();// begin listening for centrals to connectif(central){        genericTimer =millis();while(central.connected()){if(millis() - genericTimer >=10000){// Wait 10 seconds after connect                BLE.disconnect();// Disconnect BLE                BLE.end();// End BLE service                wasConnected =true;            }        }    }if(wasConnected){        genericTimer =millis();while(millis() - genericTimer <=15000){}// Wait 15 seconds after disconnect        wasConnected =false;initBLE();    }}voidinitBLE(void){    BLE.begin();    BLE.setEventHandler(BLEConnected, blePeripheralConnectHandler);    BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);    BLE.setLocalName("TestName");    BLE.setDeviceName("Test Device Name");    TestService.addCharacteristic(TestData);    TestData.addDescriptor(TestDescriptor);    BLE.addService(TestService);    BLE.setAdvertisedService(TestService);    BLE.advertise();}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp