Giter VIP home page Giter VIP logo

lora-mote-emulator's Introduction

LoRa Mote Emulator

version python license

This is a useful tool to test LoRa server.

To emulate end devices (a.k.a. Motes in LoRaWAN ™ protocol)

Support LoRaWAN ™ 1.0.2 & 1.1 protocol

Using Gateways from Semtech ™

System Requirements

  • Ubuntu
  • Python(>=3.6, mandatory)

Installtion

PYPI

  • Use pip to install lora-mote-emulator:

    pip install lora-mote-emulator

MANUALLY

  • Use pip to install pipenv:

    pip install pipenv
  • Clone this repo into a directory:

    git clone https://github.com/houluy/lora-mote-emulator.git
  • Use pipenv to create a virtual Python environment and install all the dependencies:

    pipenv install
  • Build the project:

    python -m build 

Here, if there is not Python 3.6 in your system, a warning will occur, and no package will be installed. It is perfect to install Python 3.6 from source. Otherwise, remove the Pipfile.lock and redo the above command.

  • Enter the virtual environment by pipenv shell
  • Run mote -h to see the help message

Usage

usage: mote [-h] [-v version] [-c CONFIG] [--model MODEL]
            {join,app,pull,mac,rejoin,info,abp,create} ...

Tool to emulate LoRa mote (a.k.a end-device) and Gateway, supported command
list: ['join', 'app', 'pull', 'mac', 'rejoin', 'info', 'abp', 'create']

optional arguments:
  -h, --help            show this help message and exit
  -v version, --version version
                        Choose LoRaWAN version, 1.0.2 or 1.1(default)
  -c CONFIG, --config CONFIG
                        Specify the directory of config files, default
                        './config'
  --model MODEL         Specify the directory to save the model file, default
                        './models'

Supported commands:
  {join,app,pull,mac,rejoin,info,abp,create}
    join                Send join request.
    app                 Send application data.
    pull                Send PULL_DATA.
    mac                 Send MACCommand.
    rejoin              Send rejoin request.
    info                Show information of current mote.
    abp                 Initialize mote in ABP mode.
    create              Handle configurations.

Tutorial

  • First, we need to create configuration files by command mote create [-c ./config]. Mote will generate required config template JSON files in the ./config directory (default). In the directory, several JSON config files are included.
  • config.json: Basic configurations.
  • gateway.json: Gateway EUI.
  • device.json: Device parameters for OTAA mode.
  • abp.json: Device parameters for ABP mode.

OTAA

  • Modify device infomation in device.json copied. An example: :

    {
        "Device": {
            "JoinEUI": "0000000000000000",
            "DevEUI": "0000000000000000"
        },
        "RootKeys": {
            "AppKey": "00000000000000000000000000000000",
            "NwkKey": "00000000000000000000000000000000"
        }
    }

NOTE: If you want to emulate LoRaWAN 1.0 device, first set JoinEUI equal to AppEUI and set NwkKey equal to AppKey.

ABP

  • Modify device activation information in abp.json. An example: :

    {
        "deveui": "0000000000000000",
        "joineui": "0000000000000000",
        "devaddr": "00000000",
        "appkey": "00000000000000000000000000000000",
        "nwkkey": "00000000000000000000000000000000",
        "nwksenckey": "00000000000000000000000000000000",
        "snwksintkey": "00000000000000000000000000000000",
        "fnwksintkey": "00000000000000000000000000000000",
        "appskey": "00000000000000000000000000000000",
        "fcntup": 0,
        "version": "1.1"
    }
  • Currently, five kinds of message is supported: pull data, join request, rejoin request, confirmed (or unconfirmed) data up (with or without FOpts) and MAC Commands in FRMPayload field:

NOTE: Always remember to mote pull to keep the gateway alive in server.

mote info
mote pull
mote abp
mote join [-n]
mote rejoin 'rejointyp' (0, 1, 2)
mote app 'message' (uplink message, will be encoded by UTF-8) [-auf]
mote mac 'command' (MAC Commands in FRMPayload field)

Here is the example step of interaction with ChirpStack:

mote pull
mote join -n
mote app helloworld -f 0302
mote main.py mac 0302

Contribution

This repo is hosted on https://github.com/houluy/lora-motes-emulator and under MIT license, any contribution or suggestion is welcome. Just open an issue or send a pull request.

lora-mote-emulator's People

Contributors

dependabot[bot] avatar houluy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lora-mote-emulator's Issues

ERROR - [Errno 22] Invalid argument while wotking with LoRiot (mac version 1.0.3)

Hi,
I'm trying to run mote with LoRiot server and I'm getting the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/src/__main__.py", line 113, in main
    gateway.push(udp_client, phypld, mote)
  File "/usr/local/lib/python3.8/site-packages/src/mac.py", line 296, in push
    transmitter.send(self.form_pshdat(data, mote))
  File "/usr/local/lib/python3.8/site-packages/src/network.py", line 17, in send
    self.s.sendto(data, self.target)
OSError: [Errno 22] Invalid argument

Thanks

Chirpstack not returning JoinAccept

I'm running OTAA join requests on Chirpstack. I'm seeing JoinRequest on Chirpstack but never a JoinAccept. Usually this means the App key is incorrect but I'm not seeing this as the case.

