How to use the rak811.Mode.LoRaWan function in rak811

To help you get started, we’ve selected a few rak811 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AmedeeBulle / pyrak811 / examples / otaa.py View on Github external
SPDX-License-Identifier: Apache-2.0
"""
from random import randint
from sys import exit
from time import sleep

from rak811 import Mode, Rak811
from ttn_secrets import APP_EUI, APP_KEY

lora = Rak811()

# Most of the setup should happen only once...
print('Setup')
lora.hard_reset()
lora.mode = Mode.LoRaWan
lora.band = 'EU868'
lora.set_config(app_eui=APP_EUI,
                app_key=APP_KEY)

print('Joining')
lora.join_otaa()
# Note that DR is different from SF and depends on the region
# See: https://docs.exploratory.engineering/lora/dr_sf/
# Set Data Rate to 5 which is SF7/125kHz for EU868
lora.dr = 5

print('Sending packets every minute - Interrupt to cancel loop')
print('You can send downlinks from the TTN console')
try:
    while True:
        print('Send packet')
github AmedeeBulle / pyrak811 / rak811 / cli.py View on Github external
def mode(ctx, mode):
    """Get/Set mode to LoRaWan or LoRaP2P."""
    lora = Rak811()
    if mode is None:
        click.echo('LoRaWan' if lora.mode == Mode.LoRaWan else 'LoRaP2P')
    else:
        mode = mode.lower()
        if mode == 'lorawan':
            lora.mode = Mode.LoRaWan
        else:
            lora.mode = Mode.LoRaP2P
        if ctx.obj['VERBOSE']:
            click.echo('Mode set to {0}.'.format(
                'LoRaWan' if mode == 'lorawan' else 'LoRaP2P'))
    lora.close()
github AmedeeBulle / pyrak811 / examples / abp.py View on Github external
SPDX-License-Identifier: Apache-2.0
"""
from random import randint
from sys import exit
from time import sleep

from rak811 import Mode, Rak811
from ttn_secrets import APPS_KEY, DEV_ADDR, NWKS_KEY

lora = Rak811()

# Most of the setup should happen only once...
print('Setup')
lora.hard_reset()
lora.mode = Mode.LoRaWan
lora.band = 'EU868'
lora.set_config(dev_addr=DEV_ADDR,
                apps_key=APPS_KEY,
                nwks_key=NWKS_KEY)

print('Joining')
lora.join_abp()
# Note that DR is different from SF and depends on the region
# See: https://docs.exploratory.engineering/lora/dr_sf/
# Set Data Rate to 5 which is SF7/125kHz for EU868
lora.dr = 5

print('Sending packets every minute - Interrupt to cancel loop')
print('You can send downlinks from the TTN console')
try:
    while True:
github AmedeeBulle / pyrak811 / rak811 / cli.py View on Github external
def mode(ctx, mode):
    """Get/Set mode to LoRaWan or LoRaP2P."""
    lora = Rak811()
    if mode is None:
        click.echo('LoRaWan' if lora.mode == Mode.LoRaWan else 'LoRaP2P')
    else:
        mode = mode.lower()
        if mode == 'lorawan':
            lora.mode = Mode.LoRaWan
        else:
            lora.mode = Mode.LoRaP2P
        if ctx.obj['VERBOSE']:
            click.echo('Mode set to {0}.'.format(
                'LoRaWan' if mode == 'lorawan' else 'LoRaP2P'))
    lora.close()