-
-
Notifications
You must be signed in to change notification settings - Fork 284
CurieBLE: StandardFirmata BLE does not work. #377
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
Hi @sandeepmistry , I has shoot the root cause of this issue. The Firmata try to add profile before HW initialized. That makes the program crashed. So I move some process from BLEStream constructor to begin and that makes the program works. I can discover the profile with another 101 board. The fix commit ID is 10c482f. My github is https://github.com/sgbihu/corelibs-arduino101. I didn't test with https://gist.github.com/soundanalogous/927360b797574ed50e27. Because I don't have access to it. And I didn't know how to set the environment. So can you help test it? |
This issue is logged as Jira #791. |
This issue is logged as Jira 791. Solution from Liang under internal review, testing. Will update status here upon completion. |
…rduino#377 1. The BLEStream add profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change CommunitySketches/StandardFirmataBLE/BLEStream.h. Move the add profile at begin after HW complete initial process.
…rduino#377 1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change CommunitySketches/StandardFirmataBLE/BLEStream.h. Move the add profile at begin after HW complete initial process.
Hi @sgbihu, There are a few concerns about the items you proposed in #377 (comment):
|
…rduino#377 1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change CommunitySketches/StandardFirmataBLE/BLEStream.h. Move the add profile at begin after HW complete initial process.
Hi, @sandeepmistry Agree with you that this is not the solution. The issue actually exposes a problem with the robustness of the BLE library initialization process and we are going to address it (instead of making changes to the 3rd party code). The cause of the system crash can be traced back to the instantiation of a global object using a constructor that makes BLE API calls at the time when the BLE library has not been initialized. The instantiation of global object is (determined at compile time) done as part of the system power cylce/reset initialization. Object instantiation is performed by the Class Constructor. The BLE objects, however, are instantiated at run time (in order to reduce heap space and BSS consumption for sketches that do not use BLE), via the, begin(), API call in a sketch. Thus, if BLE API's are called in a constructor of a global object, these calls are made prior to proper BLE initialization. We are working a solution to overcome this issue. |
…rduino#377 1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change the BLE initial process not depend on HW. Buffer the attributes if HW not initialized. 3. Changed files libraries/CurieBLE/src/BLEDevice.h - expose constructor libraries/CurieBLE/src/BLEPeripheral.cpp - not call HW init function libraries/CurieBLE/src/internal/BLEDeviceManager.cpp - change init order libraries/CurieBLE/src/internal/BLEProfileManager.cpp - change constructor
Hi @SidLeung and @sandeepmistry , I implement a solution. Please help review again. Thanks! |
…rduino#377 1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change CommunitySketches/StandardFirmataBLE/BLEStream.h. Move the add profile at begin after HW complete initial process.
Currently testing this. Do we have to test using the node js app above/ |
@noelpaz if possible that would be great, if you can't get it setup for whatever reason I can test it out later. Once things work, we can ping firmata/arduino#335 to be merged. |
…#377 1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change the BLE initial process not depend on HW. Buffer the attributes if HW not initialized. 3. Changed files libraries/CurieBLE/src/BLEDevice.h - expose constructor libraries/CurieBLE/src/BLEPeripheral.cpp - not call HW init function libraries/CurieBLE/src/internal/BLEDeviceManager.cpp - change init order libraries/CurieBLE/src/internal/BLEProfileManager.cpp - change constructor
1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change the BLE initial process not depend on HW. Buffer the attributes if HW not initialized. 3. Changed files libraries/CurieBLE/src/BLEDevice.h - expose constructor libraries/CurieBLE/src/BLEPeripheral.cpp - not call HW init function libraries/CurieBLE/src/internal/BLEDeviceManager.cpp - change init order libraries/CurieBLE/src/internal/BLEProfileManager.cpp - change constructor
Code mods passed code review, system testing, and emerged to main trunk. Will be available in the next nightly build. |
…#377 1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change the BLE initial process not depend on HW. Buffer the attributes if HW not initialized. 3. Changed files libraries/CurieBLE/src/BLEDevice.h - expose constructor libraries/CurieBLE/src/BLEPeripheral.cpp - not call HW init function libraries/CurieBLE/src/internal/BLEDeviceManager.cpp - change init order libraries/CurieBLE/src/internal/BLEProfileManager.cpp - change constructor
…rduino#377 1. The BLEStream object adds profile when boot but the HW doesn't be initialized and makes APP crash. 2. Change CommunitySketches/StandardFirmataBLE/BLEStream.h. Move the add profile at begin after HW complete initial process.
There's still something up with this, if I test with the instructions in #377 (comment) it doesn't work connecting from my Mac using Node.js Debug wise with
|
Hi @sandeep, I don't have access to get the nodejs example, can you share it to me? Thanks! |
@sgbihu it's the Github gist link in the first comment: #377 (comment) |
@SidLeung Can you evaluate if this is multiple tickets, and open new issues as needed? |
I tested using the instructiosn from sandeep and using ble-firmata-test.js and it looks like this is working. Here is the log from the mode.js application. BLE-firmata.txt Steps:
|
I forgot to make the edits to utility/BLEStream.h so I did that and got the same result. Here is the log |
It looks like it crashes silently right here:
If successful you would see something like the following printed to the console shortly afterwards:
I'll take a look at it this weekend to see if I can determine what the issue may be. The node.js script can also be fussy at times. It doesn't work consistently. |
A reply is never received from the board via Firmata. |
Can you post some serial command and expected response here? In this way, I can use other device to simulate the process. |
Per Sandeep's observation, he noted above that,
Is the debug flag needed to be set in order to determine if there is any reply? |
The debug flag is not necessary. |
Thanks. We were under the impression that if you see only these lines BLEStream::received(F9) That it has failed. I have 2 logs one with the debug on set on BLEStream.h Sandeep said that the BLE is not advertising as the symptom. Now with this new script what is actually not working? Is it our library or the script which is suppose to be unstable at times or the firmata library.? Protocol wise what transaction should the 101 be sending out. We will run this through a protocol analyzer. Also when I stop the node JS application, the Arduino 101 is scannable and connectable again. So BLE did not crash as has been implied. |
@soundanalogous . I did not wire the components last night as per the instructions in the script but I will do so this morning and run it again. All I wanted to test was if your node js script can connect to the 101 and it did so and explored the peripheral which I thought was that was needed. Could it be the reason why? Also How should we be running the potentiometer and what is the spec for that potentiometer , taper and impedance will be helpful to reproduce these results. |
I'll try this out with the v1.0.7 release shortly and repeat back on the expected results. |
Here's what I get with v1.0.7
Which lines up with the following statements in the JS: console.log(
board.firmware.name + "-" +
board.firmware.version.major + "." +
board.firmware.version.minor
);
// ...
board.analogRead(0, function(val) {
if (val !== lastVal) {
console.log(val);
}
lastVal = val;
});
board.digitalRead(dBtnPin, function (val) {
console.log("pin " + dBtnPin + " value: " + val);
});
board.digitalRead(aBtnPin, function (val) {
console.log("pin " + aBtnPin + " value: " + val);
});
// ... |
Yep that is the expected output :) |
This works for me with the Github master version of the core (d818a3a) now. Closing. |
I'm testing the latest master release with PR firmata/arduino#335.
However, I think the board is crashing - I don't see the 101 advertising using BLE, and the next time I try to load a sketch I have to press the master reset button.
I would expect the sketch to work with @soundanalogous's Node.js test app: https://gist.github.com/soundanalogous/927360b797574ed50e27
The text was updated successfully, but these errors were encountered: