Skip to content

Instantly share code, notes, and snippets.

@WayneKeenan
Created January 23, 2023 14:42
Show Gist options
  • Save WayneKeenan/c8a176837b23fcdf05c2944be6f5417b to your computer and use it in GitHub Desktop.
Save WayneKeenan/c8a176837b23fcdf05c2944be6f5417b to your computer and use it in GitHub Desktop.
from gpiozero import LED
from bubblepy import peripheral, gatt
@gatt.service(0x1234)
class Light:
def __init__(self):
self.led = LED(17)
@gatt.characteristic(0xABCD, ['write'], "Set Light State")
def light_state(self):
return [self.led.is_lit]
@light_state.setter
def light_state(self, bytes):
if len(bytes)>0 and bytes[0]>0:
self.led.on()
else:
self.led.off()
peripheral.add_service(Light())
peripheral.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment