Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加配置节点I2C地址功能 #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _locales/en/loRaWANNodeModule-jsdoc-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"LoRaWAN.connectOtaaGateway|param|devType": "Device type",
"LoRaWAN.getData": "Get node data",
"LoRaWAN.getGatewayData": "Get gateway data",
"LoRaWAN.init": "Set node I2C address",
"LoRaWAN.init|param|addr": "I2C address",
"LoRaWAN.initialize": "Initialize module I2C address and configurations",
"LoRaWAN.isConnected": "Check if node successfully joined. Returns true if connected",
"LoRaWAN.sendCommand": "Send commands to query or configure node",
Expand Down
1 change: 1 addition & 0 deletions _locales/en/loRaWANNodeModule-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"LoRaWAN.connectOtaaGateway|block": "Connect Gateway OTAA configuration | Region: $band| APPEUI: $appeui| APPKEY: $appkey| Device Class:$devType",
"LoRaWAN.getData|block": "Obtain node data",
"LoRaWAN.getGatewayData|block": "Obtain Gateway data",
"LoRaWAN.init|block": "Set node I2C address $addr",
"LoRaWAN.initialize|block": "Node initialize",
"LoRaWAN.isConnected|block": "Connect Gateway successfully",
"LoRaWAN.sendData|block": "Send data $data to node address $address",
Expand Down
114 changes: 58 additions & 56 deletions _locales/zh/loRaWANNodeModule-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
{
"LoRaWAN.configNode": "选择节点通信频段和设置节点LoRa地址",
"LoRaWAN.configNode|param|address": "设备地址",
"LoRaWAN.configNode|param|band": "地区选择",
"LoRaWAN.connectAbpGateway": "节点连接网关,选择ABP入网方式,并进行必要的参数配置",
"LoRaWAN.connectAbpGateway|param|appSkey": "应用会话密钥",
"LoRaWAN.connectAbpGateway|param|band": "地区选择",
"LoRaWAN.connectAbpGateway|param|devAddr": "设备地址",
"LoRaWAN.connectAbpGateway|param|devType": "设备类型",
"LoRaWAN.connectAbpGateway|param|nwkSkey": "网络会话密钥",
"LoRaWAN.connectGateway": "开始连接网关,发送入网包给网关",
"LoRaWAN.connectGatewayAdvanced470": "连接470MHz网关高级配置",
"LoRaWAN.connectGatewayAdvanced470|param|adr": "自适应速率",
"LoRaWAN.connectGatewayAdvanced470|param|dr": "通信频率",
"LoRaWAN.connectGatewayAdvanced470|param|eirp": "发射功率",
"LoRaWAN.connectGatewayAdvanced470|param|packetType": "数据包类型",
"LoRaWAN.connectGatewayAdvanced470|param|subband": "通信子频带",
"LoRaWAN.connectGatewayAdvanced868": "连接868MHz网关高级配置",
"LoRaWAN.connectGatewayAdvanced868|param|adr": "自适应速率",
"LoRaWAN.connectGatewayAdvanced868|param|dr": "通信频率",
"LoRaWAN.connectGatewayAdvanced868|param|eirp": "发射功率",
"LoRaWAN.connectGatewayAdvanced868|param|packetType": "数据包类型",
"LoRaWAN.connectGatewayAdvanced868|param|subband": "通信子频带",
"LoRaWAN.connectGatewayAdvanced915": "连接915MHz网关高级配置",
"LoRaWAN.connectGatewayAdvanced915|param|adr": "自适应速率",
"LoRaWAN.connectGatewayAdvanced915|param|dr": "通信频率",
"LoRaWAN.connectGatewayAdvanced915|param|eirp": "发射功率",
"LoRaWAN.connectGatewayAdvanced915|param|packetType": "数据包类型",
"LoRaWAN.connectGatewayAdvanced915|param|subband": "通信子频带",
"LoRaWAN.connectNode": "开始连接节点",
"LoRaWAN.connectNodeAdvanced470": "连接470MHz节点高级配置",
"LoRaWAN.connectNodeAdvanced470|param|eirp": "发射功率",
"LoRaWAN.connectNodeAdvanced470|param|freq": "通信频点",
"LoRaWAN.connectNodeAdvanced470|param|sf": "扩展因子",
"LoRaWAN.connectNodeAdvanced868": "连接868MHz节点高级配置",
"LoRaWAN.connectNodeAdvanced868|param|eirp": "发射功率",
"LoRaWAN.connectNodeAdvanced868|param|freq": "通信频点",
"LoRaWAN.connectNodeAdvanced868|param|sf": "扩展因子",
"LoRaWAN.connectNodeAdvanced915": "连接915MHz节点高级配置",
"LoRaWAN.connectNodeAdvanced915|param|eirp": "发射功率",
"LoRaWAN.connectNodeAdvanced915|param|freq": "通信频点",
"LoRaWAN.connectNodeAdvanced915|param|sf": "扩展因子",
"LoRaWAN.connectOtaaGateway": "节点连接网关,选择OTAA入网方式,并进行必要的参数配置",
"LoRaWAN.connectOtaaGateway|param|appeui": "应用EUI",
"LoRaWAN.connectOtaaGateway|param|appkey": "应用密钥",
"LoRaWAN.connectOtaaGateway|param|band": "地区选择",
"LoRaWAN.connectOtaaGateway|param|devType": "设备类型",
"LoRaWAN.getData": "获取节点数据",
"LoRaWAN.getGatewayData": "获取网关数据",
"LoRaWAN.initialize": "初始化模块的I2C地址以及相关配置",
"LoRaWAN.isConnected": "判断节点是否入网成功。如果返回为真(true),则表示连接网关成功",
"LoRaWAN.sendCommand": "通过发送特定的指令,可以查询节点的配置参数或者设置节点",
"LoRaWAN.sendData": "给特定地址(范围1~255,0是无效地址不能填写)的节点发送数据",
"LoRaWAN.sendData|param|address": "设备地址",
"LoRaWAN.sendData|param|data": "发送的数据",
"LoRaWAN.sendGatewayData": "给网关发送数据",
"LoRaWAN.sendGatewayData|param|data": "数据"
"LoRaWAN.configNode": "选择节点通信频段和设置节点LoRa地址",
"LoRaWAN.configNode|param|address": "设备地址",
"LoRaWAN.configNode|param|band": "地区选择",
"LoRaWAN.connectAbpGateway": "节点连接网关,选择ABP入网方式,并进行必要的参数配置",
"LoRaWAN.connectAbpGateway|param|appSkey": "应用会话密钥",
"LoRaWAN.connectAbpGateway|param|band": "地区选择",
"LoRaWAN.connectAbpGateway|param|devAddr": "设备地址",
"LoRaWAN.connectAbpGateway|param|devType": "设备类型",
"LoRaWAN.connectAbpGateway|param|nwkSkey": "网络会话密钥",
"LoRaWAN.connectGateway": "开始连接网关,发送入网包给网关",
"LoRaWAN.connectGatewayAdvanced470": "连接470MHz网关高级配置",
"LoRaWAN.connectGatewayAdvanced470|param|adr": "自适应速率",
"LoRaWAN.connectGatewayAdvanced470|param|dr": "通信频率",
"LoRaWAN.connectGatewayAdvanced470|param|eirp": "发射功率",
"LoRaWAN.connectGatewayAdvanced470|param|packetType": "数据包类型",
"LoRaWAN.connectGatewayAdvanced470|param|subband": "通信子频带",
"LoRaWAN.connectGatewayAdvanced868": "连接868MHz网关高级配置",
"LoRaWAN.connectGatewayAdvanced868|param|adr": "自适应速率",
"LoRaWAN.connectGatewayAdvanced868|param|dr": "通信频率",
"LoRaWAN.connectGatewayAdvanced868|param|eirp": "发射功率",
"LoRaWAN.connectGatewayAdvanced868|param|packetType": "数据包类型",
"LoRaWAN.connectGatewayAdvanced868|param|subband": "通信子频带",
"LoRaWAN.connectGatewayAdvanced915": "连接915MHz网关高级配置",
"LoRaWAN.connectGatewayAdvanced915|param|adr": "自适应速率",
"LoRaWAN.connectGatewayAdvanced915|param|dr": "通信频率",
"LoRaWAN.connectGatewayAdvanced915|param|eirp": "发射功率",
"LoRaWAN.connectGatewayAdvanced915|param|packetType": "数据包类型",
"LoRaWAN.connectGatewayAdvanced915|param|subband": "通信子频带",
"LoRaWAN.connectNode": "开始连接节点",
"LoRaWAN.connectNodeAdvanced470": "连接470MHz节点高级配置",
"LoRaWAN.connectNodeAdvanced470|param|eirp": "发射功率",
"LoRaWAN.connectNodeAdvanced470|param|freq": "通信频点",
"LoRaWAN.connectNodeAdvanced470|param|sf": "扩展因子",
"LoRaWAN.connectNodeAdvanced868": "连接868MHz节点高级配置",
"LoRaWAN.connectNodeAdvanced868|param|eirp": "发射功率",
"LoRaWAN.connectNodeAdvanced868|param|freq": "通信频点",
"LoRaWAN.connectNodeAdvanced868|param|sf": "扩展因子",
"LoRaWAN.connectNodeAdvanced915": "连接915MHz节点高级配置",
"LoRaWAN.connectNodeAdvanced915|param|eirp": "发射功率",
"LoRaWAN.connectNodeAdvanced915|param|freq": "通信频点",
"LoRaWAN.connectNodeAdvanced915|param|sf": "扩展因子",
"LoRaWAN.connectOtaaGateway": "节点连接网关,选择OTAA入网方式,并进行必要的参数配置",
"LoRaWAN.connectOtaaGateway|param|appeui": "应用EUI",
"LoRaWAN.connectOtaaGateway|param|appkey": "应用密钥",
"LoRaWAN.connectOtaaGateway|param|band": "地区选择",
"LoRaWAN.connectOtaaGateway|param|devType": "设备类型",
"LoRaWAN.getData": "获取节点数据",
"LoRaWAN.getGatewayData": "获取网关数据",
"LoRaWAN.init": "配置节点I2C地址",
"LoRaWAN.init|param|addr": "I2C地址",
"LoRaWAN.initialize": "初始化模块的I2C地址以及相关配置",
"LoRaWAN.isConnected": "判断节点是否入网成功。如果返回为真(true),则表示连接网关成功",
"LoRaWAN.sendCommand": "通过发送特定的指令,可以查询节点的配置参数或者设置节点",
"LoRaWAN.sendData": "给特定地址(范围1~255,0是无效地址不能填写)的节点发送数据",
"LoRaWAN.sendData|param|address": "设备地址",
"LoRaWAN.sendData|param|data": "发送的数据",
"LoRaWAN.sendGatewayData": "给网关发送数据",
"LoRaWAN.sendGatewayData|param|data": "数据"
}
1 change: 1 addition & 0 deletions _locales/zh/loRaWANNodeModule-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"LoRaWAN.connectOtaaGateway|block": "连接网关OTAA配置 | 地区选择: $band| APPEUI: $appeui| APPKEY: $appkey| 设备类型:$devType",
"LoRaWAN.getData|block": "获取节点数据",
"LoRaWAN.getGatewayData|block": "获取网关数据",
"LoRaWAN.init|block": "配置节点I2C地址 $addr",
"LoRaWAN.initialize|block": "节点初始化",
"LoRaWAN.isConnected|block": "连接网关成功",
"LoRaWAN.sendData|block": "给节点地址 $address 发送数据 $data",
Expand Down
19 changes: 18 additions & 1 deletion loRaWANNodeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,25 @@ enum LoRaCommand {
//% color="#FFD43B" icon="\uf09e"
//% groups=['CONNECT_NODE', 'CONNECT_GATEWAY']
namespace LoRaWAN {
let _I2CAddr = 32;
let _deviceAddr = 0;
let _deviceClass = LoRaDevType.CLASS_A;

/**
* Initialize module I2C address
* @param address is i2c address, eg: 32
*/
//% blockId=lorawan_init
//% block="Set node I2C address $addr"
//% addr.defl="32"
//% weight=190
//% group="CONNECT_NODE"
export function init(addr: number): void{
_I2CAddr = addr;
}

/**
* Initialize module I2C address and configurations
* Initialize module
*/
//% blockId=lorawan_initialize
//% block="Node initialize"
Expand Down
5 changes: 1 addition & 4 deletions main.blocks
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="pxt-on-start"></block>
<block type="device_forever"></block>
</xml>
<xml xmlns="https://developers.google.com/blockly/xml"><variables></variables><block type="device_forever" id="bB]LE|#Y%pt52-N3Ff8|" x="186" y="-106"></block><block type="pxt-on-start" id="*oNkQ%0Teb`eMO%j2M6G" x="0" y="0"><statement name="HANDLER"><block type="lorawan_init" id="G/T?SHu2tv%#Nxm`xuWY"><value name="addr"><shadow type="math_number" id="SMR,dd_*H)4q7t3TBs[l"><field name="NUM">32</field></shadow></value></block></statement></block></xml>
5 changes: 4 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@

LoRaWAN.init(32)
basic.forever(function () {

})
20 changes: 18 additions & 2 deletions pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dependencies": {
"core": "*",
"radio": "*",
"microphone": "*"
"microphone": "*",
"OLED12864_I2C": "github:makecode-extensions/oled12864_i2c#v1.5.0"
},
"files": [
"README.md",
Expand All @@ -22,8 +23,23 @@
"test.ts"
],
"public": true,
"targetVersions": {
"target": "7.0.51",
"targetId": "microbit"
},
"supportedTargets": [
"microbit"
],
"preferredEditor": "blocksprj"
"preferredEditor": "tsprj",
"yotta": {
"config": {
"microbit-dal": {
"bluetooth": {
"open": 1,
"whitelist": 0,
"security_level": null
}
}
}
}
}