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

Enable inclusion of softdevice #139

Merged
merged 1 commit into from Apr 4, 2022
Merged

Enable inclusion of softdevice #139

merged 1 commit into from Apr 4, 2022

Conversation

maxgerhardt
Copy link
Contributor

@maxgerhardt maxgerhardt commented Jan 28, 2022

Per https://community.platformio.org/t/bbc-microbit-v2-cannot-compile-bleperipheral-library/25688.

Without this flag, the builder script won't include the softdevice needed for bluetooth.

https://github.com/platformio/builder-framework-arduino-nrf5/blob/08ccc03196db3c58fbd52ddd55b20ea406c927ae/nrf5.py#L129-L134

And hence, simple sketches needing bluetooth fail to compile, as e.g.

[env:bbcmicrobit_v2]
platform = nordicnrf52
board = bbcmicrobit_v2
framework = arduino
lib_deps =
   sandeepmistry/BLEPeripheral@^0.4.0

with src\main.cpp

#include <Arduino.h>
#include <BLEPeripheral.h>

BLEPeripheral blePeripheral = BLEPeripheral();

void setup(){}
void loop(){}

with errors like

Compiling .pio\build\bbcmicrobit_v2\src\main.cpp.o
In file included from .pio\libdeps\bbcmicrobit_v2\BLEPeripheral\src/BLEPeripheral.h:24:0,
                 from src\main.cpp:2:
.pio\libdeps\bbcmicrobit_v2\BLEPeripheral\src/nRF51822.h:11:12: fatal error: ble_gatts.h: No such file or directory

I think the soft-device should be enabled by default, especially since the user fix, adding build_flags = -DNRF52_S132 to the platformio.ini, is not documented on Nordic nRF52.

Although this flag does exist in example project like https://github.com/platformio/platform-nordicnrf52/blob/master/examples/arduino-ble-led/platformio.ini, it's rather well-hidden.

@ivankravets ivankravets merged commit f004ebe into platformio:develop Apr 4, 2022
@ivankravets
Copy link
Member

Thanks for the PR!

@carlosperate
Copy link

Do the BLE examples work with the S132 SoftDevice?
As the micro:bit V2 uses an nRF52833 I believe SoftDevice S132 is not compatible, it would need to use either S113, S122, or S140: https://www.nordicsemi.com/Products/nRF52833/Downloads?lang=en#infotabs

image

@maxgerhardt
Copy link
Contributor Author

Hm I got the S132 from

[env]
lib_deps = sandeepmistry/BLEPeripheral @ ^0.4.0
lib_compat_mode = soft
build_flags = -DNRF52_S132

with which it builds.. I guess that won't run then during runtime? I haven't gotten feedback from https://community.platformio.org/t/bbc-microbit-v2-cannot-compile-bleperipheral-library/25688/7?u=maxgerhardt regarding it working :/

nRF52833 is indeed the chip on the BBC Micro:bit 2 per board definitoin.

@carlosperate
Copy link

Yeah, I would guess this would probably crash when the code tries to call any of the SoftDevice functionality. Maybe without using any BLE code an Arduino sketch could run without errors, but this might likely trip people trying to use Bluetooth and not knowing why their programme stops working.

@maxgerhardt
Copy link
Contributor Author

Well but then the next problem is that the nrf5 SDK only seems to have SoftDevice choices that are not compatible with this chip, which is extremely weird. (https://github.com/platformio/builder-framework-arduino-nrf5/blob/08ccc03196db3c58fbd52ddd55b20ea406c927ae/nrf5.py#L129-L134).

@maxgerhardt
Copy link
Contributor Author

The choices for the MicroBitV2 softdevices is literally empty in that core.

https://github.com/sandeepmistry/arduino-nRF5/blob/master/boards.txt#L84-L87

Did they support a bluetooth board there without bluetooth functionality?

@maxgerhardt
Copy link
Contributor Author

We now depend on sandeepmistry/arduino-nRF5#483.

@maxgerhardt
Copy link
Contributor Author

@ivankravets please revert this PR, per sandeepmistry/arduino-nRF5#483 (comment) the core does not support bluetooth functionality and using the S132 softdevice seems very wrong per comments above. Issue must be fixed in the Arduino core.

@ivankravets
Copy link
Member

Thanks! Done!

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

Successfully merging this pull request may close these issues.

None yet

3 participants