-
Notifications
You must be signed in to change notification settings - Fork 2k
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
pkg/nimble: Fix compilation with USEMODULE += nimble_svc_bas
#21200
base: master
Are you sure you want to change the base?
Conversation
'USEMODULE += nimble_svc_bas
'USEMODULE += nimble_svc_bas
USEMODULE += nimble_svc_bas
Hi, thanks for the PR. I sadly have little prior knowledge about nimBLE, but I will review and help you get this upstream anyway. At first I thought that this might just be a new feature, but given that we already have
in the I can confirm the issue. In
However, with this PR I get
Something along the lines of diff --git a/pkg/nimble/patches/0001-port-npl-riot-add-svc_bas-config.patch b/pkg/nimble/patches/0001-port-npl-riot-add-svc_bas-config.patch
new file mode 100644
index 0000000000..89f52f6cd1
--- /dev/null
+++ b/pkg/nimble/patches/0001-port-npl-riot-add-svc_bas-config.patch
@@ -0,0 +1,36 @@
+From 3cd2f7dc9f2c17ffb83499ab569a291988cbbc08 Mon Sep 17 00:00:00 2001
+From: Marian Buschsieweke <[email protected]>
+Date: Sat, 8 Feb 2025 13:54:20 +0100
+Subject: [PATCH] port/npl/riot: add svc_bas config
+
+---
+ porting/npl/riot/include/syscfg/syscfg.h | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/porting/npl/riot/include/syscfg/syscfg.h b/porting/npl/riot/include/syscfg/syscfg.h
+index 84bdea5..a0b49c8 100644
+--- a/porting/npl/riot/include/syscfg/syscfg.h
++++ b/porting/npl/riot/include/syscfg/syscfg.h
+@@ -670,6 +670,19 @@
+ #define MYNEWT_VAL_BASELIBC_PRESENT (1)
+ #endif
+
++/*** @apache-mynewt-nimble/nimble/host/services/bas */
++#ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE
++#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE (1)
++#endif
++
++#ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM
++#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM (0)
++#endif
++
++#ifndef MYNEWT_VAL_BLE_SVC_BAS_SYSINIT_STAGE
++#define MYNEWT_VAL_BLE_SVC_BAS_SYSINIT_STAGE (303)
++#endif
++
+ /*** @apache-mynewt-core/sys/console/stub */
+ #ifndef MYNEWT_VAL_CONSOLE_UART_BAUD
+ #define MYNEWT_VAL_CONSOLE_UART_BAUD (115200)
+--
+2.43.0
+ fixes the build issue for me. Would that make sense in your opinion? If you agree with that change, please directly squash that into a single commit (or use Could you please change the title of the commit to something like:
(E.g. |
`pkg/nimble/Makefile.include` includes logic for the module, however the corresponding Make target is missing. This produces the following error: ``` make[3]: *** No rule to make target 'nimble_svc_bas', needed by 'all'. Stop. ```
Im currently doing the following right now CFLAGS += -DMYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE=1
CFLAGS += -DMYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM=0 So that seems fine to me! |
I was aiming for something that would compile by default, so that we could enable compile testing coverage for Judging from the name only, I assume that this is possible to provide from the application side. But the default would need to be
as we cannot assume that each and every app provides battery level info. We would at least need a way to allow the app to overwrite this. With adding the patch for the the
which would allow the app to just add
to enable battery level reporting, if it has that implemented. |
The service doesn't directly provide any mechanism to read battery level, it only provides an API to set the current value.
|
Thx for clarifying! Would you mind to add this to |
I would advice about not making it a default behaviour through CFLAGS. Adding those lines makes it sort of impossible to change the behaviour if someone wished to do so. Whereas the patch at least allows the values to be redefined. Maybe not such a common scenario for battery, but you might want the encrypted read permission.
Hopefully I can get round to submitting some of the example/test apps i've used along the way of getting HID over GATT working. BAS being a optional service for it to function. |
OK, if we want the application to be able to set those values, I'd prefer the variant with the patch, as suggested in #21200 (comment) Having a module selectable that will not compile unless certain CFLAGS are set it a bit too arcane, even if that behaviour were documented. Instead, we need to peovide conservative defaults and allow the app to override, if needed. |
Contribution description
pkg/nimble/Makefile.include
includes logic for the module, however the corresponding Make target is missing.This produces the following error: