["read"], characteristic) def ReadValue(self, options): value = [] value.append(dbus.Byte(0x1B)) value.append(dbus.Byte(0x00)) value.append(dbus.Byte(0x00)) value.append(dbus.Byte(0x00)) value.append(dbus.Byte(0x01)) value.append(dbus.Byte(0x00)) value.append(dbus.Byte(0x00)) return value app = Application() app.add_service(DeviceInformationService(0)) app.add_service(HeliumService(1)) app.register() adv = ConfigAdvertisement(0) # Setup GPIO Devices variant = os.getenv('VARIANT') if (variant == "Indoor"): buttonGPIO = 26 statusGPIO = 25 else: buttonGPIO = 24 statusGPIO = 25 userButton = Button(buttonGPIO, hold_time=5)
class UnitDescriptor(Descriptor): UNIT_DESCRIPTOR_UUID = "2901" UNIT_DESCRIPTOR_VALUE = "Temperature Units (F or C)" def __init__(self, characteristic): Descriptor.__init__( self, self.UNIT_DESCRIPTOR_UUID, ["read"], characteristic) def ReadValue(self, options): value = [] desc = self.UNIT_DESCRIPTOR_VALUE for c in desc: value.append(dbus.Byte(c.encode())) return value app = Application() app.add_service(ThermometerService(0)) app.register() adv = ThermometerAdvertisement(0) adv.register() try: app.run() except KeyboardInterrupt: app.quit()
return value class MacDescriptor(Descriptor): MAC_DESCRIPTOR_UUID = "2901" MAC_DESCRIPTOR_VALUE = "MAC Address" def __init__(self, characteristic): Descriptor.__init__(self, self.MAC_DESCRIPTOR_UUID, ["read"], characteristic) def ReadValue(self, options): value = [] desc = self.MAC_DESCRIPTOR_VALUE for c in desc: value.append(dbus.Byte(c.encode())) return value if __name__ == "__main__": app = Application() app.add_service(MacService(0)) app.register() adv = MacAdvertisement(0) adv.register() app.run()
def WriteValue(self, value, options): output = bytes(value).decode() if output == "0": print('turning LED off') GPIO.output(26, GPIO.LOW) elif output == "1": print('turning LED on') GPIO.output(26, GPIO.HIGH) else: print('try again') print(output) #GPIO setup GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(26, GPIO.OUT) app = Application() app.add_service(BLEService(0)) app.register() adv = LEDControlAdvertisement(0) adv.register() try: app.run() except KeyboardInterrupt: app.quit()
PRESSURE_DESCRIPTOR_VALUE = "Pressure" def __init__(self, characteristic): Descriptor.__init__(self, self.PRESSURE_DESCRIPTOR_UUID, ["read"], characteristic) def ReadValue(self, options): value = [] desc = self.PRESSURE_DESCRIPTOR_VALUE for c in desc: value.append(dbus.Byte(c.encode())) return value sense = SenseHat() app = Application() app.add_service(SensorsService(0)) app.register() adv = SensorsAdvertisement(0) adv.add_service_uuid(uuid="181A") adv.register() try: app.run() except KeyboardInterrupt: app.quit()
class PauseDescriptor(Descriptor): PAUSE_DESCRIPTOR_UUID = "2901" PAUSE_DESCRIPTOR_VALUE = "Pause" def __init__(self, characteristic): Descriptor.__init__(self, self.PAUSE_DESCRIPTOR_UUID, ["read"], characteristic) def ReadValue(self, options): value = [] desc = self.PAUSE_DESCRIPTOR_VALUE for c in desc: value.append(dbus.Byte(c.encode())) return value app = Application() app.add_service(PiService(0)) app.add_service(VLCService(1)) app.register() adv = MainMainAdvertisement(0) adv.register() try: app.run() except KeyboardInterrupt: app.quit()