My device.json

{
    "Device": {
        "JoinEUI": "ded70e37a48e4289",
        "DevEUI": "ded70e37a48e4289"
    },
    "RootKeys": {
        "AppKey": "1CB94D4B9B5522C11233D2EEFE64D82A",
        "NwkKey": "1CB94D4B9B5522C11233D2EEFE64D82A"
    }
}

My join request:

#mote join  -n
2022-05-25 22:24:26,558 - INFO - Forming a join request message -
NwkKey: 1CB94D4B9B5522C11233D2EEFE64D82A, AppKey: 1CB94D4B9B5522C11233D2EEFE64D82A, AppEUI: ded70e37a48e4289, DevEUI: ded70e37a48e4289, DevNonce: 19, MIC: bad07cea,Final Join Req: 0089428ea4370ed7de89428ea4370ed7de1300bad07cea --

2022-05-25 22:24:26,559 - INFO - Sending a PUSH DATA -
Verson: 02, Token: 5bd6, Identifier: 00, GatewayEUI: 4e7b2799b9bfd427

2022-05-25 22:24:26,560 - INFO - Receiving a PUSH ACK -
Version: 02, Token: 5bd6, Identifier: 01

2022-05-25 22:24:28,563 - INFO - No response is received from remote servers

I'm getting the following error on the app server:

`time="2022-05-25T22:24:27.058915588Z" level=info msg="backend/joinserver: sending response" dev_eui=ded70e37a48e4289 message_type=JoinAns receiver_id=000000 result_code=Success sender_id=ded70e37a48e4289 transaction_id=4008038692

time="2022-05-25T22:24:28.141512925Z" level=warning msg="finished unary call with code FailedPrecondition" ctx_id=a4afba43-49d5-4ffb-a20a-b494c9c17039 error="rpc error: code = FailedPrecondition desc = devaddr does not match, the security-context is out of sync" grpc.code=FailedPrecondition grpc.method=ReEncryptDeviceQueueItems grpc.service=as.ApplicationServerService grpc.start_time="2022-05-25T22:24:28Z" grpc.time_ms=63.609 peer.address="172.24.0.3:40256" span.kind=server system=grpcod

time="2022-05-25T22:24:30.396006389Z" level=warning msg="finished unary call with code FailedPrecondition" ctx_id=40d097b0-4f3b-4905-95b8-8420ffe3b9cf error="rpc error: code = FailedPrecondition desc = devaddr does not match, the security-context is out of sync" grpc.code=FailedPrecondition grpc.method=ReEncryptDeviceQueueItems grpc.service=as.ApplicationServerService grpc.start_time="2022-05-25T22:24:30Z" grpc.time_ms=63.557 peer.address="172.24.0.3:40256" span.kind=server system=grpc
`

Suggestions?

cannot run mote

I cannot run mote. Every time I start mote I get:

2022-05-20 11:55:44,375 - ERROR - Bad config file format, please copy a new file from template.

I use the default generated files in config/ only. I did not make any changes.
As the message is not very informative I hope to hear where to look to debug.

Thanks in advance

Problem at OTAA Join Request

Hi
I have trouble to parse Join Accept. I am tring with Helium Console. OTAA 1.0.2

pi@raspberrypi:~/deneme/lora-mote-emulator $ mote -v 1.0.2 join -n

2023-10-04 03:40:15,727 - INFO - Forming a join request message -
NwkKey: 01010101010101010101010101010101, AppKey: 01010101010101010101010101010101, AppEUI: a100000000000001, DevEUI: a100000000000001, DevNonce: 15, MIC: 3c55be3e,Final Join Req: 0001000000000000a101000000000000a10f003c55be3e --

2023-10-04 03:40:15,728 - INFO - Sending a PUSH DATA -
Verson: 02, Token: 2faf, Identifier: 00, GatewayEUI: aa555a0000000000

2023-10-04 03:40:15,730 - INFO - Receiving a PUSH ACK -
Version: 02, Token: 2faf, Identifier: 01

2023-10-04 03:40:18,033 - ERROR - Bad config file format, please copy a new file from template.

Where i did mistake?

Error while retrieving the device session

Hi,

I can send the Data Push join message and receive and parse its response correctly with correct mic. However, when it tries to save the session I get the following error:

ERROR - can't pickle memoryview objects

This is during self.save() operation.

Syed

OTAA device and join request

Hi,
I'm having some trouble to create an OTAA device and send a join request. Apparently there's only the ABP command available to create ABP compliant device. Can you please help me in this matter. Cheers

Syed

OTAA failed to Join

Hello,

I am trying to use to send data to test the ChirpStack integration from my backend.

I am not able to receive a Join Accept from ChirpStack, the join request packet is received to the ChirpStack side. All the session keys are being generated, I checked them inside the node dashboard.

i am using LoraWan 1.0.2, any suggesstions?

device session error

Hi
I can see the messages getting to the gateway bridge
but i get device-session error: device-session does not exist or invalid fcnt or mic" for when i run this command
python main.py app -m helloworld -f 0302

I have my device set up as
devicesession

Here are my configs i used
abp.txt
config.txt
device.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.