Skip to content

Instantly share code, notes, and snippets.

@bobmcwhirter
Last active November 13, 2020 19:08
Show Gist options
  • Select an option

  • Save bobmcwhirter/501bc1fca11c421c57be7bd8f75e25b2 to your computer and use it in GitHub Desktop.

Select an option

Save bobmcwhirter/501bc1fca11c421c57be7bd8f75e25b2 to your computer and use it in GitHub Desktop.
let host: &mut BlueNrgHost<'_> = ctx.resources.ble_host;
let params = LeSetAdvertisingParameters {
min_interval: Milliseconds(500),
max_interval: Milliseconds(500),
advertising_type: AdvertisingType::ConnectableAndScannableUndirected,
own_address_type: Default::default(),
peer_address_type: Default::default(),
peer_address: Address([0, 0, 0, 0, 0, 0]),
channel_map: Default::default(),
filter_policy: Default::default(),
};
host.set_advertising_parameters(params).unwrap();
let mut advertising_data = Vec::new();
advertising_data.push(
AdvertisingData::AdvertisingFlags(
AdvertisingFlags {
discoverability: Discoverability::General,
capability: Capability::LeOnly,
}
)
);
advertising_data.push(
AdvertisingData::ManufacturerSpecific(
CompanyIdentifier(0x004c), Vec::from_slice( &[ 0x02, 0x15,
0xF0, 0x01, 0x8B, 0x9B, /**/ 0x75, 0x09, /**/ 0x4C, 0x31, /**/ 0xA9, 0x05, /**/ 0x1A, 0x27, 0xD3, 0x9C, 0x00, 0x3C,
0x00, 0x01, 0x00, 0x02,
0xc8
] ).unwrap()
)
);
host.set_advertising_data(advertising_data).unwrap();
host.set_advertising_enable(true).unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment