Skip to content

Commit

Permalink
nrf528xx: correctly use the passed Advertising options type as the ty…
Browse files Browse the repository at this point in the history
…pe passed into the SoftDevice struct for API call

Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Jan 9, 2025
1 parent 52ffdd8 commit 0cdcf6d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion gap_nrf528xx-advertisement.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,26 @@ 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])),
len: C.uint16_t(a.payload.len),
}
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),
}
Expand Down

0 comments on commit 0cdcf6d

Please sign in to comment.