Created
January 23, 2023 14:42
-
-
Save WayneKeenan/c8a176837b23fcdf05c2944be6f5417b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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