Commit 4ef8fd23 authored by Klint Youngmeyer's avatar Klint Youngmeyer
Browse files

Add timer that updates the read attributes at 2Hz. One has the value of SW1,...

Add timer that updates the read attributes at 2Hz. One has the value of SW1, the other has a RNG value.
parent 7b97850c
Pipeline #18 failed with stages
import pyb
import network
import micropython
class BleChat:
def __init__(self, name): = name
self.local_name = None
self.local_mac = None
self.write_handle = None
self.read_sw_handle = None
self.read_rand_handle = None = network.RS911XBT(pyb.SPI(2), pyb.Pin("I0"), pyb.Pin("E3"), pyb.Pin("E4")) = network.RS9116()
self.lcd = pyb.LCD()
self.led = pyb.LED(1)
self.tim = pyb.Timer(4)
self._set_attr = self._set_attr_method
def _timer_setup(self):
def _timer_callback(self, tim):
micropython.schedule(self._set_attr, 0)
def _set_attr_method(self, _):, "Pressed" if pyb.Switch(1).value() else "Not Pressed"), "{}".format(pyb.rng()))
def _radio_setup(self):
handle =
# write_attr_index = rs.add_attribute(handle, 0x1aa2, rs.ATT_PROPERTY_WRITE)
# read_attr_index = rs.add_attribute(handle, 0x2bb1, rs.ATT_PROPERTY_NOTIFY | rs.ATT_PROPERTY_READ), 0x1aa2,, 0x2bb1, |
self.write_handle =, 0x1aa2,
self.read_sw_handle =, 0x2bb1, |
self.read_rand_handle =, 0x3cc4,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment