def test_connect(self): """ 0x5012: "latest_sensing_data", 0x5013: "latest_calculation_data", 0x5021: "latest_data_long", 0x5031: "vibration_count", 0x5111: "led_setting", 0x5115: "advertise_setting", """ sensor = Omron2JCIE_BU01.serial("COM3") tpl = sensor.latest_data_long() print(tpl) self.assertEqual(type(tpl).__name__, "latest_data_long") tpl = sensor.vibration_count() print(tpl) self.assertEqual(type(tpl).__name__, "vibration_count") tpl = sensor.led() print(tpl) self.assertEqual(type(tpl).__name__, "led_setting") tpl = sensor.info() print(tpl) self.assertEqual(type(tpl).__name__, "device_info") tpl = sensor.advertise_setting() print(tpl) self.assertEqual(type(tpl).__name__, "advertise_setting") tpl = sensor.advertise_setting(mode=0x03) print(tpl) self.assertEqual(type(tpl).__name__, "advertise_setting") self.assertEqual(tpl.mode, 0x03) tpl = sensor.advertise_setting(interval=0x00a0) print(tpl) self.assertEqual(tpl.interval, 0x00a0)
- 275 - 374 If you need scan on Linux, consider notify method. --- On Windows, data can be detected at intervals of 1 second or less. And complete data will be obtained about every 1 second. """ import sys sys.path.insert(0, "../lib-ext") sys.path.insert(0, "..") from omron_2jcie_bu01 import Omron2JCIE_BU01 #s = Omron2JCIE_BU01.ble("AA:BB:CC:DD:EE:FF") s = Omron2JCIE_BU01.ble() # Scan def on_scan(data): print(data) # Set Advertising mode: 0x03 (Active scan) # The setting is retained even when the power is turned off the device. s.advertise_setting(mode=0x03) # Scanning needs to disconnect # If connected, advertising packets will not be detected. s.disconnect()
def setUp(self): self.sensor = Omron2JCIE_BU01.ble(self.ADDRESS)
def setUpClass(cls): sensor = Omron2JCIE_BU01.ble() cls.ADDRESS = sensor.address print(f"Target HW address: {cls.ADDRESS}")
#!/usr/bin/env python3 import sys sys.path.insert(0, "../lib-ext") sys.path.insert(0, "..") from omron_2jcie_bu01 import Omron2JCIE_BU01 s = Omron2JCIE_BU01.serial("COM3") #s = Omron2JCIE_BU01.serial("/dev/ttyUSB0") # Show current setting print(s.led()) # rule=0x06 (noise) # rgb=(0, 255, 200) s.led(0x06, (0, 255, 200))