blatann.examples.peripheral_glucose_service module¶
This example demonstrates using Bluetooth SIG’s defined Glucose service as a peripheral. The peripheral creates a range of fake glucose readings that can be queried from the central.
This can be used in conjunction with the nRF Connect apps to explore the peripheral’s functionality
- blatann.examples.peripheral_glucose_service.on_connect(peer, event_args)¶
Event callback for when a central device connects to us
- Parameters
peer (blatann.peer.Client) – The peer that connected to us
event_args – None
- blatann.examples.peripheral_glucose_service.on_disconnect(peer, event_args)¶
Event callback for when the client disconnects from us (or when we disconnect from the client)
- Parameters
peer (blatann.peer.Client) – The peer that disconnected
event_args (blatann.event_args.DisconnectionEventArgs) – The event args
- blatann.examples.peripheral_glucose_service.on_security_level_changed(peer, event_args)¶
Event callback for when the security level changes on a connection with a peer
- Parameters
peer (blatann.peer.Client) – The peer the security level changed on
event_args (blatann.event_args.SecurityLevelChangedEventArgs) – The event args
- blatann.examples.peripheral_glucose_service.display_passkey(peer, event_args)¶
Event callback that is called when a passkey is required to be displayed to a user for the pairing process.
- Parameters
peer (blatann.peer.Client) – The peer the passkey is for
event_args (blatann.event_args.PasskeyDisplayEventArgs) – The event args
- blatann.examples.peripheral_glucose_service.add_fake_glucose_readings(glucose_database, num_records=15)¶
Helper method to create some glucose readings and add them to the glucose database
- Parameters
glucose_database (glucose.BasicGlucoseDatabase) – The database to add readings to
num_records – The number of records to generate
- blatann.examples.peripheral_glucose_service.main(serial_port)¶