You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
self.device_state=HumanInterfaceDevice.DEVICE_STOPPED# The initial device state.
194
194
self.conn_handle=None# The handle of the connected client. HID devices can only have a single connection.
195
195
self.state_change_callback=None# The user defined callback function which gets called when the device state changes.
196
+
self.passkey_callback=None# The user defined callback function which gets called when a passkey is prompted.
196
197
self.io_capability=_IO_CAPABILITY_NO_INPUT_OUTPUT# The IO capability of the device. This is used to allow for different ways of identification during pairing.
197
198
self.bond=True# Do we wish to bond with connecting clients? Normally True. Not supported by older Micropython versions.
198
199
self.le_secure=True# Do we wish to use a secure connection? Normally True. Not supported by older Micropython versions.
@@ -393,8 +394,7 @@ def start(self):
393
394
print("BLE on with", "random"ifaddr_typeelse"public", "mac address", addr)
394
395
395
396
# After registering the DIS and BAS services, write their characteristic values.
396
-
# Must be overwritten by subclass, and called in
397
-
# the overwritten function by using
397
+
# Must be overwritten by subclass, and called in the overwritten function by using
Copy file name to clipboardExpand all lines: readme.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ The reason for this is that such functionality is entirely dependent on the inte
134
134
135
135
The library consists of five classes with the following functions:
136
136
137
-
*`HumanInterfaceDevice` (superclass for the HID service classes, implements the Device Information and Battery services, and sets up BLE and advertisement)
137
+
*`HumanInterfaceDevice` (Superclass for the HID service classes, implements the Device Information and Battery services, and sets up BLE and advertisement)
138
138
*`__init__(device_name)` (Initialize the superclass)
139
139
*`ble_irq(event, data)` (Internal callback function that catches BLE interrupt requests)
140
140
*`start()` (Starts Device Information and Battery services)
@@ -163,19 +163,20 @@ The library consists of five classes with the following functions:
163
163
*`set_passkey_callback(passkey_callback)` (Set callback function for pairing events. Callback function should return boolean to accept connection or passkey depending on I/O capability used)
164
164
*`set_passkey(passkey)` (Set the passkey to use for pairing)
165
165
*`set_keystore(keystore)` (Sets the key store to use from `hid_keystores.py`. Default `JSONKeyStore`)
166
+
*`forget_clients()` (Removes all client keys from the key store)
166
167
*`set_battery_level(level)` (Sets the battery level internally)
167
168
*`notify_battery_level()` (Notifies the client of the current battery level. Call after setting battery level)
168
169
*`notify_hid_report()` (Function for subclasses to override)
169
170
170
-
*`Joystick` (subclass of `HumanInterfaceDevice`, implements joystick service)
171
+
*`Joystick` (Subclass of `HumanInterfaceDevice`, implements joystick service)
171
172
*`__init__(name)` (Initialize the joystick)
172
173
*`start()` (Starts the HID service using joystick characteristics. Calls `HumanInterfaceDevice.start()`)
173
174
*`write_service_characteristics(handles)` (Writes the joystick HID service characteristics. Calls `HumanInterfaceDevice.write_service_characteristics(handles)`)
174
175
*`notify_hid_report()` (Notifies the client of the internal HID joystick status)
175
176
*`set_axes(x, y)` (Sets the joystick axes internally)
*`Mouse` (subclass of `HumanInterfaceDevice`, implements mouse service)
179
+
*`Mouse` (Subclass of `HumanInterfaceDevice`, implements mouse service)
179
180
*`__init__(name)` (Initialize the mouse)
180
181
*`start()` (Starts the HID service using mouse characteristics. Calls `HumanInterfaceDevice.start()`)
181
182
*`write_service_characteristics(handles)` (Writes the mouse HID service characteristics. Calls `HumanInterfaceDevice.write_service_characteristics(handles)`)
@@ -184,7 +185,7 @@ The library consists of five classes with the following functions:
184
185
*`set_wheel(w)` (Sets the mouse wheel movement internally)
185
186
*`set_buttons(b1, b2, b3)` (Sets the mouse buttons internally)
186
187
187
-
*`Keyboard` (subclass of `HumanInterfaceDevice`, implements keyboard service)
188
+
*`Keyboard` (Subclass of `HumanInterfaceDevice`, implements keyboard service)
188
189
*`__init__(name)` (Initialize the keyboard)
189
190
*`start()` (Starts the HID service using keyboard characteristics. Calls `HumanInterfaceDevice.start()`)
190
191
*`write_service_characteristics(handles)` (Writes the keyboard HID service characteristics. Calls `HumanInterfaceDevice.write_service_characteristics(handles)`)
@@ -203,6 +204,29 @@ The library consists of five classes with the following functions:
203
204
*`start_advertising()` (Used internally)
204
205
*`stop_advertising()` (Used internally)
205
206
207
+
*`KeyStore` (Superclass for the key store classes)
208
+
*`__init__()` (Initialize the key store)
209
+
*`add_secret(type, key, value)` (Adds a type-key-value triplet)
210
+
*`get_secret(type, index, key)` (Returns the value for the given type-key pair, or the value at the given index for the given type)
211
+
*`remove_secret(type, key)` (Removes the type-key-value triplet of the given type-key pair)
212
+
*`has_secret(type, key)` (Return true iff there exists a value for the given type-key pair)
213
+
*`get_json_secrets()` (Returns the added type-key-value triplets as a JSON string)
214
+
*`add_json_secrets(entries)` (Adds all type-key-value triplets contained in the given JSON string)
215
+
*`clear_secrets()` (Removes all type-key-value triplets)
216
+
*`load_secrets()` (Function for subclasses to override)
217
+
*`save_secrets()` (Function for subclasses to override)
218
+
219
+
*`JSONKeyStore` (Subclass of `KeyStore` that saves the type-key-value triplets as a JSON file)
220
+
*`__init__()` (Initialize the key store)
221
+
*`clear_secrets()` (Removes all type-key-value triplets and calls `save_secrets()`)
222
+
*`load_secrets()` (Loads the JSON file and calls `add_json_secrets(entries)`)
223
+
*`save_secrets()` (Calls `get_json_secrets()` and saves the result to a file)
224
+
225
+
*`NVSKeyStore` (Subclass of `KeyStore` that saves the type-key-value triplets in non-volatile storage)
226
+
*`__init__()` (Initialize the key store)
227
+
*`clear_secrets()` (Removes all type-key-value triplets and calls `save_secrets()`)
228
+
*`load_secrets()` (Loads the JSON blob from non-volatile storage and calls `add_json_secrets(entries)`)
229
+
*`save_secrets()` (Calls `get_json_secrets()` and saves the result to a non-volatile storage blob)
206
230
207
231
<palign="right">(<ahref="#top">back to top</a>)</p>
0 commit comments