Skip to content

Commit 1084498

Browse files
Damian-Nordicrestyled-commits
authored andcommitted
[nrfconnect] Introduce BLE advertising arbiter (#24637)
* [nrfconnect] Introduce BLE advertising arbiter Add a class that enables easier coexistence of Matter and custom BLE services. Signed-off-by: Damian Krolik <[email protected]> * Restyled by clang-format --------- Signed-off-by: Damian Krolik <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent fa7fca5 commit 1084498

File tree

35 files changed

+397
-308
lines changed

35 files changed

+397
-308
lines changed

config/nrfconnect/chip-module/Kconfig.defaults

+1-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ config BT_DEVICE_NAME_MAX
127127
default 15
128128

129129
config BT_MAX_CONN
130-
default 2 # a workaround for non-unreferenced BLE connection object
131-
# when restaring the BLE advertising in disconnect callback
132-
# TODO: analyze and revert to 1 if proper fix exists
130+
default 1
133131

134132
config BT_L2CAP_TX_MTU
135133
default 247

examples/all-clusters-app/nrfconnect/main/AppTask.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,6 @@ void AppTask::FunctionTimerEventHandler(const AppEvent & event)
332332
}
333333
}
334334

335-
#ifdef CONFIG_MCUMGR_SMP_BT
336-
void AppTask::RequestSMPAdvertisingStart(void)
337-
{
338-
AppEvent event;
339-
event.Type = AppEventType::StartSMPAdvertising;
340-
event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); };
341-
PostEvent(event);
342-
}
343-
#endif
344-
345335
void AppTask::FunctionHandler(const AppEvent & event)
346336
{
347337
if (event.ButtonEvent.PinNo != FUNCTION_BUTTON)

examples/all-clusters-app/nrfconnect/main/include/AppEvent.h

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ enum class AppEventType : uint8_t
3333
UpdateLedState,
3434
IdentifyStart,
3535
IdentifyStop,
36-
StartSMPAdvertising
3736
};
3837

3938
enum class FunctionEvent : uint8_t

examples/all-clusters-app/nrfconnect/main/include/AppTask.h

-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ class AppTask
6666
static void FunctionTimerTimeoutCallback(k_timer * timer);
6767
static void UpdateStatusLED();
6868

69-
#ifdef CONFIG_MCUMGR_SMP_BT
70-
static void RequestSMPAdvertisingStart(void);
71-
#endif
72-
7369
FunctionEvent mFunction = FunctionEvent::NoneSelected;
7470
bool mFunctionTimerActive = false;
7571

examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,6 @@ void AppTask::ButtonEventHandler(uint32_t buttonState, uint32_t hasChanged)
209209
}
210210
}
211211

212-
#ifdef CONFIG_MCUMGR_SMP_BT
213-
void AppTask::RequestSMPAdvertisingStart(void)
214-
{
215-
AppEvent event;
216-
event.Type = AppEventType::StartSMPAdvertising;
217-
event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); };
218-
PostEvent(event);
219-
}
220-
#endif
221-
222212
void AppTask::FunctionTimerTimeoutCallback(k_timer * timer)
223213
{
224214
if (!timer)

examples/all-clusters-minimal-app/nrfconnect/main/include/AppEvent.h

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ enum class AppEventType : uint8_t
3333
UpdateLedState,
3434
IdentifyStart,
3535
IdentifyStop,
36-
StartSMPAdvertising
3736
};
3837

3938
enum class FunctionEvent : uint8_t

examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h

-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ class AppTask
6262
static void FunctionTimerTimeoutCallback(k_timer * timer);
6363
static void UpdateStatusLED();
6464

65-
#ifdef CONFIG_MCUMGR_SMP_BT
66-
static void RequestSMPAdvertisingStart(void);
67-
#endif
68-
6965
FunctionEvent mFunction = FunctionEvent::NoneSelected;
7066
bool mFunctionTimerActive = false;
7167

examples/light-switch-app/nrfconnect/main/AppTask.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ CHIP_ERROR AppTask::Init()
185185

186186
// Initialize DFU
187187
#ifdef CONFIG_MCUMGR_SMP_BT
188-
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
188+
GetDFUOverSMP().Init();
189189
GetDFUOverSMP().ConfirmNewImage();
190190
#endif
191191

@@ -646,16 +646,6 @@ void AppTask::FunctionTimerTimeoutCallback(k_timer * timer)
646646
}
647647
}
648648

649-
#ifdef CONFIG_MCUMGR_SMP_BT
650-
void AppTask::RequestSMPAdvertisingStart(void)
651-
{
652-
AppEvent event;
653-
event.Type = AppEventType::StartSMPAdvertising;
654-
event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); };
655-
PostEvent(event);
656-
}
657-
#endif
658-
659649
void AppTask::PostEvent(const AppEvent & event)
660650
{
661651
if (k_msgq_put(&sAppEventQueue, &event, K_NO_WAIT) != 0)

examples/light-switch-app/nrfconnect/main/include/AppEvent.h

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ enum class AppEventType : uint8_t
3333
UpdateLedState,
3434
IdentifyStart,
3535
IdentifyStop,
36-
StartSMPAdvertising
3736
};
3837

3938
enum class FunctionEvent : uint8_t

examples/light-switch-app/nrfconnect/main/include/AppTask.h

-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ class AppTask
8484
static void StartTimer(Timer, uint32_t);
8585
static void CancelTimer(Timer);
8686

87-
#ifdef CONFIG_MCUMGR_SMP_BT
88-
static void RequestSMPAdvertisingStart(void);
89-
#endif
90-
9187
FunctionEvent mFunction = FunctionEvent::NoneSelected;
9288

9389
#if CONFIG_CHIP_FACTORY_DATA

examples/lighting-app/nrfconnect/main/AppTask.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ CHIP_ERROR AppTask::Init()
195195

196196
#ifdef CONFIG_MCUMGR_SMP_BT
197197
// Initialize DFU over SMP
198-
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
198+
GetDFUOverSMP().Init();
199199
GetDFUOverSMP().ConfirmNewImage();
200200
#endif
201201

@@ -443,16 +443,6 @@ void AppTask::FunctionTimerEventHandler(const AppEvent & event)
443443
}
444444
}
445445

446-
#ifdef CONFIG_MCUMGR_SMP_BT
447-
void AppTask::RequestSMPAdvertisingStart(void)
448-
{
449-
AppEvent event;
450-
event.Type = AppEventType::StartSMPAdvertising;
451-
event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); };
452-
PostEvent(event);
453-
}
454-
#endif
455-
456446
void AppTask::FunctionHandler(const AppEvent & event)
457447
{
458448
if (event.ButtonEvent.PinNo != FUNCTION_BUTTON)

examples/lighting-app/nrfconnect/main/include/AppEvent.h

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ enum class AppEventType : uint8_t
3535
Lighting,
3636
IdentifyStart,
3737
IdentifyStop,
38-
StartSMPAdvertising
3938
};
4039

4140
enum class FunctionEvent : uint8_t

examples/lighting-app/nrfconnect/main/include/AppTask.h

-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ class AppTask
8686
static void FunctionHandler(const AppEvent & event);
8787
static void StartBLEAdvertisementAndLightActionEventHandler(const AppEvent & event);
8888

89-
#ifdef CONFIG_MCUMGR_SMP_BT
90-
static void RequestSMPAdvertisingStart(void);
91-
#endif
92-
9389
FunctionEvent mFunction = FunctionEvent::NoneSelected;
9490
bool mFunctionTimerActive = false;
9591
PWMDevice mPWMDevice;

examples/lock-app/nrfconnect/main/AppTask.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ CHIP_ERROR AppTask::Init()
179179

180180
#ifdef CONFIG_MCUMGR_SMP_BT
181181
// Initialize DFU over SMP
182-
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
182+
GetDFUOverSMP().Init();
183183
GetDFUOverSMP().ConfirmNewImage();
184184
#endif
185185

@@ -399,16 +399,6 @@ void AppTask::FunctionTimerEventHandler(const AppEvent & event)
399399
}
400400
}
401401

402-
#ifdef CONFIG_MCUMGR_SMP_BT
403-
void AppTask::RequestSMPAdvertisingStart(void)
404-
{
405-
AppEvent event;
406-
event.Type = AppEventType::StartSMPAdvertising;
407-
event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); };
408-
PostEvent(event);
409-
}
410-
#endif
411-
412402
void AppTask::FunctionHandler(const AppEvent & event)
413403
{
414404
if (event.ButtonEvent.PinNo != FUNCTION_BUTTON)

examples/lock-app/nrfconnect/main/include/AppEvent.h

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ enum class AppEventType : uint8_t
3434
UpdateLedState,
3535
IdentifyStart,
3636
IdentifyStop,
37-
StartSMPAdvertising
3837
};
3938

4039
enum class FunctionEvent : uint8_t

examples/lock-app/nrfconnect/main/include/AppTask.h

-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ class AppTask
7676

7777
static void LockStateChanged(BoltLockManager::State state, BoltLockManager::OperationSource source);
7878

79-
#ifdef CONFIG_MCUMGR_SMP_BT
80-
static void RequestSMPAdvertisingStart(void);
81-
#endif
82-
8379
FunctionEvent mFunction = FunctionEvent::NoneSelected;
8480
bool mFunctionTimerActive = false;
8581

0 commit comments

Comments
 (0)