1
电子说
本项目是ESP32+SX1302,做成LoRaWAN 多通道GW,支持packet-forward
开发环境
1.烧录程序时接这个口,ESP32烧程序是先让设备进入烧录模式(先按住BOOT0按键,然后按下EN按键,此时ESP32重启,进入烧录模式,然后松开BOOT0按键,ESP32停留在烧录模式)
Note:
1.下载flash_download_tool_3.9.6_2
2.选择芯片和下载方式
3.配置下载地址和bin文件,点击start开始下载
设备上电会进入AP模式
设备内置一个web端,可用于对设备进行配置
设备首次上电WIFI会进入AP模块,AP模式下设备配置如下
# AP模式下WIFI配置
SSID:LoRaGW-xxxxxx
password:loragwwifi
xxxxxx为SN的后6位
WEB端地址:192.168.4.1
用户需要再配置网关的区域、频点、网关ID、packet-forward转发地址,网关ID默认会根据MAC地址自动生成,可以不用修改
网关的频点是通过修改radio0和radio1来实现的,8个频点和radio0,radio1的映射,不同地区会不一样
CN470(通常radio0与radio1相差800KHZ,默认radio=470600000Hz,radio1=471400000Hz)
freq0 = RADIO0-300KHz,默认为470.3MHz
freq1 = RADIO0-100KHz,默认为470.5MHz
freq2 = RADIO0+100KHz,默认为470.7MHz
freq3 = RADIO0+300KHz,默认为470.9MHz
freq4 = RADIO1-300KHz,默认为471.1MHz
freq5 = RADIO1-100KHz,默认为471.3MHz
freq6 = RADIO1+100KHz,默认为471.5MHz
freq7 = RADIO1+300KHz,默认为471.7MHz
EU868(默认radio=867500000Hz,radio1=868500000Hz)
freq0 = RADIO1-400KHz 默认为868.1MHz
freq1 = RADIO1-200KHz 默认为868.3MHz
freq2 = RADIO1 默认为868.5MHz
freq3 = RADIO0-400KHz 默认为867.1MHz
freq4 = RADIO0-200KHz 默认为867.3MHz
freq5 = RADIO0 默认为867.5MHz
freq6 = RADIO0+200KHz 默认为867.7MHz
freq7 = RADIO0+400KHz 默认为867.9MHz
US915(默认radio=904300000Hz,radio1=905000000Hz) //US915_1
freq0 = RADIO0-400KHz 默认为903.9MHz
freq1 = RADIO0-200KHz 默认为904.1MHz
freq2 = RADIO0 默认为904.3MHz
freq3 = RADIO0+200KHz 默认为904.5MHz
freq4 = RADIO1-300KHz 默认为904.7MHz
freq5 = RADIO1-100KHz 默认为904.9MHz
freq6 = RADIO1+100KHz 默认为905.1MHz
freq7 = RADIO1+300KHz 默认为905.3MHz
chan_LoRa_Std = radio0+300Khz,默认为904.6MHz
设备支持命令行进行配置,请使用putty或XSHELL进行
ESXP1302_GW >
ESXP1302_GW > help
pkt_fwd [-h] [--restore] [--host=< UDP Host >] [--port=< UDP Port >] [--gwid=< gateway id >]
ESP32 packet forwarder based on sx1302_hal
--restore clean NVS config
-h, --help print help
--host=< UDP Host > UDP Host
--port=< UDP Port > UDP Port
--gwid=< gateway id > Gateway Id
ifconfig
printf network status
reboot
reboot the system
help [< string >]
Print the summary of all registered commands if no arguments are given,
otherwise print summary of given command.
< string > Name of command
如上,可通过设备pkt_fwd命令进行设置
ESXP1302_GW >
ESXP1302_GW > ifconfig
=========ifconfig===========
--------if:ppp prio:20--------
link: NET_UP
ip: 10.145.122.176
mask: 255.255.255.255
gw: 10.64.64.64
dns1: 218.85.157.99
dns2: 218.85.157.99
IMEI: 860761079936981
IMSI: 460115210945489
ICCID: 89860322245923849833
CSQ/BER: 23/0
--------if:eth prio:50--------
link: LINK_DOWN/NET_DOWN
MAC: 66:e8:33:49:ba:47
ip: 0.0.0.0
mask: 0.0.0.0
gw: 0.0.0.0
dns1: 218.85.157.99
dns2: 218.85.157.99
--------if:ap prio:10--------
MAC: 64:e8:33:49:ba:45
ip: 192.168.4.1
ssid: esp32
pswd: esp32wifi
=========ifconfig end===========
测试用NS,域名:lora.ansitw.com,IP:106.52.124.231
WEB端地址:106.52.124.231:8080
包转发地址:
test_hal_tx -r 1250 -f 506.5 -s 12 --pwid 22 -n 10
-r:指定射频前端芯片为1250
-f:发送的频点(MHz)
-s:SF
–pwid 22:
test_hal_rx -r 1250 -a 475.5 -b 476.5
配置通道通过MQTT进行数据交互,其中设备发往服务器的通道称为上行通道,服务器发往设备的通道称为下行通道
其中:
例如网关的SN:64e833fffe5909d8,那么上下行通道分别为
网关会周期性地通过上行通道发送周期心跳包
服务器也可以通过下行通道,向网关下发数据
{
"pkt": "periodUplink",
"GWInfo": {
"SN": "64e833fffe5909d8",
"SoftwareVersion": "V1.0.1",
"HardwareVersion": "V1.0.0"
},
"Staus": {
"GPSValid": true,
"Latitude": 24.000000,
"Longitude": 120.000000,
"Altitude": 0.000000,
"Cellular": {},
"Ethernet": {},
"WIFI": {
"Link": "NET_UP",
"IPMode": "DHCP",
"MAC": "64:e8:33:59:09:d8",
"IP": "192.169.4.12",
"Mask": "255.255.255.0",
"GW": "192.169.4.1",
"DNS1": "192.169.4.1",
"DNS2": "192.169.4.1"
}
},
"Configuration": {
"STA": {
"Enable": false,
"SSID": "",
"Password": ""
},
"Management": {
"MQTT": {
"Enable": true,
"URL": "mqtt://broker.emqx.io",
"ClientID": "64e833fffe5909d8",
"UplinkTopic": "up/gw/64e833fffe5909d8/0",
"DownlinkTopic": "dn/gw/64e833fffe5909d8/0"
}
},
"LoRaWAN": {
"Region": "cn470",
"Radio0": "470600000",
"Radio1": "enable",
"NsHost": "lora.ansitw.com",
"NsPort": "1700",
"GatewayID": "64e833fffe5909d8"
}
}
}
直接修改Configuration中的内容,下发下来即可
{
"pkt": "downlink",
"Configuration": {
"STA": {
"Enable": false,
"SSID": "",
"Password": ""
},
"Management": {
"MQTT": {
"Enable": true,
"URL": "mqtt://broker.emqx.io",
"ClientID": "64e833fffe5909d8",
"UplinkTopic": "up/gw/64e833fffe5909d8/0",
"DownlinkTopic": "dn/gw/64e833fffe5909d8/0"
}
},
"LoRaWAN": {
"Region": "cn470",
"Radio0": "470600000",
"Radio1": "enable",
"NsHost": "lora.ansitw.com",
"NsPort": "1700",
"GatewayID": "64e833fffe5909d8"
}
}
}
回复:
{
"pkt": "downlinkRespone",
“result”:"success"
}
重启
{
"pkt": "downlink",
"cmd": {
"reboot": true
}
}
回复
{
"pkt": "downlinkRespone",
“result”:"success"
}
升级
{
"pkt": "downlink",
"cmd": {
"upgrade": "http://192.169.4.53/esp32_sx1302.bin"
}
}
回复(收到升级命令)
{
"pkt": "downlinkRespone",
“result”:"success"
}
配置通道通过MQTT进行数据交互,网关发送数据给云平台称为uplink,云平台发送命令给网关称为downlink
有两条链路:
审核编辑 黄宇
全部0条评论
快来发表一下你的评论吧 !