File tree 1 file changed +39
-0
lines changed 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2022 Scott Shawcroft for Adafruit Industries
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """
5
+ This example does a generic connectable advertisement and prints out the
6
+ manufacturer and model number of the device(s) that connect to it.
7
+ """
8
+
9
+ import time
10
+ import adafruit_ble
11
+ from adafruit_ble .advertising .standard import Advertisement
12
+ from adafruit_ble .services .standard .device_info import DeviceInfoService
13
+
14
+ radio = adafruit_ble .BLERadio ()
15
+ a = Advertisement ()
16
+ a .connectable = True
17
+ radio .start_advertising (a )
18
+
19
+ # Info that the other device can read about us.
20
+ my_info = DeviceInfoService (manufacturer = "CircuitPython.org" , model_number = "1234" )
21
+
22
+ print ("advertising" )
23
+
24
+ while not radio .connected :
25
+ pass
26
+
27
+ print ("connected" )
28
+
29
+ while radio .connected :
30
+ for connection in radio .connections :
31
+ if not connection .paired :
32
+ connection .pair ()
33
+ print ("paired" )
34
+ dis = connection [DeviceInfoService ]
35
+ print (dis .manufacturer )
36
+ print (dis .model_number )
37
+ time .sleep (60 )
38
+
39
+ print ("disconnected" )
You can’t perform that action at this time.
0 commit comments