def __SelectChipOnOff(self, ChipOnOff): timeout = 1000000 if ChipOnOff == 1: gpio.low(self.spi_select) #deselect chip after timout elif ChipOnOff == 0: while timeout > 1: timeout -= 1 gpio.high(self.spi_select)
def init(ser, appeui, appkey, rst, join_lora=True, short_startup=False): """ .. function:: init(ser, appeui, appkey, rst, join_lora=True) Performs basic module configuration and try over-the-air activation. * *ser* is the serial port used for device-to-module communication (ex. SERIAL1) * *appeui*, *appkey* are needed for otaa * *rst* is the module reset pin * if *join_lora* is False the configuration and over-the-air activation attempt are skipped and the module can be configured through the :ref:`config() <config>` function and then the LoRa network can be joined calling the :ref:`join() <join>` function. """ global _ser, _appeui, _appkey, _deveui if _ser is None: gpio.mode(rst, OUTPUT) gpio.high(rst) sleep(100) gpio.low(rst) sleep(100) gpio.high(rst) _ser = streams.serial(ser, set_default=False, baud=57600) _get_startup_msg() if short_startup: return _appeui = appeui _appkey = appkey if join_lora: config(appeui=appeui, appkey=appkey) joined = join() return joined
def __init__(self, watchdog_time): sfw.watchdog(0, watchdog_time) port_expander = sx1503.SX1503(I2C0, 400000) gpio.add_expander(1, port_expander, pinmap) gpio.mode(LED_R, OUTPUT) gpio.mode(LED_G, OUTPUT) gpio.mode(LED_B, OUTPUT) gpio.mode(RS485EN, OUTPUT) gpio.low(LED_G) gpio.low(LED_R) gpio.high(LED_B) gpio.low(RS485EN) self.port = streams.serial(drvname=SERIAL1, baud=9600, set_default=False)
def write(self, packet): gpio.high(RS485EN) self.port.write(packet) gpio.low(RS485EN) sfw.kick()
def read(self): gpio.low(RS485EN) bc = self.port.available() sfw.kick() return self.port.read(bc)