From 03c848cde6594c61bd92e7737472a51471be82b5 Mon Sep 17 00:00:00 2001 From: Simon Danner Date: Tue, 3 Jan 2023 12:25:50 +0100 Subject: [PATCH] Docs: Make scanner sample code work with python3 by using print() --- docs/scanner.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/scanner.rst b/docs/scanner.rst index 2727cc4d..cd27f81c 100644 --- a/docs/scanner.rst +++ b/docs/scanner.rst @@ -82,9 +82,9 @@ Basic code to run a LE device scan for 10 seconds follows this example:: # when this python script discovers a BLE broadcast packet, print a message with the device's MAC address def handleDiscovery(self, dev, isNewDev, isNewData): if isNewDev: - print "Discovered device", dev.addr + print("Discovered device", dev.addr) elif isNewData: - print "Received new data from", dev.addr + print("Received new data from", dev.addr) # create a scanner object that sends BLE broadcast packets to the ScanDelegate scanner = Scanner().withDelegate(ScanDelegate()) @@ -96,7 +96,7 @@ Basic code to run a LE device scan for 10 seconds follows this example:: for dev in devices: # print the device's MAC address, its address type, # and Received Signal Strength Indication that shows how strong the signal was when the script received the broadcast. - print "Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi) + print("Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi)) # For each of the device's advertising data items, print a description of the data type and value of the data itself # getScanData returns a list of tupples: adtype, desc, value @@ -104,7 +104,7 @@ Basic code to run a LE device scan for 10 seconds follows this example:: # https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile # desc is a human-readable description of the data type and value is the data itself for (adtype, desc, value) in dev.getScanData(): - print " %s = %s" % (desc, value) + print(" %s = %s" % (desc, value)) For continuous scanning, follow this example:: @@ -120,9 +120,9 @@ For continuous scanning, follow this example:: # when this python script discovers a BLE broadcast packet, print a message with the device's MAC address def handleDiscovery(self, dev, isNewDev, isNewData): if isNewDev: - print "Discovered device", dev.addr + print("Discovered device", dev.addr) elif isNewData: - print "Received new data from", dev.addr + print("Received new data from", dev.addr) # create a scanner object that sends BLE broadcast packets to the ScanDelegate scanner = Scanner().withDelegate(ScanDelegate()) @@ -130,7 +130,7 @@ For continuous scanning, follow this example:: # start the scanner and keep the process running scanner.start() while True: - print "Still running..." + print("Still running...") scanner.process()