Skip to content

Commit 0cdcf6d

Browse files
committed
nrf528xx: correctly use the passed Advertising options type as the type passed into the SoftDevice struct for API call
Signed-off-by: deadprogram <[email protected]>
1 parent 52ffdd8 commit 0cdcf6d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

gap_nrf528xx-advertisement.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,26 @@ func (a *Advertisement) Configure(options AdvertisementOptions) error {
5656
return errAdvertisementPacketTooBig
5757
}
5858

59+
var typ uint8
60+
switch options.AdvertisementType {
61+
case AdvertisingTypeInd:
62+
typ = C.BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED
63+
case AdvertisingTypeDirectInd:
64+
typ = C.BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED
65+
case AdvertisingTypeScanInd:
66+
typ = C.BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED
67+
case AdvertisingTypeNonConnInd:
68+
typ = C.BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED
69+
}
70+
5971
data := C.ble_gap_adv_data_t{}
6072
data.adv_data = C.ble_data_t{
6173
p_data: (*C.uint8_t)(unsafe.Pointer(&a.payload.data[0])),
6274
len: C.uint16_t(a.payload.len),
6375
}
6476
params := C.ble_gap_adv_params_t{
6577
properties: C.ble_gap_adv_properties_t{
66-
_type: C.BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED,
78+
_type: typ,
6779
},
6880
interval: C.uint32_t(options.Interval),
6981
}

0 commit comments

Comments
 (0)