-
Notifications
You must be signed in to change notification settings - Fork 217
begin() doesn't work after end() on Nano BLE 33, have to power cycle #65
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
Comments
Probing So for some reason the system is not responding to the reset opcode the second time round. Any help welcome. @facchinm? |
Continuing to probe. Looks like HCI is not available after end(), and isn't getting reset for some reason. |
For those who want to test this, use the following sketch: #include <ArduinoBLE.h>
BLEService TestService("DEAD");
BLECharacteristic TestData("BEEF", BLEIndicate | BLENotify, 2, true);
BLEDescriptor TestDescriptor("BEEF", "Test");
uint32_t genericTimer = 0;
bool wasConnected = false;
void setup(){
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
initBLE();
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop(){
BLEDevice central = BLE.central(); // begin listening for centrals to connect
if(central){
genericTimer = millis();
while(central.connected()){
if(millis() - genericTimer >= 5000){ // Wait 5 seconds
BLE.disconnect(); // Disconnect BLE - LED should go out
BLE.end();
digitalWrite(LED_BUILTIN, LOW); // Doesn't go out - have to do it manually
wasConnected = true;
}
}
}
if(wasConnected){
genericTimer = millis();
while(millis() - genericTimer <= 5000){} // Wait 5 seconds
wasConnected = false;
initBLE();
}
}
void initBLE(void){
if(BLE.begin()){
digitalWrite(LED_BUILTIN, HIGH);
}
BLE.setLocalName("TestName");
BLE.setDeviceName("Test Device Name");
TestService.addCharacteristic(TestData);
TestData.addDescriptor(TestDescriptor);
BLE.addService(TestService);
BLE.setAdvertisedService(TestService);
BLE.advertise();
} And insert This will show the LED re-lighting after But moving that Or to go one step further, put that Unfortunately that's as far as I can get. I don't know enough to explain why the HCI isn't available after calling |
I'm experiencing the same bug. |
I'm also experiencing this bug, also using the Nano 33 BLE Sense and with the latest commit. @rmlearney-digicatapult & @drewbus-drewbus, I assume you are also trying to turn the radio on and off at will. I was looking at the NINA B306 schematics, it shows a hardware reset pin (RESET_N) in C3/C4 from the NINA at pin 19 to P0.18. It's not clear to me whether this input is accessible to us currently from the U-blox NINA-B3 Series datasheet, see 1.5.1. For others wondering about the pin mapping between the nRF52840 and the Nano 33 BLE Sense, here's a useful thread. @per1234 @facchinm Could you provide assistance? Turning the radio off and on would be very useful. Let me know if I can help with testing! |
I am trying to write a reset function that turns BLE off and then back on again. I'm being blocked by this bug as well! Let me know if there's anything I can do to assist @rmlearney-digicatapult |
@sastorer-ms I'm definitely no expert when it comes to C++ but if you could possibly poke around and confirm my findings that could really help. Unfortunately I don't know how to raise the priority of this issue with the Arduino team but would love to understand if this is on their backlog. |
I have the same bug, what can be the solution? |
We are actively investigating all the reports and will post a response later today 🙂 |
The problem here is that the bleLoop thread is getting terminated on ArduinoBLE/src/utility/HCICordioTransport.cpp Lines 200 to 202 in 693268d
The CordioHCIHook terminate() , however, doesn't shut down the radio, so calling BLE.end() right now will not have the expected behaviour.
Moreover, starting a thread twice is forbidden in mbed (https://os.mbed.com/docs/mbed-os/v6.0/mbed-os-api-doxy/classrtos_1_1_thread.html#ad315c4f13f31fffde51040cbf00518cb) so the second I'm going to post a patch for the thread start/stop but the only way to have a real |
@facchinm thank you! Would it make sense to create a new functionality called
|
The scope of this library is to abstract the underlying hardware as much as possible, thus a proper Anyway, I added #92 to fix the end() -> begin() hang, pleas egive it a try so we can merge it. |
Thank you @facchinm ! I'll try tonight. |
Hi,
The
begin()
function does not behave as expected following anend()
and instead I have to power cycle. This is similar to #33I've created two minimal examples for people to try below:
Example 1:
BLE.disconnect()
10 seconds after connected to centralExpected behaviour - disconnect from central and allow reconnection after re-advertising
Actual behaviour - works as expected
Example 2:
end()
after 10 seconds of connection to centralExpected behaviour - system disconnects, then ends BLE service, and restarts it correctly
Actual behaviour - unable to restart BLE with
begin()
after callingend()
The text was updated successfully, but these errors were encountered: