From 0cdcf6d099a7c6808a3a1d665ffc72be7a8f15ab Mon Sep 17 00:00:00 2001 From: deadprogram Date: Wed, 8 Jan 2025 12:38:37 +0100 Subject: [PATCH] nrf528xx: correctly use the passed Advertising options type as the type passed into the SoftDevice struct for API call Signed-off-by: deadprogram --- gap_nrf528xx-advertisement.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gap_nrf528xx-advertisement.go b/gap_nrf528xx-advertisement.go index da6ae52..e19ae07 100644 --- a/gap_nrf528xx-advertisement.go +++ b/gap_nrf528xx-advertisement.go @@ -56,6 +56,18 @@ func (a *Advertisement) Configure(options AdvertisementOptions) error { return errAdvertisementPacketTooBig } + var typ uint8 + switch options.AdvertisementType { + case AdvertisingTypeInd: + typ = C.BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED + case AdvertisingTypeDirectInd: + typ = C.BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED + case AdvertisingTypeScanInd: + typ = C.BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED + case AdvertisingTypeNonConnInd: + typ = C.BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED + } + data := C.ble_gap_adv_data_t{} data.adv_data = C.ble_data_t{ p_data: (*C.uint8_t)(unsafe.Pointer(&a.payload.data[0])), @@ -63,7 +75,7 @@ func (a *Advertisement) Configure(options AdvertisementOptions) error { } params := C.ble_gap_adv_params_t{ properties: C.ble_gap_adv_properties_t{ - _type: C.BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED, + _type: typ, }, interval: C.uint32_t(options.Interval), }