LMIC-node 项目教程

LMIC-node 项目教程

LMIC-nodeLMIC-node | One example to rule them all. LMIC-node is an example LoRaWAN application for a node that can be used with The Things Network. It demonstrates how to send uplink messages, how to receive downlink messages, how to implement a downlink command and it provides useful status information. With LMIC-node it is easy to get a working node quickly up and running. LMIC-node supports many popular (LoRa) development boards out of the box. It uses the Arduino framework, the LMIC LoRaWAN library and PlatformIO.项目地址:https://gitcode.com/gh_mirrors/lm/LMIC-node

项目介绍

LMIC-node 是一个 LoRaWAN 节点的示例应用程序,适用于 The Things Network。它展示了如何发送上行消息、接收下行消息、实现下行命令,并提供了有用的状态信息。使用 LMIC-node,可以快速让一个节点运行起来。LMIC-node 支持许多流行的(LoRa)开发板,使用 Arduino 框架、LMIC LoRaWAN 库和 PlatformIO。

项目快速启动

基本步骤

  1. 选择支持的板子:在 platformio.ini 文件中选择一个支持的开发板。
  2. 选择 LoRaWAN 区域:在 platformio.ini 文件中选择你的 LoRaWAN 区域。
  3. 提供 LoRaWAN 密钥:在 lorawan-keys.h 文件中提供你的节点的 LoRaWAN 密钥。
  4. 编译和上传固件:编译并上传固件,然后就可以开始使用了。

示例代码

[env:your_board]
platform = ststm32
board = your_board
framework = arduino
lib_deps = 
    mcci-catena/MCCI LoRaWAN LMIC library@3.3.0

[platformio]
default_envs = your_board
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

// LoRaWAN 密钥
static const u1_t PROGMEM DEVEUI[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8); }

static const u1_t PROGMEM APPEUI[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8); }

static const u1_t PROGMEM APPKEY[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16); }

static uint8_t mydata[] = "Hello, world!";
static osjob_t sendjob;

const unsigned TX_INTERVAL = 60;

void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    switch(ev) {
        case EV_JOINED:
            Serial.println("EV_JOINED");
            break;
        case EV_TXCOMPLETE:
            Serial.println("EV_TXCOMPLETE (includes waiting for RX windows)");
            if (LMIC.dataLen) {
                // 数据已接收
                Serial.println("Received data");
            }
            // 计划下一次传输
            os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
            break;
        default:
            Serial.println(ev);
            break;
    }
}

void do_send(osjob_t* j) {
    // 检查是否可以发送
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println("OP_TXRXPEND, not sending");
    } else {
        // 发送数据
        LMIC_setTxData2(1, mydata, sizeof(mydata) - 1, 0);
        Serial.println("Packet queued");
    }

LMIC-nodeLMIC-node | One example to rule them all. LMIC-node is an example LoRaWAN application for a node that can be used with The Things Network. It demonstrates how to send uplink messages, how to receive downlink messages, how to implement a downlink command and it provides useful status information. With LMIC-node it is easy to get a working node quickly up and running. LMIC-node supports many popular (LoRa) development boards out of the box. It uses the Arduino framework, the LMIC LoRaWAN library and PlatformIO.项目地址:https://gitcode.com/gh_mirrors/lm/LMIC-node

  • 10
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乔瑗励

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值