Python interface to remote control BOSCH PLM 40 C (might also work with other devices).
It implements the exchange data container where measurements are triggered by the device ("Event by LRF" similar to the MeasureOn App).
- measure distance
- turn laser on and off
- turn display backlight on and off
- get device name and device info (serial number, HW/SW version...)
- recive data from device via exchange data container ("Event by LRF")
The interface uses the Bluetooth module from PyQt5. It uses crc to compute checksums. qasync allows the usage of asyncio
with PyQt
. Poetry is used as build system.
The interface taskes advantage of async/await
.
from bosch_plr import Device
@Device.run('<mac-address of the device>')
async def main(device: Device):
for i in range(4):
data = await device.user_measure() # waits for the user to measure a distance with the device
print(data.result)
if __name__ == '__main__':
main()
>>> 4.001649856567383
>>> 3.888049840927124
>>> ...
from bosch_plr.device import Device
from PyQt6.QtWidgets import QApplication
from qasync import QEventLoop
import asyncio
app = QApplication([])
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
async def main():
device = Device()
await device.connect('<mac-address of the device>')
info = await device.info()
print(info)
distance = await device.measure() # trigger measurement from computer
print(distance)
await device.disconnect()
if __name__ == '__main__':
loop.run_until_complete(main())
>>> info = {'date_code': '131', 'serial_number': ..., 'sw_revision': 2263, 'sw_version': '1.3.3', 'hw_version': '6.0.0', 'part_number': '...'}
>>> distance = 47.318
poetry run sandbox
- Bosch_GLM_PLR_Bluetooth_App_Kit
- Hacking the Bosch GLM 20 Laser Measuring Tape
- Android Bluetooth HCI snoop log + Wireshark
- BOSCH-GLM-rangefinder by Philipp Trenz