32 Commits

Author SHA1 Message Date
YuanHongbin aca260ba54 fix: boot升级后擦除外Flash防参数偏移,修复8项Bug
新增APP_BOOT_UPGRADE_FLAG标记,boot升级后APP启动时检测并擦除外部Flash避免参数偏移。修复: CatSendErrCnt清零、Mac索引、时间同步指针、HIS_DATA break、Ch2校准标志、RS485离线通知格式、LoraSetFreqCent参数。
2026-07-14 17:25:08 +08:00
YuanHongbin 4e45de919c feat(sensor): 新增Lora信号质量查询指令(0x09)及多项Bug修复
新增 COMM_UNIT_CMD_GET_SIGNAL(0x09): 传感器可查询与网关的Lora信号质量,无需注册,回应SNR/RSSI各1字节,回应后打印日志并刷新CommErrCnt/在线状态。CommUnitCmdSend对GET_SIGNAL豁免注册检查。culs命令新增传感器在线状态显示。Bug修复: CatSendErrCnt清零、Mac索引修正、时间同步指针修正、HIS_DATA break补全、Ch2校准标志修正、RS485离线通知格式修正、LoraSetFreqCent参数修正
2026-07-14 10:13:25 +08:00
YuanHongbin 38b9663320 refactor(eth): 删除ETH参数配置/显示及枚举结构体,保留基本通讯功能
- 删除 EthIpMode_m/EthWorkMode_m 枚举,EthNetPara_t 改用 uint8_t

- 删除 ETHApplyNetPara() 函数及其调用

- 删除 main.c 中 ETH 默认参数初始化

- 删除 DebugCmdEthNet CLI配置命令

- 删除 DebugCmdGetPara 中 ETH 参数显示

- 保留 ETHTriggerRegister/EthLoopHandler 等基本通讯
2026-07-13 15:51:49 +08:00
YuanHongbin 95a0ecda5b chore: 将子模块(FatFS/GateWay_Debug/SDCard/sx127x)转为普通目录,纳入主仓库管理 2026-07-13 12:07:19 +08:00
YuanHongbin b75df5e0fc fix(cat1/eth): 修复通信模块重连后SvrRegFlag未清零导致跳过注册的问题 2026-06-25 17:23:02 +08:00
YuanHongbin c8986a8074 chore: 更新子模块指针到最新提交 2026-06-22 11:41:32 +08:00
YuanHongbin 74a0193e3d chore: 清理废弃模块代码 2026-06-22 10:11:33 +08:00
YuanHongbin a87bc24b01 chore: 更新 Gateway_Debug 子模块到最新提交 2026-06-17 17:47:38 +08:00
YuanHongbin 1f255cb3ef fix(eth): 修复EthNet模块参数配置和调试命令问题 2026-06-17 17:46:33 +08:00
YuanHongbin 2a7c8e4b3b chore: 更新 Gateway_Debug 子模块到最新提交 2026-06-17 12:33:11 +08:00
YuanHongbin dd8018e9bb feat(eth): 完善YOXO1007以太网模块配置和调试命令 2026-06-17 12:30:57 +08:00
YuanHongbin 626a486945 feat(debug): 新增 up 上传网关状态和 reg 重新注册命令 2026-06-15 18:56:53 +08:00
YuanHongbin 8052721c21 chore: 更新 Gateway_Debug 子模块的提交哈希
将子模块 Gateway_Debug 从 7e55f4c 更新到 765fe78
2026-06-15 15:18:46 +08:00
YuanHongbin 44e679182d fix: 修复以太网控制逻辑,调整硬件版本引脚映射
1. 移除main.h中的软硬件版本宏定义,移至bsp.h
2. 新增ETHStop和ETHReset对外接口并实现对应逻辑
3. 注释掉原有的ETH硬件复位延时流程
4. 根据硬件版本适配ETH和CAT1的引脚控制逻辑
5. 清理冗余的CAT1电源引脚宏定义
2026-06-15 15:11:23 +08:00
YuanHongbin 21cb23d0b9 refactor(rs485): 拆分通讯单元参数和数据结构体
调整RS485配置结构体,将原CUData拆分为CUPara和CUData,修正多处引用的字段名,同时修复CommUnitAnalyze中的数据拷贝偏移和包长度计算错误
2026-06-12 18:14:43 +08:00
YuanHongbin 030c22472d refactor(GateWay): 重构ETH通信状态机并调整测试配置
1.  将MAC_ADDR_TYPE从9改为0,使用测试MAC地址配置
2.  移除硬编码的服务器地址和端口默认值
3.  新增ETH状态机管理,完善链路检测、重连和收发逻辑
4.  添加一系列ETH通信超时、重试相关的宏定义
5.  新增调试观察窗口配置
2026-06-11 19:17:31 +08:00
YuanHongbin d05345afb7 1、位移监测传感器上传参数修改
2、CatOneTask兼容新版4G模块
3、完善传感器类型SensorType_m结构
2026-06-05 11:08:54 +08:00
YuanHongbin 7103c8ddfb 1、增加ExclCommUint_t结构体,用于排除指定通讯单元的MAC
2、修复了复位后重复定义各项参数的bug。只有从flash读取到的出厂标志位错误时,才会进入配置默认参数判断,否则会以从flash读取到的数据为配置参数
3、增加CheckCommUnitExcl函数,用于查询mac是否被排除

GateWay_Debug:
1、rs485配置函数增加了boot升级使能功能
2、增加了excu、exdel、exls命令,用于配置排除设备的增、删、查
3、para命令增加显示LpCfg参数

sx127x:
1、lora通道选择取消,通过修改频率来修改通道
2026-05-21 17:30:35 +08:00
YuanHongbin 37d8152227 Debug文件修改仓库命名 2026-05-15 16:04:13 +08:00
YuanHongbin 3eb57965a5 修复了修改服务器ip和端口无提示信息的bug 2026-05-15 15:29:10 +08:00
YuanHongbin 55a82c6a50 添加位移监测传感器结构体及解包 2026-05-15 15:15:42 +08:00
YuanHongbin 942275328c SDCard文件修改为子模块方式 2026-05-15 13:52:02 +08:00
YuanHongbin cdc0c59a3f 1、删除AD7924目录文件
2、删除SDCard目录文件
3、删除SHT20目录文件
2026-05-15 13:46:05 +08:00
YuanHongbin 9bb3309b30 FatFS文件修改为子模块方式 2026-05-15 13:41:56 +08:00
YuanHongbin b93dda47ab 删除FatFS目录文件 2026-05-15 13:38:30 +08:00
YuanHongbin 72cf076b31 sx127x文件修改为子模块方式 2026-05-15 13:30:54 +08:00
YuanHongbin 28ef3921a1 删除SX127x目录文件 2026-05-15 13:28:35 +08:00
YuanHongbin 5383c83937 DebugCmd文件修改为子模块方式 2026-05-14 17:54:04 +08:00
YuanHongbin 2bf447ce1c DebugCmd文件修改为子模块方式 2026-05-14 10:37:06 +08:00
YuanHongbin aa5548d70e SpiFlash全片擦除时喂狗 2026-05-12 18:29:33 +08:00
YuanHongbin 0986af5968 调试 2026-05-12 16:39:58 +08:00
YuanHongbin a3198e56a9 1、public.h文件的结构体增加字节对齐
2、GATEMEY_PARA_SAV_ADDR扇区内存增加到两个扇区,日志扇区起始地址后移
3、spiflash写入函数中,跨扇区判断函数释放,用于修复网关参数存储扩容后的跨扇区读写
2026-04-28 15:11:44 +08:00
46 changed files with 2127 additions and 1417 deletions
View File
@@ -0,0 +1,88 @@
---
name: add-debug-command
description: 在 GateWay_Debug 模块中添加新的 Debug 调试命令(函数指针表 + 字符串匹配模式)
source: auto-skill
extracted_at: '2026-06-15T08:10:31.194Z'
---
# 添加 Debug 调试命令
本项目的 Debug 命令系统位于 `Project/GateWay/source/Module/GateWay_Debug/DebugCmd.c`,采用**函数指针表 + 字符串匹配**模式。
## 修改步骤
### 1. 编写 handler 函数
`DebugCmd.c` 中添加函数,签名固定为 `void FuncName(int argc, char *argv[])`
```c
static void DebugCmdXxx(int argc, char *argv[])
{
DBG_LOG("\r\n");
if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: xxx\r\n");
DBG_LOG(" brief --> 功能描述.\r\n\r\n");
return;
}
// 实际逻辑...
}
```
**必须遵循的模式:**
- 函数体第一行:`DBG_LOG("\r\n");`
- `"?"` 帮助分支:打印命令名和 brief 说明
- 若修改了 `ConfigPara`,调用 `WritePara()` 保存
- 需要被外部引用时声明为 `void`,仅内部使用时声明为 `static void`
### 2. 注册到命令表
在文件末尾的 `DebugFun[]` 常量数组中添加一行:
```c
const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
// ... 已有命令 ...
"xxx", DebugCmdXxx,
};
```
**容量限制:** `DEBUG_CMD_CNT = 30`,添加前检查剩余空位(当前使用 28/30)。若超出需增大该宏。
### 3. 添加到 help 输出
`DebugCmdHelp` 函数末尾添加:
```c
len = strlen("xxx ?\r\n");
memcpy(Data, "xxx ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
```
## 可用的关键 API
| 函数 | 头文件 | 用途 |
|---|---|---|
| `CatOneEthSendQueue(data, len)` | CatOneTask.h | 将载荷放入网络发送队列(需 `SvrRegFlag == true` |
| `CommUintOrgData(GateWay, CUPara, CUData, buf)` | Public.h | 组装通讯单元传感器数据包 |
| `GateWayRegister(TxBuff)` | CatOneTask.h | 组装网关注册包,返回长度 |
| `NetCommOrgData(GateWay, payload, outBuf)` | Public.h | 为载荷添加网络帧头(0x7A)+MAC+CRC |
| `WritePara(data, len)` | (bsp) | 保存配置参数到 Flash |
| `CatOneTriggerRegister()` | CatOneTask.h | 将 Cat1 状态机立即切换到注册状态 |
| `ETHTriggerRegister()` | CatOneTask.h | 将以太网状态机立即切换到注册状态 |
## 可用的全局/extern 变量
| 变量 | 类型 | 来源 |
|---|---|---|
| `GateWay` | `static GateWayPara` | DebugCmd.c 内静态指针,指向网关参数 |
| `SComm1Para` / `SComm2Para` | `SensorCommPara_t` | RS485Task.c 中定义,DebugCmd.c 已 extern |
| `GateWay->SvrRegFlag` | `bool` | 服务器注册状态 |
| `GateWay->ConfigPara` | `GWConfigPara_t` | 网关配置参数 |
## 注意事项
- `CatOne_t CatOne``CatOneEthTxBuff[]` 均为 CatOneTask.c 中的 **static** 变量,不能直接在 DebugCmd.c 中访问;应使用封装好的接口函数(如 `CatOneTriggerRegister()``ETHTriggerRegister()`)来操作状态机
- 重新注册应:清 `GateWay->SvrRegFlag = false`,然后根据通信模式调用 `CatOneTriggerRegister()``ETHTriggerRegister()` 立即切换状态机到注册状态,而不是仅清标志位等待状态机自动检测
- `CatOneEthSendQueue` 内部检查 `SvrRegFlag`,未注册时返回 `false`
- 命令解析函数 `DebugAnalyze``" "` 分割参数,去除 `\r`,最多 10 个参数
- `DEBUG_CMD_CNT = 30` 为命令容量上限,添加新命令前需检查当前使用量,若超出需将此宏增大(如改为31)
- 若模块需要保存独立的配置参数(如YOXO1007网络参数),可在DebugCmd.c中定义static变量,并通过Flash读写函数持久化(参考`EthNetPara_t``WriteEthNetPara`的实现)
@@ -0,0 +1,57 @@
---
name: fix-yoxo1007-receive-data
description: 修复YOXO1007以太网模块接收数据解析错误问题
source: auto-skill
extracted_at: '2026-06-17T04:30:00.000Z'
---
# 修复 YOXO1007 以太网模块接收数据解析错误
## 问题现象
服务器已收到网关注册请求并响应,但网关端无法接收/解析服务器返回的数据。
## 根本原因
YOXO1007 模块在**透传模式**下发送的是**原始二进制数据**,不是 ASCII 格式的 hex 字符串。
原代码错误地使用了 `AsciiToHex` 函数进行格式转换:
```c
// 错误代码 - CATONE 模式使用的 ASCII 转换不适用于 ETH 透传模式
memset(HexData, 0x00, CatOneEthRxLen / 2);
uint8_t ret = AsciiToHex(RxBuffTemp, HexData, CatOneEthRxLen);
if(ret > 0)
GateWay->SvrRevCallBack(GateWay, HexData, ret);
```
这导致服务器返回的二进制数据被错误解析,回调函数无法正确处理。
## 修复方案
修改 `CatOneTask.c` 中 ETH 接收线程的数据处理逻辑,直接传递原始二进制数据:
```c
// 修改后的正确代码
CAT1_DBG_LOG("Eth Rev: len=%d\r\n", CatOneEthRxLen);
/* YOXO1007模块在透传模式下发送原始二进制数据,直接传递 */
if(CatOneEthRxLen > 0)
GateWay->SvrRevCallBack(GateWay, (uint8_t *)CatOneEthRxBuff, CatOneEthRxLen);
```
## 修改位置
`Project/GateWay/source/User/Src/CatOneTask.c` 中的 `CatOneRev_Thread_Entry` 函数内的 ETH 分支。
## 关键区别
| 模式 | 数据格式 | 解析方式 |
|------|----------|----------|
| CAT1 (4G) | ASCII 字符串 (AT 命令/响应) | 需要 AsciiToHex 转换 |
| ETH (YOXO1007) | 原始二进制 (透传模式) | 直接传递,不转换 |
## 注意事项
- 此修改仅影响 ETH 通信模式,CAT1 模式的 ASCII 解析逻辑保持不变
- YOXO1007 模块配置参数使用二进制命令协议(识别流 ED F2 A3 56...),与数据透传是不同层面
- 模块配置保存后重启会自动进入之前保存的工作模式,无需额外进入透传模式的命令
@@ -0,0 +1,79 @@
---
name: git-branch-cleanup
description: 批量删除/重命名本地和远端 Git 分支,并同步远端仓库结构(含中文分支名、upstream 修复)
source: auto-skill
extracted_at: '2026-06-17T10:06:37.947Z'
---
# Git 分支批量清理与重命名
## 适用场景
需要删除多余的本地/远端分支、将分支重命名、并让远端结构与本地保持一致。
## 操作流程
### 1. 切换到安全分支
```bash
# 先 stash 未提交的更改
git stash --include-untracked
# 如果有 untracked 文件冲突,使用 -f 强制切换
git checkout -f master
```
> **坑点**:中文分支名之间的文件差异可能产生大量 untracked 冲突(如 FatFS 文档等),
> `git checkout` 会拒绝切换,需要 `-f` 强制切换,之后 `git stash pop` 恢复。
### 2. 删除本地分支
```bash
git branch -D "LAN口通讯"
git branch -D "新版4G模块1"
```
### 3. 重命名本地分支
```bash
git branch -m "旧版4G模块" develop
```
### 4. 删除远端分支(每个远端都要操作)
```bash
# 一次性删除多个远端分支
git push home --delete "LAN口通讯" "新版4G模块" "旧版4G模块"
git push origin --delete "LAN口通讯" "新版4G模块" "旧版4G模块"
```
> **注意**:远端可能认证失败(如内网地址不可达),先确认网络可达再操作。
> 远端分支名可能与本地不完全一致(本地有 `新版4G模块1`,远端只有 `新版4G模块`)。
### 5. 强制推送重命名后的分支到远端
```bash
git push home develop --force
git push origin develop --force
```
### 6. 修复上游跟踪分支
重命名后,分支仍跟踪旧的远端名(如 `origin/旧版4G模块`,已不存在):
```bash
git branch --set-upstream-to=origin/develop develop
```
### 7. 恢复工作内容并切回开发分支
```bash
git checkout develop
git stash pop
```
### 8. 验证最终结构
```bash
git fetch --all --prune
git branch -a
```
## 常见问题
| 问题 | 解决方案 |
|------|----------|
| checkout 报 untracked files 冲突 | `git checkout -f <branch>` |
| 远端认证失败 | 检查网络/VPN,确认远端地址可达 |
| 重命名后 upstream 指向已删除的远端分支 | `git branch --set-upstream-to=origin/<new-name> <branch>` |
| 中文分支名在命令行中需加引号 | `git branch -D "旧版4G模块"` |
+314
View File
@@ -0,0 +1,314 @@
$PACKAGES
bq25306rter ! bq25306rter ! '{Value}' ; U2
c0402m ! c0402m ! 100nF ; C9 C28 C41
c0402m ! c0402m ! 100pF ; C11 C42 C43
c0402m ! c0402m ! 10nF ; C10
c0402m ! c0402m ! 33pF ; C29 C30 C31 C32
C0603 ! C0603 ! '2.2uF' ; C59 C60 C68
C0603 ! C0603 ! '4.7uF' ; C65
C0603 ! C0603 ! 100nF ; C1 C3 C5 C15 C16 C19 C21 C23 C25 C26 C34 C36 C38 C40 ,
C44 C46 C48 C50 C52 C53 C54 C56 C61 C63 C64 C66 C70 C71 C76 C78 C79 ,
C80 C83 C84 C85 C86
C0603 ! C0603 ! 10uF ; C27 C55 C57 C62
C0603 ! C0603 ! 15pF ; C73 C77
C0603 ! C0603 ! 1uF ; C69 C72 C75
C0603 ! C0603 ! 22pF ; C67 C74 C81 C82
C0603 ! C0603 ! 22uF ; C58
C0603 ! C0603 ! 470pF ; C17
C0603 ! C0603 ! 47nF ; C4
C0805 ! C0805 ! '2.2uF' ; C13
C0805 ! C0805 ! 10nF ; C24
C0805 ! C0805 ! 22uF ; C2 C8 C12 C18 C20 C33 C35 C39 C45 C47 C49 C51
C1206 ! C1206 ! 22uF ; C14 C37
CAP-SMD_BD6.3-L6.6-W6.6-FD ! CAP-SMD_BD6.3-L6.6-W6.6-FD ! 470uF ; C6 C7
CAP-SMD_BD6.3-L6.6-W6.6-LS7.3-FD ! CAP-SMD_BD6.3-L6.6-W6.6-LS7.3-FD ! 220uF ; ,
C22
CONN-TH_2P-P2.50_HX25003-2A ! CONN-TH_2P-P2.50_HX25003-2A ! '{Value}' ; CN1
CONN-TH_2P-P3.81_L7.4-W7.6 ! CONN-TH_2P-P3.81_L7.4-W7.6 ! '{Value}' ; U1 U9 ,
U11 U13 U15
,
CONN-TH_3P-P2.00_HCTL_PH-3A_C2908624 ! CONN-TH_3P-P2.00_HCTL_PH-3A_C2908624 ! '{Value}' ,
; CN3
CONN-TH_4P-P2.00_PH-4A_C2908625 ! CONN-TH_4P-P2.00_PH-4A_C2908625 ! '{Value}' ,
; H4
,
CONN-TH_7P-P1.25_HCTL_HC-1.25-7A ! CONN-TH_7P-P1.25_HCTL_HC-1.25-7A ! '{Value}' ,
; CN2
CONN-TH_PH-2A_C2908623 ! CONN-TH_PH-2A_C2908623 ! '{Value}' ; H1
CRYSTAL-SMD_4P-L3.2-W2.5-BL-2 ! CRYSTAL-SMD_4P-L3.2-W2.5-BL-2 ! '{Value}' ; ,
U21
DO-214AC_L4.3-W2.4-LS4.7-RD ! DO-214AC_L4.3-W2.4-LS4.7-RD ! '{Value}' ; D1
E32-400M30S ! E32-400M30S ! '{Value}' ; U12
,
ESOP-8_L4.9-W3.9-P1.27-LS6.0-TL-EP ! ESOP-8_L4.9-W3.9-P1.27-LS6.0-TL-EP ! '{Value}' ,
; U4
FC-135R_L3.2-W1.5 ! FC-135R_L3.2-W1.5 ! '32.768kHz' ; X1
HDR-TH_2P-P2.54-V-M ! HDR-TH_2P-P2.54-V-M ! '{Value}' ; H5
HDR-TH_3P-P2.54-V-M ! HDR-TH_3P-P2.54-V-M ! '{Value}' ; H2 H3
IND-SMD_L2.5-W2.0_AHP252010TF ! IND-SMD_L2.5-W2.0_AHP252010TF ! 10uH ; L2 L4
IND-SMD_L4.8-W4.5 ! IND-SMD_L4.8-W4.5 ! '2.2uH' ; L1
IND-SMD_L7.0-W6.6_FXL0630 ! IND-SMD_L7.0-W6.6_FXL0630 ! 15uH ; L3 L5
IPEX-SMD_BWIPX-1-001E ! IPEX-SMD_BWIPX-1-001E ! '{Value}' ; RF1
L0603 ! L0603 ! '{Value}' ; L6
LED0603-FD_BLUE ! LED0603-FD_BLUE ! '{Value}' ; LORA
LED0603-RD ! LED0603-RD ! '{Value}' ; LAN LED1
,
LQFP-64_L10.0-W10.0-P0.50-LS12.0-BL ! LQFP-64_L10.0-W10.0-P0.50-LS12.0-BL ! '{Value}' ,
; U20
NANO-SIM-SMD_SMN-305-ARP7 ! NANO-SIM-SMD_SMN-305-ARP7 ! '{Value}' ; CARD1
NT26E ! NT26E ! '{Value}' ; U19
OSC-SMD_4P-L3.2-W2.5-BL ! OSC-SMD_4P-L3.2-W2.5-BL ! 16MHz ; X2
,
QFN-48_L5.0-W5.0-P0.35-EP3.7_UC8288 ! QFN-48_L5.0-W5.0-P0.35-EP3.7_UC8288 ! '{Value}' ,
; U17
R0402 ! R0402 ! '100kΩ' ; R5 R34 R41 R42 R44
R0402 ! R0402 ! '10kΩ' ; R2 R15 R23 R35 R37 R38 R39 R40 R43 R45 R55 R75
R0402 ! R0402 ! '1kΩ' ; R18
R0402 ! R0402 ! '22Ω' ; R25 R26 R30
R0603 ! R0603 ! '100kΩ' ; R13 R19 R57 R72
R0603 ! R0603 ! '100Ω' ; R56
R0603 ! R0603 ! '10kΩ' ; R10 R11 R14 R47 R50 R51 R54 R59 R63 R64 R65 R66 R67 ,
R68
R0603 ! R0603 ! '120kΩ' ; R73
R0603 ! R0603 ! '120Ω' ; R49 R52
R0603 ! R0603 ! '12kΩ' ; R22 R36
R0603 ! R0603 ! '169kΩ' ; R7 R28
R0603 ! R0603 ! '1kΩ' ; R1 R4 R8 R12 R29 R58 R69 R70 R74
R0603 ! R0603 ! '1MΩ' ; R17
R0603 ! R0603 ! '2.7kΩ' ; R61
R0603 ! R0603 ! '200kΩ' ; R16 R71
R0603 ! R0603 ! '24kΩ' ; R46
R0603 ! R0603 ! '3.24kΩ' ; R31
R0603 ! R0603 ! '3.3kΩ' ; R6 R21
R0603 ! R0603 ! '30kΩ' ; R3
R0603 ! R0603 ! '330kΩ' ; R20
R0603 ! R0603 ! '4.7kΩ' ; R60 R62
R0603 ! R0603 ! '64kΩ' ; R9 R27
R0805 ! R0805 ! '100kΩ' ; R53
R0805 ! R0805 ! '10kΩ' ; R24 R33
R0805 ! R0805 ! '1kΩ' ; R48
R0805 ! R0805 ! '20kΩ' ; R32
RJ45-TH_HR915310A ! RJ45-TH_HR915310A ! '{Value}' ; D7
,
SC-70-6_L2.2-W1.3-P0.65-LS2.1-BL ! SC-70-6_L2.2-W1.3-P0.65-LS2.1-BL ! '{Value}' ,
; U22 U23
SMA_L4.3-W2.6-LS5.1-RD ! SMA_L4.3-W2.6-LS5.1-RD ! '{Value}' ; D3 D4
SOIC-8_L5.0-W4.0-P1.27-LS6.0-BL ! SOIC-8_L5.0-W4.0-P1.27-LS6.0-BL ! '{Value}' ,
; U10 U14
SOIC-8_L5.3-W5.3-P1.27-LS8.0-BL ! SOIC-8_L5.3-W5.3-P1.27-LS8.0-BL ! '{Value}' ,
; U18
,
SOT-223-3_L6.5-W3.4-P2.30-LS7.0-BR ! SOT-223-3_L6.5-W3.4-P2.30-LS7.0-BR ! '{Value}' ,
; U8
SOT-23 ! SOT-23 ! '{Value}' ; D5 D6
SOT-23_L2.9-W1.3-P1.90-LS2.4-BR ! SOT-23_L2.9-W1.3-P1.90-LS2.4-BR ! '{Value}' ,
; Q1 Q2 Q3 Q4 Q7 Q15 Q17
,
SOT-23-3_L2.9-W1.3-P1.90-LS2.4-BR ! SOT-23-3_L2.9-W1.3-P1.90-LS2.4-BR ! '{Value}' ,
; Q5 Q11 Q19
,
SOT-23-3_L2.9-W1.6-P1.90-LS2.8-BR ! SOT-23-3_L2.9-W1.6-P1.90-LS2.8-BR ! '{Value}' ,
; Q6
,
SOT-23-3_L3.0-W1.7-P0.95-LS2.9-BR ! SOT-23-3_L3.0-W1.7-P0.95-LS2.9-BR ! '{Value}' ,
; Q18
sot-23-3p ! sot-23-3p ! '{Value}' ; Q8 Q9 Q10 Q12 Q13 Q14
,
SOT-23-6_L2.9-W1.6-P0.95-LS2.8-BL ! SOT-23-6_L2.9-W1.6-P0.95-LS2.8-BL ! '{Value}' ,
; U3 U6
,
SOT-23-6_L2.9-W1.6-P0.95-LS2.8-BR ! SOT-23-6_L2.9-W1.6-P0.95-LS2.8-BR ! '{Value}' ,
; U7
,
SOT-363_L2.0-W1.3-P0.65-LS2.1-BR ! SOT-363_L2.0-W1.3-P0.65-LS2.1-BR ! '{Value}' ,
; D2
SOT323-6L_L2.0-W1.3-LS2.1-BL ! SOT323-6L_L2.0-W1.3-LS2.1-BL ! '{Value}' ; U16
TF-SMD_XKTF-1307-18 ! TF-SMD_XKTF-1307-18 ! '{Value}' ; CARD2
,
TO-263-5_L10.2-W9.9-P1.70-LS14.4-TL ! TO-263-5_L10.2-W9.9-P1.70-LS14.4-TL ! '{Value}' ,
; U5
$A_PROPERTIES
$NETS
'$1N14156' ; R32.1 R33.1 U5.5
'$1N15120' ; C16.2 L2.1 U3.6
'$1N15124' ; C16.1 U3.1
'$1N156972' ; R61.2 U20.55
'$1N157217' ; LORA.2 R61.1
'$1N219298' ; Q3.1 R6.2
'$1N219301' ; Q7.1 R21.2
'$1N219303' ; Q6.3 R8.1 R19.2
'$1N219304' ; D1.1 R1.1 R10.1
'$1N219315' ; Q4.1 R8.2
'$1N219322' ; R11.2 R14.2 U2.7
'$1N219324' ; R16.2 U2.8
'$1N219325' ; C17.1 R16.1 R20.2 U2.9
'$1N219326' ; R17.1 R20.1
'$1N219329' ; C4.1 L1.1 U2.13 U2.14
'$1N219330' ; C5.2 C14.2 C17.2 CN1.1 L1.2 Q7.3 R17.2 U2.10
'$1N219388' ; Q3.3 U1.2
'$1N219660' ; Q6.1 R10.2
'$1N219673' ; C15.2 Q3.2 Q4.2 Q6.2 R1.2
'$1N219967' ; H5.2 R72.2 R74.2 U22.6 U23.6
'$1N220337' ; Q2.1 R12.2 R13.2
'$1N220644' ; H2.2 R22.2 U3.3
'$1N220659' ; H2.1 R9.1
'$1N220661' ; H2.3 R7.2
'$1N220812' ; H3.1 R27.2
'$1N220814' ; H3.3 R28.2
'$1N220820' ; H3.2 R36.2 U6.3
'$1N232426' ; C4.2 U2.15
'$1N232428' ; R3.2 U2.4
'$1N25321' ; C24.1 U4.1
'$1N25347' ; C24.2 D3.1 L3.1 U4.8
'$1N25981' ; R24.1 R31.2 U4.4
'$1N27457' ; C25.1 U6.1
'$1N27465' ; C25.2 L4.1 U6.6
'$1N27856' ; D4.2 L5.2 U7.1
'$1N27899' ; R46.1 R48.2 U7.3
'$1N284612' ; H4.2 R29.1
'$1N284617' ; H4.1 Q11.3
'$1N284675' ; Q11.1 R44.2 R45.2
'$1N284885' ; C3.2 C12.2 Q4.3 R12.1 U2.1
'$1N284896' ; R4.2 U2.3
'$1N284900' ; H1.2 R4.1
'$1N284903' ; C13.2 H1.1 R11.1 U2.2
'$1N285302' ; C54.2 C55.2 C56.2 C57.2 Q15.3 U12.9 U12.10
'$1N292841' ; Q15.1 Q19.3 R53.2
'$1N292934' ; Q19.1 R55.2
'$1N299251' ; H4.4 U4.7
'$1N330138' ; Q1.1 Q5.3 R5.2
'$1N330143' ; Q5.1 R2.1
'$1N330213' ; C58.2 C62.2 Q17.3 Q18.2 U16.5
'$1N330234' ; Q17.1 R57.1 R58.2
'$1N35056' ; Q9.1 R40.1 R41.2
'$1N35060' ; Q9.3 U19.20
'$1N35062' ; R26.2 U19.12
'$1N35065' ; R30.2 U19.13
'$1N35068' ; R25.2 U19.11
'$1N35087' ; LED1.1 Q8.3
'$1N35088' ; Q8.1 R15.1
'$1N35089' ; LED1.2 R18.2
'$1N35110' ; Q10.1 R34.2 R35.1
'$1N35118' ; Q14.1 R42.2 R43.1
'$1N35136' ; C43.2 Q13.1 R38.2
'$1N35141' ; C42.1 Q12.1 R37.1
'$1N35148' ; C6.1 C7.1 C8.1 C9.2 C10.2 C11.2 Q1.3 U19.45 U19.46
'$1N36133' ; LAN.2 U17.21
'$1N36222' ; C68.2 U17.33
'$1N36366' ; C59.1 L6.1 U17.1 U17.2
'$1N36373' ; C66.2 L6.2 U17.35
'$1N36810' ; C67.2 U17.32 U21.3
'$1N36815' ; C74.2 U17.31 U21.1
'$1N37705' ; Q18.1 U16.3
'$1N39412' ; C80.2 U20.30
'$1N45053' ; LAN.1 R62.2
'$1N46192' ; R60.1 U20.60
'$1N88506' ; D7.10 R69.1
'$1N88557' ; D7.11 R70.1
'$1N99689' ; RF1.1 U19.37
'4G/~LAN' ; R2.2 R58.1 R74.1 U20.61
'ADC_VBAT' ; C84.2 R71.1 R73.2 U20.15
'CAT1_NETSTATUS' ; R15.2 U19.17
'CAT1_PWRKEY' ; R35.2 U20.17
'CAT1_RESET' ; R43.2 U20.14
'CAT1_UART_RX' ; Q12.3 U19.18
'CAT1_UART_TX' ; Q13.2 U19.19
'CAT1_WAKEUP' ; R40.2 U20.16
'E32_INT' ; U12.20 U20.20
'E32_NRST' ; U12.21 U20.21
'E32_PXEN' ; U12.6 U20.26
'E32_TXEN' ; R75.2 U12.7 U20.27
'LORA_POWER' ; R55.1 U20.37
'MCU_SWCLK' ; CN2.3 U20.49
'MCU_SWDIO' ; CN2.4 U20.46
'NT26E_RX' ; Q13.3 R39.1 U22.1
'NT26E_TX' ; Q12.2 U23.1
'POWER_CONTROL' ; R45.1 U20.56
'RD-' ; D7.7 U17.12
'RD+' ; D7.6 U17.11
'RS485_1_A' ; D5.1 R49.1 R50.2 U9.1 U10.6
'RS485_1_B' ; D5.2 R47.2 R49.2 U9.2 U10.7
'RS485_1_CTRL' ; U10.2 U10.3 U20.38
'RS485_2_A' ; D6.1 R52.1 R54.2 U13.1 U14.6
'RS485_2_B' ; D6.2 R51.2 R52.2 U13.2 U14.7
'RS485_2_CTRL' ; U14.2 U14.3 U20.34
'SD1_CLK' ; CARD2.5 R65.1 U20.53
'SD1_CMD' ; CARD2.3 R66.1 U20.54
'SD1_DAT0' ; CARD2.7 R64.1 U20.39
'SD1_DAT1' ; CARD2.8 R63.1 U20.40
'SD1_DAT2' ; CARD2.1 R68.1 U20.42
'SD1_DAT3' ; CARD2.2 R67.1 U20.52
'SIM_CLK' ; C29.2 CARD1.3 D2.4 R30.1
'SIM_DATA' ; C31.2 CARD1.7 D2.6 R23.2 R25.1
'SIM_RST' ; C30.2 CARD1.2 D2.5 R26.1
'SIM_VDD' ; C32.1 C41.2 CARD1.1 CARD1.6 D2.3 R23.1 U19.15
'SPI1_MISO' ; U18.2 U20.9
'SPI1_MOSI' ; U18.5 U20.11
'SPI1_SCK' ; U18.6 U20.10
'SPI1_SS0' ; U18.1 U20.8
'SPI2_MISO' ; U12.22 U20.22
'SPI2_MOSI' ; U12.23 U20.23
'SPI2_SCK' ; U12.24 U20.24
'SPI2_SS0' ; U12.25 U20.25
'TD-' ; D7.2 U17.14
'TD+' ; D7.1 U17.13
'UART1_RX' ; CN2.6 CN3.3 U20.44
'UART1_TX' ; CN2.5 CN3.2 U20.45
'UART2_RX' ; U10.1 U20.43
'UART2_TX' ; U10.4 U20.41
'UART3_RX' ; U14.1 U20.35
'UART3_TX' ; U14.4 U20.33
'UART4_RX' ; U20.62 U22.4
'UART4_TX' ; U20.2 U23.4
'V_RS4851_5/12V' ; C20.2 C21.2 L2.2 R7.1 R9.2 U11.2
'V_RS4851_ON/~OFF' ; U3.4 U20.51
'V_RS4852_5/12V' ; C35.2 C36.2 L4.2 R27.1 R28.1 U15.2
'V_RS4852_ON/~OFF' ; U6.4 U20.28
'VCC_15V' ; C18.2 C19.2 C33.2 C34.2 C51.1 C52.2 D4.1 R46.2 U3.5 U6.5
'VCC_33' ; C60.1 C61.1 C69.2 D7.3 D7.5 D7.9 D7.12 Q18.3 R56.2 U17.3
'VCC_3V3' ; C42.2 C46.2 C47.2 C48.2 C53.2 C63.1 C64.1 C65.1 C71.1 C72.1 C75.1 ,
C76.1 C78.1 C79.2 C83.2 C85.2 C86.2 CARD2.4 CN2.7 Q17.2 R37.2 R39.2 ,
R50.1 R54.1 R57.2 R59.1 R60.2 R63.2 R64.2 R65.2 R66.2 R67.2 R68.2 ,
R72.1 U8.2 U8.4 U10.8 U14.8 U18.3 U18.7 U18.8 U20.13 U20.19 U20.32 ,
U20.48 U20.64 U22.5 U23.5
'VCC_3V8' ; C39.2 C40.2 Q1.2 Q15.2 R5.1 R18.1 R32.2 R53.1 U5.4
'VCC_5V' ; C22.1 C23.2 C37.2 C38.2 C44.2 C45.2 L3.2 R24.2 U5.1 U5.2 U8.3
'VCC_7V4' ; C1.2 C2.2 C26.2 C27.2 C49.1 C50.2 H4.3 L5.1 Q2.2 R29.2 U2.16 U7.4 ,
U7.5
'VDD_EXT' ; C28.2 C43.1 R38.1 U19.26
'XTAL_IN' ; C81.2 U20.5 X2.1
'XTAL_OUT' ; C82.2 U20.6 X2.3
'XTAL32_IN' ; C77.1 U20.4 X1.2
'XTAL32_OUT' ; C73.1 U20.3 X1.1
'YOXO_100MLINK' ; R69.2 U17.23
'YOXO_DEF' ; U17.22 U20.59
'YOXO_NRST' ; U17.25 U20.57
'YOXO_RX' ; U17.37 U22.3
'YOXO_TX' ; U17.36 U23.3
ACT ; R70.2 U17.27
CAT1PWRKEY ; Q10.3 U19.7
CAT1RESET ; Q14.3 U19.16
GND ; C1.1 C2.1 C3.1 C5.1 C6.2 C7.2 C8.2 C9.1 C10.1 C11.1 C12.1 C13.1 C14.1 ,
C15.1 C18.1 C19.1 C20.1 C21.1 C22.2 C23.1 C26.1 C27.1 C28.1 C29.1 ,
C30.1 C31.1 C32.2 C33.1 C34.1 C35.1 C36.1 C37.1 C38.1 C39.1 C40.1 ,
C41.1 C44.1 C45.1 C46.1 C47.1 C48.1 C49.2 C50.1 C51.2 C52.1 C53.1 ,
C54.1 C55.1 C56.1 C57.1 C58.1 C59.2 C60.2 C61.2 C62.1 C63.2 C64.2 ,
C65.2 C66.1 C67.1 C68.1 C69.1 C70.1 C71.2 C72.2 C73.2 C74.1 C75.2 ,
C76.2 C77.2 C78.2 C79.1 C80.1 C81.1 C82.1 C83.1 C84.1 C85.1 C86.1 ,
CARD1.5 CARD1.9 CARD1.10 CARD1.11 CARD2.6 CARD2.9 CARD2.10 CARD2.11 ,
CARD2.12 CN1.2 CN2.1 CN3.1 D1.2 D2.2 D3.2 D5.3 D6.3 H5.1 LORA.1 Q5.2 ,
Q8.2 Q9.2 Q10.2 Q11.2 Q14.2 Q19.2 R3.1 R6.1 R13.1 R14.1 R19.1 R21.1 ,
R22.1 R31.1 R33.2 R34.1 R36.1 R41.1 R42.1 R44.1 R47.1 R48.1 R51.1 ,
R56.1 R62.1 R73.1 R75.1 RF1.2 RF1.3 U1.1 U2.11 U2.12 U3.2 U4.6 U4.9 ,
U5.3 U5.6 U6.2 U7.2 U8.1 U10.5 U11.1 U12.1 U12.2 U12.3 U12.4 U12.5 ,
U12.11 U12.12 U12.17 U12.18 U12.26 U12.28 U14.5 U15.1 U16.2 U17.49 ,
U18.4 U19.1 U19.10 U19.29 U19.36 U19.39 U19.40 U19.43 U19.44 U19.50 ,
U19.51 U19.52 U19.53 U19.81 U19.82 U19.83 U19.85 U19.103 U19.107 ,
U19.108 U19.109 U19.110 U19.111 U19.112 U20.12 U20.18 U20.31 U20.47 ,
U20.63 U21.2 U21.4 U22.2 U23.2 X2.2 X2.4
LINK ; U17.28 U20.58
NRST ; C70.2 CN2.2 R59.2 U20.7
PGND ; D7.8 D7.13 D7.14
VBAT ; Q2.3 Q7.2 R71.2
$SCHEDULE
$END
Binary file not shown.
+74 -63
View File
@@ -75,7 +75,7 @@
<OPTFL> <OPTFL>
<tvExp>1</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget> <IsCurrentTarget>0</IsCurrentTarget>
</OPTFL> </OPTFL>
<CpuCode>255</CpuCode> <CpuCode>255</CpuCode>
<DebugOpt> <DebugOpt>
@@ -350,7 +350,7 @@
<OPTFL> <OPTFL>
<tvExp>1</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget> <IsCurrentTarget>1</IsCurrentTarget>
</OPTFL> </OPTFL>
<CpuCode>255</CpuCode> <CpuCode>255</CpuCode>
<DebugOpt> <DebugOpt>
@@ -410,7 +410,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>JL2CM3</Key> <Key>JL2CM3</Key>
<Name>-U4294967295 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO8 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_otp.FLM -FS03000C00 -FL03FC -FP0($$Device:HC32F460KETA$FlashARM\HC32F460_otp.FLM) -FF1HC32F460_512K.FLM -FS10 -FL180000 -FP1($$Device:HC32F460KETA$FlashARM\HC32F460_512K.FLM)</Name> <Name>-U4294967295 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO14 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_otp.FLM -FS03000C00 -FL03FC -FP0($$Device:HC32F460KETA$FlashARM\HC32F460_otp.FLM) -FF1HC32F460_512K.FLM -FS10 -FL180000 -FP1($$Device:HC32F460KETA$FlashARM\HC32F460_512K.FLM)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@@ -428,7 +428,40 @@
<Name></Name> <Name></Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint/> <Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>1004</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\source\User\Src\Public.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>1006</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\source\User\Src\Public.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@@ -438,27 +471,17 @@
<Ww> <Ww>
<count>1</count> <count>1</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>sData</ItemText> <ItemText>EthStatus</ItemText>
</Ww> </Ww>
<Ww> <Ww>
<count>2</count> <count>2</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>CatOne.Status</ItemText> <ItemText>EthRecvTimeoutCnt,0x0A</ItemText>
</Ww> </Ww>
<Ww> <Ww>
<count>3</count> <count>3</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>CatOneEthTxBuff</ItemText> <ItemText>(60 * 1000),0x0A</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>CatOneEthTxLen,0x0A</ItemText>
</Ww>
<Ww>
<count>5</count>
<WinNumber>1</WinNumber>
<ItemText>SCPara-&gt;RS485RxBuff</ItemText>
</Ww> </Ww>
</WatchWindow1> </WatchWindow1>
<WatchWindow2> <WatchWindow2>
@@ -653,18 +676,6 @@
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\source\User\Src\DebugCmd.c</PathWithFileName>
<FilenameWithoutPath>DebugCmd.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>10</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\source\User\Src\spiflash.c</PathWithFileName> <PathWithFileName>..\source\User\Src\spiflash.c</PathWithFileName>
<FilenameWithoutPath>spiflash.c</FilenameWithoutPath> <FilenameWithoutPath>spiflash.c</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@@ -672,7 +683,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>11</FileNumber> <FileNumber>10</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -684,7 +695,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>12</FileNumber> <FileNumber>11</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -696,7 +707,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>13</FileNumber> <FileNumber>12</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -708,7 +719,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>14</FileNumber> <FileNumber>13</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -728,7 +739,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>15</FileNumber> <FileNumber>14</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -740,7 +751,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>16</FileNumber> <FileNumber>15</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -752,7 +763,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>17</FileNumber> <FileNumber>16</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -764,7 +775,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>18</FileNumber> <FileNumber>17</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -776,7 +787,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>19</FileNumber> <FileNumber>18</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -788,7 +799,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>20</FileNumber> <FileNumber>19</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -800,7 +811,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>21</FileNumber> <FileNumber>20</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -812,7 +823,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>22</FileNumber> <FileNumber>21</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -824,7 +835,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>23</FileNumber> <FileNumber>22</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -836,7 +847,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>24</FileNumber> <FileNumber>23</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -848,7 +859,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>25</FileNumber> <FileNumber>24</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -860,7 +871,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>26</FileNumber> <FileNumber>25</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -872,7 +883,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>27</FileNumber> <FileNumber>26</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -884,7 +895,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>28</FileNumber> <FileNumber>27</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -896,7 +907,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>29</FileNumber> <FileNumber>28</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -908,7 +919,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>30</FileNumber> <FileNumber>29</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -920,7 +931,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>31</FileNumber> <FileNumber>30</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -933,20 +944,20 @@
</Group> </Group>
<Group> <Group>
<GroupName>Debug</GroupName> <GroupName>GateWay_Debug</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>32</FileNumber> <FileNumber>31</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\source\Module\Debug\Debug.c</PathWithFileName> <PathWithFileName>..\source\Module\GateWay_Debug\DebugCmd.c</PathWithFileName>
<FilenameWithoutPath>Debug.c</FilenameWithoutPath> <FilenameWithoutPath>DebugCmd.c</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
@@ -960,7 +971,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>33</FileNumber> <FileNumber>32</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -972,7 +983,7 @@
</File> </File>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>34</FileNumber> <FileNumber>33</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -992,7 +1003,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>35</FileNumber> <FileNumber>34</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -1004,7 +1015,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>36</FileNumber> <FileNumber>35</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -1016,7 +1027,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>37</FileNumber> <FileNumber>36</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -1028,7 +1039,7 @@
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>38</FileNumber> <FileNumber>37</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -1042,13 +1053,13 @@
<Group> <Group>
<GroupName>sx127x</GroupName> <GroupName>sx127x</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>7</GroupNumber>
<FileNumber>39</FileNumber> <FileNumber>38</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
+8 -258
View File
@@ -341,7 +341,7 @@
<MiscControls>--diag_suppress=186,66</MiscControls> <MiscControls>--diag_suppress=186,66</MiscControls>
<Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA</Define> <Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\SX127x</IncludePath> <IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\GateWay_Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\SX127x</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@@ -468,11 +468,6 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\source\User\Src\Public.c</FilePath> <FilePath>..\source\User\Src\Public.c</FilePath>
</File> </File>
<File>
<FileName>DebugCmd.c</FileName>
<FileType>1</FileType>
<FilePath>..\source\User\Src\DebugCmd.c</FilePath>
</File>
<File> <File>
<FileName>spiflash.c</FileName> <FileName>spiflash.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
@@ -591,132 +586,12 @@
</Files> </Files>
</Group> </Group>
<Group> <Group>
<GroupName>Debug</GroupName> <GroupName>GateWay_Debug</GroupName>
<GroupOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>0</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<GroupArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>2</interw>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<thumb>2</thumb>
<SplitLS>2</SplitLS>
<SwStkChk>2</SwStkChk>
<NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc>
<useXO>2</useXO>
<ClangAsOpt>0</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
</GroupArmAds>
</GroupOption>
<Files> <Files>
<File> <File>
<FileName>Debug.c</FileName> <FileName>DebugCmd.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\source\Module\Debug\Debug.c</FilePath> <FilePath>..\source\Module\GateWay_Debug\DebugCmd.c</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>0</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
</File> </File>
</Files> </Files>
</Group> </Group>
@@ -1392,7 +1267,7 @@
<MiscControls>--diag_suppress=186,66</MiscControls> <MiscControls>--diag_suppress=186,66</MiscControls>
<Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA,BOOT_ENABLE</Define> <Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA,BOOT_ENABLE</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\SX127x</IncludePath> <IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\sx127x;..\source\Module\GateWay_Debug</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@@ -1519,11 +1394,6 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\source\User\Src\Public.c</FilePath> <FilePath>..\source\User\Src\Public.c</FilePath>
</File> </File>
<File>
<FileName>DebugCmd.c</FileName>
<FileType>1</FileType>
<FilePath>..\source\User\Src\DebugCmd.c</FilePath>
</File>
<File> <File>
<FileName>spiflash.c</FileName> <FileName>spiflash.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
@@ -1642,132 +1512,12 @@
</Files> </Files>
</Group> </Group>
<Group> <Group>
<GroupName>Debug</GroupName> <GroupName>GateWay_Debug</GroupName>
<GroupOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>0</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<GroupArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>2</interw>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<thumb>2</thumb>
<SplitLS>2</SplitLS>
<SwStkChk>2</SwStkChk>
<NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc>
<useXO>2</useXO>
<ClangAsOpt>0</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
</GroupArmAds>
</GroupOption>
<Files> <Files>
<File> <File>
<FileName>Debug.c</FileName> <FileName>DebugCmd.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\source\Module\Debug\Debug.c</FilePath> <FilePath>..\source\Module\GateWay_Debug\DebugCmd.c</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>0</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
</File> </File>
</Files> </Files>
</Group> </Group>
@@ -0,0 +1,21 @@
/*
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'GateWay'
* Target: 'app_app'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "HC32F460KETA.h"
#endif /* RTE_COMPONENTS_H */
@@ -1,2 +0,0 @@
#include "bps.h"
@@ -0,0 +1,130 @@
# ---> IAR
# Compiled binaries
*.o
*.bin
*.elf
*.hex
*.map
*.out
*.obj
# Trash
*.bak
thumbs.db
*.~*
# IAR Settings
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos
# IAR Debug Exe
**/Exe/*.sim
# IAR Debug Obj
**/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*
# IAR project "Debug" directory
Debug/
# IAR project "Release" directory
Release/
# IAR project settings directory
settings/
# IAR backup files
Backup*
# IAR .dep files
*.dep
# ---> IAR_EWARM
# gitignore template for the IAR EWARM
# website: https://www.iar.com/knowledge/support/technical-notes/ide/which-files-should-be-version-controlled/
# Some tools will put the EWARM files
# under a subdirectory with the same name
# as the configuration.
# Example
# EWARM/Config1/Obj /List /Exe
# EWARM/Config2/Obj /List /Exe
EWARM/**/Obj
EWARM/**/List
EWARM/**/Exe
# Autogenerated project files
*.dep
*.ewt
# Autogenerated folder for debugger
EWARM/settings
# ---> uVision
# git ignore file for Keil µVision Project
# µVision 5 and µVision 4 Project screen layout file
*.uvguix.*
*.uvgui.*
# Listing Files
*.i
*.lst
*.m51
*.m66
*.map
# Object Files
*.axf
*.b[0-2][0-9]
*.b3[0-1]
*.bak
*.build_log.htm
*.crf
*.d
*.dep
*.elf
*.htm
*.iex
*.lnp
*.o
*.obj
*.sbr
# Firmware Files
*.bin
*.h86
*.hex
# Build Files
.bat
# Debugger Files
.ini
# JLink Files
JLinkLog.txt
# Other Files
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
@@ -0,0 +1,2 @@
# FatFS
@@ -0,0 +1,130 @@
# ---> IAR
# Compiled binaries
*.o
*.bin
*.elf
*.hex
*.map
*.out
*.obj
# Trash
*.bak
thumbs.db
*.~*
# IAR Settings
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos
# IAR Debug Exe
**/Exe/*.sim
# IAR Debug Obj
**/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*
# IAR project "Debug" directory
Debug/
# IAR project "Release" directory
Release/
# IAR project settings directory
settings/
# IAR backup files
Backup*
# IAR .dep files
*.dep
# ---> IAR_EWARM
# gitignore template for the IAR EWARM
# website: https://www.iar.com/knowledge/support/technical-notes/ide/which-files-should-be-version-controlled/
# Some tools will put the EWARM files
# under a subdirectory with the same name
# as the configuration.
# Example
# EWARM/Config1/Obj /List /Exe
# EWARM/Config2/Obj /List /Exe
EWARM/**/Obj
EWARM/**/List
EWARM/**/Exe
# Autogenerated project files
*.dep
*.ewt
# Autogenerated folder for debugger
EWARM/settings
# ---> uVision
# git ignore file for Keil µVision Project
# µVision 5 and µVision 4 Project screen layout file
*.uvguix.*
*.uvgui.*
# Listing Files
*.i
*.lst
*.m51
*.m66
*.map
# Object Files
*.axf
*.b[0-2][0-9]
*.b3[0-1]
*.bak
*.build_log.htm
*.crf
*.d
*.dep
*.elf
*.htm
*.iex
*.lnp
*.o
*.obj
*.sbr
# Firmware Files
*.bin
*.h86
*.hex
# Build Files
.bat
# Debugger Files
.ini
# JLink Files
JLinkLog.txt
# Other Files
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
@@ -1,4 +1,5 @@
#include "main.h" #include "main.h"
#include "bsp.h"
#include "CatOneTask.h" #include "CatOneTask.h"
#include "RS485Task.h" #include "RS485Task.h"
#include "Public.h" #include "Public.h"
@@ -8,7 +9,7 @@
#define DBG_RX_LEN_MAX 128 #define DBG_RX_LEN_MAX 128
//#define DBG_LOG(...) rt_kprintf(__VA_ARGS__) //#define DBG_LOG(...) rt_kprintf(__VA_ARGS__)
#define DEBUG_CMD_CNT 22 #define DEBUG_CMD_CNT 31
#define DEBUG_BUFF_SIZE_MAX 512 #define DEBUG_BUFF_SIZE_MAX 512
#define DEBUG_BUFSIZE 200 #define DEBUG_BUFSIZE 200
@@ -183,10 +184,11 @@ void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen)
} }
for(int i = 0; i < DEBUG_CMD_CNT; i++) { for(int i = 0; i < DEBUG_CMD_CNT; i++) {
if(strcmp(argv[0], DebugFun[i].DBGCmd) == 0) if(strcmp(argv[0], DebugFun[i].DBGCmd) == 0) {
DebugFun[i].DBGExec(argc, argv); DebugFun[i].DBGExec(argc, argv);
break; // 添加break避免继续匹配
}
} }
memset(rData, 0x00, rLen);
} }
/***************************************************************************************** /*****************************************************************************************
@@ -259,15 +261,15 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
return; return;
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: rs485 arg1 arg2 arg3 arg4\r\n"); DBG_LOG("Debug Cmd: rs485 arg1 arg2 arg3\r\n");
DBG_LOG(" brief --> RS485 control command.\r\n"); DBG_LOG(" brief --> RS485 control command.\r\n");
DBG_LOG(" arg1 --> idx: (1, 2) RS485 channel selection.\r\n"); DBG_LOG(" arg1 --> idx: (1, 2) RS485 channel selection.\r\n");
DBG_LOG(" arg2 --> scmd:(o, c, v, b)Rs485 subcommand.\r\n"); DBG_LOG(" arg2 --> scmd:(o, c, v, b, u)Rs485 subcommand.\r\n");
DBG_LOG(" scmd = o, arg3 = (on, off) RS485 Channel On-OFF.\r\n"); DBG_LOG(" scmd = o, arg3 = (on, off) RS485 Channel On-OFF.\r\n");
DBG_LOG(" scmd = c, arg3 = (on, off) Enable the internal communication unit function.\r\n"); DBG_LOG(" scmd = c, arg3 = (on, off) Enable the internal communication unit function.\r\n");
DBG_LOG(" scmd = v, arg3 = (on, off) Set output voltage.\r\n"); DBG_LOG(" scmd = v, arg3 = (on, off) Set output voltage.\r\n");
DBG_LOG(" scmd = b, arg3 = (2400~500000) Set baud rate.\r\n\r\n"); DBG_LOG(" scmd = b, arg3 = (2400~500000) Set baud rate.\r\n");
DBG_LOG(" scmd = u, arg4 = (on, off) Set Upgrade symbol.\r\n\r\n"); DBG_LOG(" scmd = u, arg3 = (on, off) Set Upgrade symbol.\r\n\r\n");
return; return;
} }
@@ -301,9 +303,9 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
if(idx == 1) { if(idx == 1) {
GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = true; GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = true;
GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true; GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true;
GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN = 0; GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN = 0;
memset(GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2); memset(GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2);
GateWay->ConfigPara.Rs485Ch1.CUData.Para.CommStatus = true; GateWay->ConfigPara.Rs485Ch1.CUPara.Para.CommStatus = true;
RS485Ch1_Config(9600); RS485Ch1_Config(9600);
GateWay->ConfigPara.Rs485Ch1.BaudRate = 9600; GateWay->ConfigPara.Rs485Ch1.BaudRate = 9600;
SComm1Para.SensorCnt = 0; SComm1Para.SensorCnt = 0;
@@ -311,9 +313,9 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
else if(idx == 2) { else if(idx == 2) {
GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = true; GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = true;
GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true; GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true;
GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN = 0; GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN = 0;
memset(GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2); memset(GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2);
GateWay->ConfigPara.Rs485Ch2.CUData.Para.CommStatus = true; GateWay->ConfigPara.Rs485Ch2.CUPara.Para.CommStatus = true;
RS485Ch2_Config(9600); RS485Ch2_Config(9600);
GateWay->ConfigPara.Rs485Ch2.BaudRate = 9600; GateWay->ConfigPara.Rs485Ch2.BaudRate = 9600;
SComm2Para.SensorCnt = 0; SComm2Para.SensorCnt = 0;
@@ -323,11 +325,11 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
else if(strstr(argv[3], "off") != NULL){ else if(strstr(argv[3], "off") != NULL){
if(idx == 1) { if(idx == 1) {
GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = false; GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = false;
GateWay->ConfigPara.Rs485Ch1.CUData.Para.CommStatus = false; GateWay->ConfigPara.Rs485Ch1.CUPara.Para.CommStatus = false;
} }
else if(idx == 2) { else if(idx == 2) {
GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = false; GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = false;
GateWay->ConfigPara.Rs485Ch2.CUData.Para.CommStatus = false; GateWay->ConfigPara.Rs485Ch2.CUPara.Para.CommStatus = false;
} }
DBG_LOG("RS485Ch%d Disable!\r\n", idx); DBG_LOG("RS485Ch%d Disable!\r\n", idx);
} }
@@ -452,11 +454,10 @@ void DebugCmdDelCommUnit(int argc, char *argv[])
return; return;
} }
GateWay->ConfigPara.CommUnitArray[ret].RegFlag = false; GateWay->ConfigPara.CommUnitArray[ret].RegFlag = false;
//memset(&GateWay->ConfigPara.CommUnitArray[ret], 0x00, sizeof(CommUnitData_t));
DBG_LOG("Device has been deleted!\r\n"); DBG_LOG("Device has been deleted!\r\n");
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
} }
/***************************************************************************************** /*****************************************************************************************
* : DebugCmdLsCommUnit * : DebugCmdLsCommUnit
* : * :
@@ -476,10 +477,10 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) { if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) {
DBG_LOG("DevType: 8001\r\n"); DBG_LOG("DevType: 8001\r\n");
DBG_LOG("DevMac: 01-80-02-00-00-01\r\n"); DBG_LOG("DevMac: 01-80-02-00-00-01\r\n");
DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN); DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN);
DBG_LOG("SensorType: "); DBG_LOG("SensorType: ");
for(int i = 0; i < GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN; i++) { for(int i = 0; i < GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN; i++) {
DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType[i]); DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType[i]);
} }
DBG_LOG("\r\n\r\n"); DBG_LOG("\r\n\r\n");
} }
@@ -487,10 +488,10 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) { if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) {
DBG_LOG("DevType: 8002\r\n"); DBG_LOG("DevType: 8002\r\n");
DBG_LOG("DevMac: 01-80-02-00-00-02\r\n"); DBG_LOG("DevMac: 01-80-02-00-00-02\r\n");
DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN); DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN);
DBG_LOG("SensorType: "); DBG_LOG("SensorType: ");
for(int i = 0; i < GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN; i++) { for(int i = 0; i < GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN; i++) {
DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType[i]); DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType[i]);
} }
DBG_LOG("\r\n\r\n"); DBG_LOG("\r\n\r\n");
} }
@@ -514,14 +515,152 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
for(int j = 0; j < GateWay->ConfigPara.CommUnitArray[i].SensorN; j++) { for(int j = 0; j < GateWay->ConfigPara.CommUnitArray[i].SensorN; j++) {
DBG_LOG("%04X ", GateWay->ConfigPara.CommUnitArray[i].SensorType[j]); DBG_LOG("%04X ", GateWay->ConfigPara.CommUnitArray[i].SensorType[j]);
} }
DBG_LOG("\r\n\r\n"); DBG_LOG("\r\n");
DBG_LOG("Online: %s\r\n", GateWay->ConfigPara.CommUnitArray[i].CommStatus ? "Yes" : "No");
DBG_LOG("\r\n");
} }
} }
if(CUCnt ==0) { if(CUCnt ==0) {
DBG_LOG("No device is registered.\r\n"); DBG_LOG("No device is registered.\r\n");
} }
} }
/*****************************************************************************************
* : DebugCmdExclCommUnit
* : MAC
* : argc,
argv,
* :
*****************************************************************************************/
void DebugCmdExclCommUnit(int argc, char *argv[])
{
DBG_LOG("\r\n");
uint8_t mac[6];
if(argc < 2)
return;
if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: excu arg1\r\n");
DBG_LOG(" brief --> Exclude communication unit.\r\n");
DBG_LOG(" arg1 --> mac: communication unit Mac address.\r\n");
DBG_LOG(" mac = (XX-XX-XX-XX-XX-XX), Exclude the MAC of the specified communication unit.\r\n\r\n");
return;
}
int ret = sscanf(argv[1], "%x-%x-%x-%x-%x-%x",
(int *)&mac[0], (int *)&mac[1], (int *)&mac[2], (int *)&mac[3], (int *)&mac[4], (int *)&mac[5]);
if(ret != 6) {
DBG_LOG("cuex Cmd Para Error!\r\n");
return;
}
ret = CheckCommUnitExcl(GateWay, mac);
if(ret > -1) {
DBG_LOG("This device has been tested and eliminated at this gateway!\r\n");
return;
}
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {//寻找空位
if(GateWay->ConfigPara.ExclCommUnit[i].ExclFlag == false){
GateWay->ConfigPara.ExclCommUnit[i].ExclFlag = true;
memcpy(&GateWay->ConfigPara.ExclCommUnit[i].ExclMac, &mac[0], 6);
break;
}
}
ret = CheckCommUnitReg(GateWay, mac);//删除注册信息
if(ret > -1) {
GateWay->ConfigPara.CommUnitArray[ret].RegFlag = false;
}
DBG_LOG("Equipment removal was successful!\r\n");
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
}
/*****************************************************************************************
* : DebugCmdDelExclCommUnit
* : MAC
* : argc,
argv,
* :
*****************************************************************************************/
void DebugCmdDelExclCommUnit(int argc, char *argv[])
{
DBG_LOG("\r\n");
uint8_t mac[6];
if(argc < 2)
return;
if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: exdel arg1\r\n");
DBG_LOG(" brief --> Delete the excluded communication units.\r\n");
DBG_LOG(" arg1 --> mac: communication unit Mac address.\r\n");
DBG_LOG(" mac = (XX-XX-XX-XX-XX-XX), Delete the MAC address of the specified excluded communication unit.\r\n\r\n");
return;
}
if(strcmp(argv[1], "all") == 0) {
for(uint8_t i = 0; i < COMMUNIT_NUM_MAX; i++)
{
GateWay->ConfigPara.ExclCommUnit[i].ExclFlag = false;
}
DBG_LOG("All excluded devices have been deleted!\r\n");
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
return;
}
int ret = sscanf(argv[1], "%x-%x-%x-%x-%x-%x",
(int *)&mac[0], (int *)&mac[1], (int *)&mac[2], (int *)&mac[3], (int *)&mac[4], (int *)&mac[5]);
if(ret != 6) {
DBG_LOG("exdel Cmd Para Error!\r\n");
return;
}
ret = CheckCommUnitExcl(GateWay, mac);
if(ret < 0) {
DBG_LOG("This equipment has not been ruled out!\r\n");
return;
}
GateWay->ConfigPara.ExclCommUnit[ret].ExclFlag = false;
DBG_LOG("The exclusion for this equipment has been cancelled!\r\n");
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
}
/*****************************************************************************************
* : DebugCmdLsExclCommUnit
* :
* : argc,
argv,
* :
*****************************************************************************************/
void DebugCmdLsExclCommUnit(int argc, char *argv[])
{
DBG_LOG("\r\n");
if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: exls\r\n\
brief --> View the information of the excluded communication units.\r\n\r\n");
return;
}
int CUCnt = 0;
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {
if(GateWay->ConfigPara.ExclCommUnit[i].ExclFlag == true) {
CUCnt++;
DBG_LOG("Exclude DevMac: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
GateWay->ConfigPara.ExclCommUnit[i].ExclMac[0],
GateWay->ConfigPara.ExclCommUnit[i].ExclMac[1],
GateWay->ConfigPara.ExclCommUnit[i].ExclMac[2],
GateWay->ConfigPara.ExclCommUnit[i].ExclMac[3],
GateWay->ConfigPara.ExclCommUnit[i].ExclMac[4],
GateWay->ConfigPara.ExclCommUnit[i].ExclMac[5]);
}
}
if(CUCnt ==0) {
DBG_LOG("No device is exclude.\r\n");
}
DBG_LOG("\r\n\r\n");
}
/***************************************************************************************** /*****************************************************************************************
* : DebugCmdSetComm * : DebugCmdSetComm
* : * :
@@ -536,14 +675,16 @@ void DebugCmdSetComm(int argc, char *argv[])
return; return;
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: comm arg1\r\n"); DBG_LOG("Debug Cmd: comm arg1\r\n");
DBG_LOG(" brief --> Set gateway and service communication methods.\r\n"); DBG_LOG(" brief --> Set gateway and service communication methods.\r\n");
DBG_LOG(" arg1 --> para: (cat1, eth),Cat1 or ETH communication.\r\n\r\n"); DBG_LOG(" arg1 --> para: (cat1, eth),Cat1 or ETH communication.\r\n\r\n");
return; return;
} }
if(strcmp(argv[1], "cat1") == 0) { if(strcmp(argv[1], "cat1") == 0) {
GateWay->SvrRegFlag = false;
GateWay->ConfigPara.Comm = CATONE_COMM; GateWay->ConfigPara.Comm = CATONE_COMM;
ETHStop();
CAT1_ON(); CAT1_ON();
CatOneReset(); CatOneReset();
DBG_LOG("Set the communication method to Cat1.\r\n"); DBG_LOG("Set the communication method to Cat1.\r\n");
@@ -557,12 +698,12 @@ void DebugCmdSetComm(int argc, char *argv[])
rt_thread_delay(3000); rt_thread_delay(3000);
CAT1_PWR_KEY_SET(); CAT1_PWR_KEY_SET();
} }
GateWay->SvrRegFlag = false;
GateWay->ConfigPara.Comm = ETH_COMM; GateWay->ConfigPara.Comm = ETH_COMM;
ETH_ON(); ETH_ON();
ETHReset();
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
} }
} }
/***************************************************************************************** /*****************************************************************************************
@@ -747,18 +888,94 @@ void DebugCmdRestoreFactory(int argc, char *argv[])
DBG_LOG("\r\n"); DBG_LOG("\r\n");
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: res\r\n\ DBG_LOG("Debug Cmd: res\r\n\
brief --> Restore to factory.\r\n\r\n"); brief --> Restore to factory.\r\n");
DBG_LOG(" arg1 --> password\r\n\r\n");
return; return;
} }
if(strcmp(argv[1], "gxjt") != 0) {
DBG_LOG("Password Error\r\n");
return;
}
DBG_LOG("Restore factory settings, GateWay Restart...\r\n");
memset((uint8_t *)&GateWay->ConfigPara, 0x00, sizeof(GWConfigPara_t)); memset((uint8_t *)&GateWay->ConfigPara, 0x00, sizeof(GWConfigPara_t));
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
DBG_LOG("Restore factory settings, GateWay Restart...\r\n");
rt_thread_delay(1000); rt_thread_delay(1000);
NVIC_SystemReset(); NVIC_SystemReset();
while(1); while(1);
} }
/*****************************************************************************************
* : DebugCmdUpload
* :
* : argc,
argv,
* :
*****************************************************************************************/
static void DebugCmdUpload(int argc, char *argv[])
{
DBG_LOG("\r\n");
if(argc > 1 && strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: up\r\n");
DBG_LOG(" brief --> Upload current gateway status to server.\r\n\r\n");
return;
}
if(GateWay->SvrRegFlag == false) {
DBG_LOG("Server not registered, please register first.\r\n");
return;
}
uint8_t MegData[6];
uint8_t len = sizeof(GateWayAlarmType_t);
MegData[0] = len & 0x00ff;
MegData[1] = (len >> 8) & 0x00ff;
MegData[2] = NET_COMM_CMD_ALARM;
MegData[3] = 0x00;
MegData[4] = GateWay->ConfigPara.OutageFlag ? 1 : 0;
MegData[5] = GateWay->Battery;
if(CatOneEthSendQueue(MegData, 6) == true) {
DBG_LOG("Gateway status uploaded.\r\n");
}
else {
DBG_LOG("Gateway status upload failed.\r\n");
}
}
/*****************************************************************************************
* : DebugCmdRegister
* :
* : argc,
argv,
* :
*****************************************************************************************/
static void DebugCmdRegister(int argc, char *argv[])
{
DBG_LOG("\r\n");
if(argc > 1 && strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: reg\r\n");
DBG_LOG(" brief --> Re-register to the server.\r\n\r\n");
return;
}
GateWay->SvrRegFlag = false;
if(GateWay->ConfigPara.Comm == CATONE_COMM) {
CatOneTriggerRegister();
DBG_LOG("Trigger Cat1 re-registration immediately.\r\n");
}
else if(GateWay->ConfigPara.Comm == ETH_COMM) {
ETHTriggerRegister();
DBG_LOG("Trigger ETH re-registration immediately.\r\n");
}
else {
DBG_LOG("Unknown communication type.\r\n");
}
}
/***************************************************************************************** /*****************************************************************************************
* : DebugCmdRestoreFactory * : DebugCmdRestoreFactory
* : * :
@@ -863,7 +1080,7 @@ void DebugCmdTimeSync(int argc, char *argv[])
return; return;
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: time\r\n"); DBG_LOG("Debug Cmd: time args\r\n");
DBG_LOG(" brief --> Time synchronization.\r\n"); DBG_LOG(" brief --> Time synchronization.\r\n");
DBG_LOG(" args --> (time YYYY-MM-DD,hh:mm:ss)Set system time.\r\n\r\n"); DBG_LOG(" args --> (time YYYY-MM-DD,hh:mm:ss)Set system time.\r\n\r\n");
return; return;
@@ -910,15 +1127,15 @@ void DebugCmdQuerySensor(int argc, char *argv[])
if(GateWay->ConfigPara.Rs485Ch1.Enable == true && GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) { if(GateWay->ConfigPara.Rs485Ch1.Enable == true && GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) {
DBG_LOG("Query Rs485Ch1...\r\n"); DBG_LOG("Query Rs485Ch1...\r\n");
GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true; GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true;
GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN = 0; GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN = 0;
memset(GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType)); memset(GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType));
SComm1Para.SensorCnt = 0; SComm1Para.SensorCnt = 0;
} }
if(GateWay->ConfigPara.Rs485Ch2.Enable == true && GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) { if(GateWay->ConfigPara.Rs485Ch2.Enable == true && GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) {
DBG_LOG("Query Rs485Ch2...\r\n"); DBG_LOG("Query Rs485Ch2...\r\n");
GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true; GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true;
GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN = 0; GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN = 0;
memset(GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType)); memset(GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType));
SComm2Para.SensorCnt = 0; SComm2Para.SensorCnt = 0;
} }
} }
@@ -938,7 +1155,7 @@ void DebugCmdSelDebugChannel(int argc, char *argv[])
return; return;
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: dch\r\n"); DBG_LOG("Debug Cmd: dch args\r\n");
DBG_LOG(" brief --> Debug information output channel selection.\r\n"); DBG_LOG(" brief --> Debug information output channel selection.\r\n");
DBG_LOG(" args --> (dbg|ch1|ch2) default: dbg\r\n"); DBG_LOG(" args --> (dbg|ch1|ch2) default: dbg\r\n");
DBG_LOG(" dbg: On board debugging serial port.\r\n"); DBG_LOG(" dbg: On board debugging serial port.\r\n");
@@ -981,49 +1198,54 @@ void DebugCmdSelDebugChannel(int argc, char *argv[])
} }
/***************************************************************************************** /*****************************************************************************************
* : DebugCmdSetSvr * : DebugCmdSetLTENet
* : * : Cat1/4G服务器的地址和端口
* : argc, * : argc,
argv, argv,
* : * :
*****************************************************************************************/ *****************************************************************************************/
static void DebugCmdSetSvr(int argc, char *argv[]) static void DebugCmdSetLTENet(int argc, char *argv[])
{ {
DBG_LOG("\r\n"); DBG_LOG("\r\n");
int IP[4]; int IP[4];
int port; int port;
if(argc < 3) if(argc < 2)
return; return;
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: arg1 arg2\r\n"); DBG_LOG("Debug Cmd: ltenet arg1 arg2 arg3\r\n");
DBG_LOG(" brief --> Set the server IP address and port for 4G communication.\r\n"); DBG_LOG(" brief --> Set the server IP address and port for Cat1/4G communication.\r\n");
DBG_LOG(" arg1 --> (xx.xx.xx.xx) ip\r\n"); DBG_LOG(" arg1 --> password\r\n");
DBG_LOG(" arg2 --> port\r\n\r\n"); DBG_LOG(" arg2 --> (xx.xx.xx.xx) server ip\r\n");
DBG_LOG(" arg3 --> server port\r\n\r\n");
return; return;
} }
char *IpStr = argv[1];
if(strcmp(argv[1], "gxjt") != 0) {
DBG_LOG("Password Error\r\n");
return;
}
char *IpStr = argv[2];
int ret = sscanf(IpStr, "%d.%d.%d.%d", &IP[0], &IP[1], &IP[2], &IP[3]); int ret = sscanf(IpStr, "%d.%d.%d.%d", &IP[0], &IP[1], &IP[2], &IP[3]);
if(ret != 4) if(ret != 4)
return; return;
if(IP[0] > 0xff || IP[1] > 0xff || IP[2] > 0xff || IP[3] > 0xff) if(IP[0] > 0xff || IP[1] > 0xff || IP[2] > 0xff || IP[3] > 0xff)
return; return;
port = atoi(argv[2]); port = atoi(argv[3]);
if(port > 0xffff) if(port > 0xffff)
return; return;
GateWay->ConfigPara.SvrAddr[0] = IP[0]; GateWay->ConfigPara.LTENet.DestAddr[0] = IP[0];
GateWay->ConfigPara.SvrAddr[1] = IP[1]; GateWay->ConfigPara.LTENet.DestAddr[1] = IP[1];
GateWay->ConfigPara.SvrAddr[2] = IP[2]; GateWay->ConfigPara.LTENet.DestAddr[2] = IP[2];
GateWay->ConfigPara.SvrAddr[3] = IP[3]; GateWay->ConfigPara.LTENet.DestAddr[3] = IP[3];
GateWay->ConfigPara.SvrPort = port; GateWay->ConfigPara.LTENet.DestPort = port;
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
DBG_LOG("Set server ip and port completed.\r\n"); DBG_LOG("Set LTENet server ip and port completed.\r\n");
} }
/***************************************************************************************** /*****************************************************************************************
@@ -1044,7 +1266,7 @@ static void DebugCmdSetMac(int argc, char *argv[])
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: mac arg1 arg2\r\n"); DBG_LOG("Debug Cmd: mac arg1 arg2\r\n");
DBG_LOG(" brief --> Set the server IP address and port for 4G communication.\r\n"); DBG_LOG(" brief --> Set the server IP address and port for 4G communication.\r\n");
DBG_LOG(" arg1 --> psw\r\n"); DBG_LOG(" arg1 --> password\r\n");
DBG_LOG(" arg2 --> mac(xx-xx-xx-xx-xx-xx)\r\n\r\n"); DBG_LOG(" arg2 --> mac(xx-xx-xx-xx-xx-xx)\r\n\r\n");
return; return;
} }
@@ -1068,7 +1290,6 @@ static void DebugCmdSetMac(int argc, char *argv[])
DBG_LOG("Set gateway mac Address completed.\r\n"); DBG_LOG("Set gateway mac Address completed.\r\n");
} }
/***************************************************************************************** /*****************************************************************************************
* : DebugCmdGetPara * : DebugCmdGetPara
* : * :
@@ -1088,7 +1309,7 @@ static void DebugCmdGetPara(int argc, char *argv[])
} }
DBG_LOG("\r\n**********************************************************\r\n"); DBG_LOG("\r\n**********************************************************\r\n");
DBG_LOG("SoftWare V:%d.%d, HardWare V:%d.%d\r\n", SOFTWARE_VERSION / 10, SOFTWARE_VERSION % 10, HARDWARE_VERSION / 10, HARDWARE_VERSION % 10); DBG_LOG("SoftWare V:%d.%d, HardWare V:%d.%d\r\n", SOFTWARE_VERSION / 10, SOFTWARE_VERSION % 10, HARDWARE_VERSION / 10, HARDWARE_VERSION % 10);
DBG_LOG("GateWay MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n", DBG_LOG("GateWay MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
GateWay->ConfigPara.GwMac[0], GateWay->ConfigPara.GwMac[1], GateWay->ConfigPara.GwMac[2], GateWay->ConfigPara.GwMac[3], GateWay->ConfigPara.GwMac[4], GateWay->ConfigPara.GwMac[5]); GateWay->ConfigPara.GwMac[0], GateWay->ConfigPara.GwMac[1], GateWay->ConfigPara.GwMac[2], GateWay->ConfigPara.GwMac[3], GateWay->ConfigPara.GwMac[4], GateWay->ConfigPara.GwMac[5]);
DBG_LOG("Battery: %d%\r\n", GateWay->Battery); DBG_LOG("Battery: %d%\r\n", GateWay->Battery);
DBG_LOG("CommInf: %s\r\n", (GateWay->ConfigPara.Comm == CATONE_COMM) ? "Cat1" : "Eth"); DBG_LOG("CommInf: %s\r\n", (GateWay->ConfigPara.Comm == CATONE_COMM) ? "Cat1" : "Eth");
@@ -1096,34 +1317,42 @@ static void DebugCmdGetPara(int argc, char *argv[])
char Imei[20], Sim[32]; char Imei[20], Sim[32];
CatReadImeiOrSim(Imei, Sim); CatReadImeiOrSim(Imei, Sim);
DBG_LOG("Cat1 IMEI: %s\r\n", Imei); DBG_LOG("Cat1 IMEI: %s\r\n", Imei);
DBG_LOG("Cat1 SIM: %s\r\n", Sim); DBG_LOG("Cat1 SIM: %s\r\n", Sim);
} }
DBG_LOG("CommUnitReadInterval: %d\r\n", GateWay->ConfigPara.CommUnitReadInterval); DBG_LOG("CommUnitReadInterval: %d\r\n", GateWay->ConfigPara.CommUnitReadInterval);
DBG_LOG("Svr MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n", DBG_LOG("Svr MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
GateWay->SvrMac[0], GateWay->SvrMac[1], GateWay->SvrMac[2], GateWay->SvrMac[3], GateWay->SvrMac[4], GateWay->SvrMac[5]); GateWay->SvrMac[0], GateWay->SvrMac[1], GateWay->SvrMac[2], GateWay->SvrMac[3], GateWay->SvrMac[4], GateWay->SvrMac[5]);
DBG_LOG("Svr IP: %d.%d.%d.%d\r\n",
GateWay->ConfigPara.SvrAddr[0], GateWay->ConfigPara.SvrAddr[1], GateWay->ConfigPara.SvrAddr[2], GateWay->ConfigPara.SvrAddr[3]);
DBG_LOG("Svr Port: %d\r\n", GateWay->ConfigPara.SvrPort);
DBG_LOG("Register Status: %d\r\n", GateWay->SvrRegFlag); DBG_LOG("Register Status: %d\r\n", GateWay->SvrRegFlag);
/* LTENet (Cat1/4G) Parameters */
DBG_LOG("=== LTENet (Cat1/4G) Parameters ===\r\n");
DBG_LOG("DestAddr: %d.%d.%d.%d\r\n",
GateWay->ConfigPara.LTENet.DestAddr[0], GateWay->ConfigPara.LTENet.DestAddr[1], GateWay->ConfigPara.LTENet.DestAddr[2], GateWay->ConfigPara.LTENet.DestAddr[3]);
DBG_LOG("DestPort: %d\r\n", GateWay->ConfigPara.LTENet.DestPort);
DBG_LOG("LocalAddr: %d.%d.%d.%d (Reserved)\r\n",
GateWay->ConfigPara.LTENet.LocalAddr[0], GateWay->ConfigPara.LTENet.LocalAddr[1], GateWay->ConfigPara.LTENet.LocalAddr[2], GateWay->ConfigPara.LTENet.LocalAddr[3]);
DBG_LOG("LocalPort: %d (Reserved)\r\n", GateWay->ConfigPara.LTENet.LocalPort);
DBG_LOG("RS485Ch1 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n", DBG_LOG("RS485Ch1 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][1], GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][1],
GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][3], GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][3],
GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][5]); GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][5]);
DBG_LOG("RS485Ch1: %s, ", (GateWay->ConfigPara.Rs485Ch1.Enable == true) ? "Enable" : "Disable"); DBG_LOG("RS485Ch1: %s, ", (GateWay->ConfigPara.Rs485Ch1.Enable == true) ? "Enable" : "Disable");
DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) ? "Enable" : "Disable"); DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) ? "Enable" : "Disable");
DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch1.Power == true) ? "Enable" : "Disable"); DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch1.Power == true) ? "Enable" : "Disable");
DBG_LOG("Baudrate %d\r\n", GateWay->ConfigPara.Rs485Ch1.BaudRate); DBG_LOG("Baudrate %d\r\n", GateWay->ConfigPara.Rs485Ch1.BaudRate);
DBG_LOG("RS485Ch2 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n", DBG_LOG("RS485Ch2 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][1], GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][1],
GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][3], GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][3],
GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][5]); GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][5]);
DBG_LOG("RS485Ch2: %s, ", (GateWay->ConfigPara.Rs485Ch2.Enable == true) ? "Enable" : "Disable"); DBG_LOG("RS485Ch2: %s, ", (GateWay->ConfigPara.Rs485Ch2.Enable == true) ? "Enable" : "Disable");
DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) ? "Enable" : "Disable"); DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) ? "Enable" : "Disable");
DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch2.Power == true) ? "Enable" : "Disable"); DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch2.Power == true) ? "Enable" : "Disable");
DBG_LOG("Baudrate %d\r\n", GateWay->ConfigPara.Rs485Ch2.BaudRate); DBG_LOG("Baudrate %d\r\n", GateWay->ConfigPara.Rs485Ch2.BaudRate);
DBG_LOG("Lora: ch %d, rp %d, fc %d\r\n", GateWay->ConfigPara.Lora.ucChannel, GateWay->ConfigPara.Lora.RegPreamble, GateWay->ConfigPara.Lora.FreqCent); DBG_LOG("Lora: ch %d, rp %d, fc %d\r\n", GateWay->ConfigPara.Lora.ucChannel, GateWay->ConfigPara.Lora.RegPreamble, GateWay->ConfigPara.Lora.FreqCent);
DBG_LOG("LpCfg: CI:%dsec, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
LW_DEV_COLLECT_INTERVAL_MAX, LW_DEV_REPORT_INTERVAL_MAX, LW_DEV_ER_INTERVAL_MAX, LW_DEV_ER_TIME_MAX);
struct tm *stime; struct tm *stime;
uint32_t dwStamp = TimeTs(); uint32_t dwStamp = TimeTs();
stime = localtime(&dwStamp); stime = localtime(&dwStamp);
@@ -1133,7 +1362,7 @@ static void DebugCmdGetPara(int argc, char *argv[])
DBG_LOG("%d:",stime->tm_hour); DBG_LOG("%d:",stime->tm_hour);
DBG_LOG("%d:",stime->tm_min); DBG_LOG("%d:",stime->tm_min);
DBG_LOG("%d\r\n",stime->tm_sec); DBG_LOG("%d\r\n",stime->tm_sec);
DBG_LOG("**********************************************************\r\n"); DBG_LOG("**********************************************************\r\n");
} }
/***************************************************************************************** /*****************************************************************************************
@@ -1156,7 +1385,7 @@ static void DebugCmdCali(int argc, char *argv[])
if(argc > 1) { if(argc > 1) {
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: cali\r\n"); DBG_LOG("Debug Cmd: cali arg1\r\n");
DBG_LOG(" brief --> Calibrate the sensor.\r\n\r\n"); DBG_LOG(" brief --> Calibrate the sensor.\r\n\r\n");
DBG_LOG(" arg1 --> mac: communication unit Mac address.\r\n"); DBG_LOG(" arg1 --> mac: communication unit Mac address.\r\n");
DBG_LOG(" mac = (XX-XX-XX-XX-XX-XX), Calibrate specified MAC communication unit.\r\n"); DBG_LOG(" mac = (XX-XX-XX-XX-XX-XX), Calibrate specified MAC communication unit.\r\n");
@@ -1212,7 +1441,7 @@ static void DebugCmdCali(int argc, char *argv[])
return; return;
} }
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0], 6) == 0) { if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0], 6) == 0) {
if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) { if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
DBG_LOG("Internal communication unit 1 is turned off!\r\n"); DBG_LOG("Internal communication unit 1 is turned off!\r\n");
return; return;
@@ -1222,7 +1451,7 @@ static void DebugCmdCali(int argc, char *argv[])
return; return;
} }
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0], 6) == 0) { if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0], 6) == 0) {
if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) { if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) {
DBG_LOG("Internal communication unit 2 is turned off!\r\n"); DBG_LOG("Internal communication unit 2 is turned off!\r\n");
return; return;
@@ -1285,8 +1514,8 @@ static void DebugLaserConfig(int argc, char *argv[])
if(argc > 1) { if(argc > 1) {
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: laser\r\n"); DBG_LOG("Debug Cmd: laser arg1 arg2\r\n");
DBG_LOG(" brief --> Control laser cutting.\r\n\r\n"); DBG_LOG(" brief --> Control laser cutting.\r\n");
DBG_LOG(" arg1 --> mac: communication unit Mac address.\r\n"); DBG_LOG(" arg1 --> mac: communication unit Mac address.\r\n");
DBG_LOG(" mac = (XX-XX-XX-XX-XX-XX), Control specified MAC communication unit.\r\n"); DBG_LOG(" mac = (XX-XX-XX-XX-XX-XX), Control specified MAC communication unit.\r\n");
DBG_LOG(" arg2 --> state: on/off, Turn on or off the laser.\r\n\r\n"); DBG_LOG(" arg2 --> state: on/off, Turn on or off the laser.\r\n\r\n");
@@ -1311,7 +1540,7 @@ static void DebugLaserConfig(int argc, char *argv[])
if(strcmp(argv[2], "on") == 0 || strcmp(argv[2], "off") == 0) if(strcmp(argv[2], "on") == 0 || strcmp(argv[2], "off") == 0)
{ {
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0], 6) == 0) { if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0], 6) == 0) {
if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) { if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
DBG_LOG("Internal communication unit 1 is turned off!\r\n"); DBG_LOG("Internal communication unit 1 is turned off!\r\n");
return; return;
@@ -1321,7 +1550,7 @@ static void DebugLaserConfig(int argc, char *argv[])
return; return;
} }
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0], 6) == 0) { if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0], 6) == 0) {
if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) { if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) {
DBG_LOG("Internal communication unit 2 is turned off!\r\n"); DBG_LOG("Internal communication unit 2 is turned off!\r\n");
return; return;
@@ -1410,10 +1639,10 @@ static void DebugCmdLPConfig(int argc, char *argv[])
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: lpcfg arg1 arg2 arg3 arg4\r\n"); DBG_LOG("Debug Cmd: lpcfg arg1 arg2 arg3 arg4\r\n");
DBG_LOG(" brief --> Configure low-power device parameters.\r\n"); DBG_LOG(" brief --> Configure low-power device parameters.\r\n");
DBG_LOG(" arg1 --> Collect interval\r\n"); DBG_LOG(" arg1 --> Collect interval(30~7200 second)\r\n");
DBG_LOG(" arg2 --> Report interval\r\n"); DBG_LOG(" arg2 --> Report interval(5~720 minute)\r\n");
DBG_LOG(" arg3 --> Emergency reporting interval\r\n"); DBG_LOG(" arg3 --> Emergency reporting interval(1~5 minute)\r\n");
DBG_LOG(" arg4 --> Emergency reporting time\r\n\r\n"); DBG_LOG(" arg4 --> Emergency reporting time(10~120 minute)\r\n\r\n");
return; return;
} }
@@ -1460,7 +1689,7 @@ static void DebugCmdLPConfig(int argc, char *argv[])
/***************************************************************************************** /*****************************************************************************************
* : DebugCmdLPConfig * : DebugCmdLPConfig
* : * : Lora参数配置
* : argc, * : argc,
argv, argv,
* : * :
@@ -1472,7 +1701,7 @@ static void DebugLoraConfig(int argc, char *argv[])
return; return;
if(strcmp(argv[1], "?") == 0) { if(strcmp(argv[1], "?") == 0) {
DBG_LOG("Debug Cmd: Lora arg1 arg2\r\n"); DBG_LOG("Debug Cmd: lora arg1 arg2\r\n");
DBG_LOG(" brief --> Configure Lora parameters.\r\n"); DBG_LOG(" brief --> Configure Lora parameters.\r\n");
DBG_LOG(" arg1 --> ch: Channel--para=(0~16)\r\n"); DBG_LOG(" arg1 --> ch: Channel--para=(0~16)\r\n");
DBG_LOG(" pw: Power--para=(0~20)\r\n"); DBG_LOG(" pw: Power--para=(0~20)\r\n");
@@ -1480,6 +1709,7 @@ static void DebugLoraConfig(int argc, char *argv[])
DBG_LOG(" sf: SpreadFactor--para=(6~12)\r\n"); DBG_LOG(" sf: SpreadFactor--para=(6~12)\r\n");
DBG_LOG(" ec: ErrorCoding--para=(1~4)\r\n"); DBG_LOG(" ec: ErrorCoding--para=(1~4)\r\n");
DBG_LOG(" rp: RegPreamble--para=(1~32)\r\n"); DBG_LOG(" rp: RegPreamble--para=(1~32)\r\n");
DBG_LOG(" fc: FreqCent--para=(410000000~525000000)\r\n");
DBG_LOG(" o: on/off\r\n"); DBG_LOG(" o: on/off\r\n");
DBG_LOG(" arg2 --> para\r\n"); DBG_LOG(" arg2 --> para\r\n");
@@ -1570,7 +1800,18 @@ static void DebugLoraConfig(int argc, char *argv[])
return; return;
} }
} }
if(GateWay->ConfigPara.Lora.OnOff) if(strcmp(argv[1], "fc") == 0){
uint32_t fc = atoi(argv[2]);
if(LoraSetFreqCent(fc)) {
GateWay->ConfigPara.Lora.FreqCent = fc;
DBG_LOG(" Lora FreqCent is configured successfully!\r\n");
}
else {
DBG_LOG("Lora Para Error!\r\n");
return;
}
}
if(GateWay->ConfigPara.Lora.OnOff == true)
LoraInit(); LoraInit();
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
DBG_LOG("Lora reinitializes.\r\n"); DBG_LOG("Lora reinitializes.\r\n");
@@ -1609,7 +1850,19 @@ void DebugCmdHelp(int argc, char *argv[])
len = strlen("culs ?\r\n"); len = strlen("culs ?\r\n");
memcpy(Data, "culs ?\r\n", len); memcpy(Data, "culs ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
len = strlen("excu ?\r\n");
memcpy(Data, "excu ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("exdel ?\r\n");
memcpy(Data, "exdel ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("exls ?\r\n");
memcpy(Data, "exls ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("comm ?\r\n"); len = strlen("comm ?\r\n");
memcpy(Data, "comm ?\r\n", len); memcpy(Data, "comm ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
@@ -1630,22 +1883,14 @@ void DebugCmdHelp(int argc, char *argv[])
memcpy(Data, "hinf ?\r\n", len); memcpy(Data, "hinf ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
// len = strlen("res ?\r\n"); len = strlen("res ?\r\n");
// memcpy(Data, "res ?\r\n", len); memcpy(Data, "res ?\r\n", len);
// DebugAnalyze(GateWay, Data, len);
len = strlen("sct ?\r\n");
memcpy(Data, "sct ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
len = strlen("time ?\r\n"); len = strlen("time ?\r\n");
memcpy(Data, "time ?\r\n", len); memcpy(Data, "time ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
len = strlen("svr ?\r\n");
memcpy(Data, "svr ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("qs ?\r\n"); len = strlen("qs ?\r\n");
memcpy(Data, "qs ?\r\n", len); memcpy(Data, "qs ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
@@ -1654,33 +1899,78 @@ void DebugCmdHelp(int argc, char *argv[])
memcpy(Data, "dch ?\r\n", len); memcpy(Data, "dch ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
len = strlen("ltenet ?\r\n");
memcpy(Data, "ltenet ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("mac ?\r\n");
memcpy(Data, "mac ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("para ?\r\n"); len = strlen("para ?\r\n");
memcpy(Data, "para ?\r\n", len); memcpy(Data, "para ?\r\n", len);
DebugAnalyze(GateWay, Data, len); DebugAnalyze(GateWay, Data, len);
len = strlen("cali ?\r\n");
memcpy(Data, "cali ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("laser ?\r\n");
memcpy(Data, "laser ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("lpcfg ?\r\n");
memcpy(Data, "lpcfg ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("lora ?\r\n");
memcpy(Data, "lora ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("reboot ?\r\n");
memcpy(Data, "reboot ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("up ?\r\n");
memcpy(Data, "up ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("reg ?\r\n");
memcpy(Data, "reg ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
len = strlen("eth ?\r\n");
memcpy(Data, "eth ?\r\n", len);
DebugAnalyze(GateWay, Data, len);
} }
const DBGFunType DebugFun[DEBUG_CMD_CNT] = { const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
"help", DebugCmdHelp, "help", DebugCmdHelp,
"main", DebugCmdMainOnOff, "main", DebugCmdMainOnOff,
"cat1", DebugCmdCat1OnOff, "cat1", DebugCmdCat1OnOff,
"rs485", DebugCmdRS485Ctrl, "rs485", DebugCmdRS485Ctrl,
"cudel", DebugCmdDelCommUnit, "cudel", DebugCmdDelCommUnit,
"culs", DebugCmdLsCommUnit, "culs", DebugCmdLsCommUnit,
"excu", DebugCmdExclCommUnit,
"exdel", DebugCmdDelExclCommUnit,
"exls", DebugCmdLsExclCommUnit,
"comm", DebugCmdSetComm, "comm", DebugCmdSetComm,
"sct", DebugCmdSetCollectTime, "sct", DebugCmdSetCollectTime,
// "his", DebugCmdReadHisData, "his", DebugCmdReadHisData,
"fmt", DebugCmdDelHisData, "fmt", DebugCmdDelHisData,
"hinf", DebugCmdGetHisInfo, "hinf", DebugCmdGetHisInfo,
// "res", DebugCmdRestoreFactory, "res", DebugCmdRestoreFactory,
"time", DebugCmdTimeSync, "time", DebugCmdTimeSync,
"qs", DebugCmdQuerySensor, "qs", DebugCmdQuerySensor,
"dch", DebugCmdSelDebugChannel, "dch", DebugCmdSelDebugChannel,
"svr", DebugCmdSetSvr, "ltenet", DebugCmdSetLTENet,
"mac", DebugCmdSetMac, "mac", DebugCmdSetMac,
"para", DebugCmdGetPara, "para", DebugCmdGetPara,
"cali", DebugCmdCali, "cali", DebugCmdCali,
"laser", DebugLaserConfig, "laser", DebugLaserConfig,
"lpcfg", DebugCmdLPConfig, "lpcfg", DebugCmdLPConfig,
"lora", DebugLoraConfig, "lora", DebugLoraConfig,
"reboot", DebugCmdReboot, "reboot", DebugCmdReboot,
"up", DebugCmdUpload,
"reg", DebugCmdRegister,
}; };
@@ -0,0 +1,5 @@
# GateWay_Debug
# 适用于Gateway项目
# 单片机HC32F460
# 转换为模块仓库 2026-05-14
@@ -0,0 +1,130 @@
# ---> IAR
# Compiled binaries
*.o
*.bin
*.elf
*.hex
*.map
*.out
*.obj
# Trash
*.bak
thumbs.db
*.~*
# IAR Settings
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos
# IAR Debug Exe
**/Exe/*.sim
# IAR Debug Obj
**/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*
# IAR project "Debug" directory
Debug/
# IAR project "Release" directory
Release/
# IAR project settings directory
settings/
# IAR backup files
Backup*
# IAR .dep files
*.dep
# ---> IAR_EWARM
# gitignore template for the IAR EWARM
# website: https://www.iar.com/knowledge/support/technical-notes/ide/which-files-should-be-version-controlled/
# Some tools will put the EWARM files
# under a subdirectory with the same name
# as the configuration.
# Example
# EWARM/Config1/Obj /List /Exe
# EWARM/Config2/Obj /List /Exe
EWARM/**/Obj
EWARM/**/List
EWARM/**/Exe
# Autogenerated project files
*.dep
*.ewt
# Autogenerated folder for debugger
EWARM/settings
# ---> uVision
# git ignore file for Keil µVision Project
# µVision 5 and µVision 4 Project screen layout file
*.uvguix.*
*.uvgui.*
# Listing Files
*.i
*.lst
*.m51
*.m66
*.map
# Object Files
*.axf
*.b[0-2][0-9]
*.b3[0-1]
*.bak
*.build_log.htm
*.crf
*.d
*.dep
*.elf
*.htm
*.iex
*.lnp
*.o
*.obj
*.sbr
# Firmware Files
*.bin
*.h86
*.hex
# Build Files
.bat
# Debugger Files
.ini
# JLink Files
JLinkLog.txt
# Other Files
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
@@ -0,0 +1,2 @@
# SDCard
-615
View File
@@ -1,615 +0,0 @@
#include "SHT20.h"
SHT20Var_t SHT20;
//---------- Defines -----------------------------------------------------------
// CRC 累加和校验常量
const uint32_t POLYNOMIAL = 0x131; //P(x)=x^8+x^5+x^4+1 = 100110001
/*
************************************************************
* 函数名称: SHT2x_CheckCrc
*
* 函数功能: 检查数据正确性
*
* 入口参数: data:读取到的数据
* nbrOfBytes:需要校验的数量
* checksum:读取到的校对比验值
*
* 返回参数: 校验结果
*
* 说明: 0-成功 1-失败
************************************************************
*/
uint8_t SHT2x_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum)
{
uint8_t crc = 0;
uint8_t bit = 0;
uint8_t byteCtr = 0;
//calculates 8-Bit checksum with given polynomial
for(byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr) {
crc ^= (data[byteCtr]);
for ( bit = 8; bit > 0; --bit) {
if (crc & 0x80)
crc = (crc << 1) ^ POLYNOMIAL;
else
crc = (crc << 1);
}
}
if(crc != checksum)
return 1;
return 0;
}
void delay_us(int dlycnt)
{
for(int i = 0; i < dlycnt; i++) {
uint8_t temp = 10;
while(temp--);
}
}
#ifdef I2C_SOFTWARE
#define ACK 0 //应答信号
#define NACK 1 //非应答信号
#define SHT20_IN_SDA SHT20_I2C_SDA_Read() //读取SDA值
#define IIC_Delay() delay_us(10) //时钟延时
/*================================================================
[ Name ]void IO_I2CInit(void)
[Function]I2C初始化 空闲状态
[ Notes ]
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void IO_I2CInit(void)
{
//
}
//
/*================================================================
[ Name ]SHT20_I2C_SDA_Read
[Function]读取SDA数据线上值
[ Notes ]
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
uint8_t SHT20_I2C_SDA_Read(void)
{
SHT20_SDA_IN();
if(SHT20_SDA_GET())
return 1;
else
return 0;
}
/*================================================================
[ Name ]I2CStart
[Function]开始
[ Notes ]
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void I2CStart(void)
{
//uint8_t retval;
SHT20_SDA_OUT(); //设置成输出
//SHT20_SCL_OUT();
SHT20_I2C_SDA_HIGH(); //为SDA下降启动做准备
SHT20_I2C_SCL_HIGH(); //在SCL高电平时,SDA为下降沿时候总线启动
IIC_Delay();
SHT20_I2C_SDA_LOW(); //突变,总线启动
IIC_Delay();
SHT20_I2C_SCL_LOW();
IIC_Delay();
//SHT20_SDA_IN(); //设置成输入
// if(SHT20_IN_SDA)
// {
// retval= NACK;
// }
// else
// {
// retval= ACK;
// }
// retval=retval;
}
/*================================================================
[ Name ]I2CStop
[Function]结束
[ Notes ]
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void I2CStop(void)
{
SHT20_SDA_OUT(); //设置成输出
SHT20_I2C_SDA_LOW(); //为SDA上升做准备
SHT20_I2C_SCL_LOW();
IIC_Delay();
SHT20_I2C_SCL_HIGH(); //在SCL高电平时,SDA为上升沿时候总线停止
IIC_Delay();
SHT20_I2C_SDA_HIGH(); //突变,总线停止
IIC_Delay();
}
/*================================================================
[ Name ]I2C_Write_Byte
[Function]写一个字节 返回ACK或NACK
[ Notes ]从高到低发
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
uint8_t I2C_Write_Byte(uint8_t Write_Byte) //Sendbyte
{
uint8_t i,retval=3;
SHT20_SDA_OUT(); //设置成输出
//SHT20_SCL_OUT() ;
for(i = 0;i < 8;i++) {
if(Write_Byte & 0x80)
SHT20_I2C_SDA_HIGH(); //判断发送位,先发送高位
else
SHT20_I2C_SDA_LOW();
//IIC_Delay();
SHT20_I2C_SCL_HIGH(); //为SCL下降做准备
IIC_Delay();
SHT20_I2C_SCL_LOW(); //突变,将数据位发送过去
IIC_Delay();
Write_Byte<<=1; //数据左移一位
} //字节发送完成,开始接收应答信号
IIC_Delay();
SHT20_I2C_SDA_HIGH(); //释放数据线
IIC_Delay();
SHT20_SDA_IN(); //设置成输入
//IIC_Delay();
SHT20_I2C_SCL_HIGH(); //为SCL下降做准备
IIC_Delay();
if(SHT20_IN_SDA)
retval= NACK;
else
retval= ACK;
SHT20_I2C_SCL_LOW();
IIC_Delay();
return retval;
}
//
/*================================================================
[ Name ]I2C_Read_Byte
[Function]读一个字节,入库参数用于控制应答状态 ACK或NAC
[ Notes ]从高到低
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
uint8_t I2C_Read_Byte(uint8_t AckValue)//receivebyte
{
uint8_t i;
uint8_t RXDATA=0;
// SHT20_SDA_OUT(); //设置成输出
// SHT20_I2C_SDA_HIGH(); //首先置数据线为高电平
// SHT20_I2C_SCL_LOW();
SHT20_SDA_IN(); //设置成输入
for(i = 0;i < 8;i++) {
SHT20_I2C_SCL_HIGH(); //突变
IIC_Delay();
RXDATA <<= 1; //读入数据,高位在前
if(SHT20_IN_SDA) RXDATA |= 0x01; //收到高电平
else RXDATA &= 0xfe;
IIC_Delay();
SHT20_I2C_SCL_LOW();
IIC_Delay();
} //数据接收完成
SHT20_SDA_OUT();
if(AckValue)
SHT20_I2C_SDA_HIGH();
else
SHT20_I2C_SDA_LOW();
IIC_Delay();
SHT20_I2C_SCL_HIGH();
IIC_Delay();
SHT20_I2C_SCL_LOW();
IIC_Delay();
return RXDATA; //返回读取到的数据
}
/*================================================================
[ Name ]SHT20_SoftReset
[Function]SHT20软件复位
[ Notes ]从高到低
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void SHT20_Reset(void)
{
// IO_I2CInit(); //I2C initialize
I2CStart(); //start I2C
I2C_Write_Byte(SHT20_ADDRESS&0xfe); //I2C address + write
I2C_Write_Byte(0xfe); //soft reset
I2CStop(); //stop I2C
}
/*================================================================
[ Name ]SET_Resolution
[Function]写寄存器 设置分辨率
[ Notes ]从高到低
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void SET_Resolution(void)
{
I2CStart(); //Start I2C
if(I2C_Write_Byte(SHT20_ADDRESS&0xfe) == ACK) { //I2C address + write + ACK
if(I2C_Write_Byte(0xe6) == ACK) { //写用户寄存器
if(I2C_Write_Byte(0x83) == ACK)
__NOP(); //设置分辨率 11bit RH% 测量时间:12ms(typ.) & 11bit T测量时间:9ms(typ.)
}
}
I2CStop(); //Stop I2C
}
/*================================================================
[ Name ]ReadSht20
[Function]非主机模式,读取温湿度值
[ Notes ]入口控制读取温度或湿度 复位需要15ms 温度转换最大需要85ms
[ Author ]LZH SHT20上电后等待20ms 再读取sht20
[ Data ]2016.06.22
================================================================*/
float SHT2x_MeasureHM(uint8_t whatdo)
{
float temp;
uint8_t MSB,LSB,checksum=0,checktemp[2];
float Humidity,Temperature;
uint32_t waitt= 1000;
//SET_Resolution(); //此处之前出过问题 所以屏蔽掉
I2CStart();
if(I2C_Write_Byte(SHT20_ADDRESS&0xfe)==ACK) { //I2C address + write + ACK
if(I2C_Write_Byte(whatdo)==ACK) { //Command
do{
delay_us(100); //加入超时
I2CStart();
if(--waitt==0)
break;
} while(I2C_Write_Byte(SHT20_ADDRESS|0x01) == NACK); //I2C address + read + NACK
if(waitt != 0) {
MSB = I2C_Read_Byte(ACK); //Data(MSB)
LSB = I2C_Read_Byte(ACK); //Data(LSB)
checksum=I2C_Read_Byte(NACK); //Checksum + NACK 累加和校验值
I2CStop(); //Stop I2C
checktemp[0]=MSB;
checktemp[1]=LSB;
if(SHT2x_CheckCrc(checktemp,2,checksum)) { //累加和校验成功
LSB &= 0xfc; //Data (LSB) 后两位清零
temp = MSB*256 + LSB; //十六进制转十进制
if (whatdo==((uint8_t)0xf5)) { //No Hold Master Mode,read humidity
/*-- calculate relative humidity [%RH] --*/
Humidity =(temp*125)/65536-6; //公式: RH%= -6 + 125 * SRH/2^16
return Humidity; //返回:humidity
}
else{ //No Hold Master Mode,read temperature
/*-- calculate temperature [℃] --*/
Temperature = (temp*175.72)/65536-46.85; //公式:T= -46.85 + 175.72 * ST/2^16
return Temperature; //返回:temperature
}
}
}
}
}
I2CStop(); //CT add
return 0;
}
//
/********************************************************
[ Name ]GetMiddleNum
[Function] 中值滤波
[ Notes ] 传入数据buf bArray, iFilterLen滤波数据长度
[ Author ] CSDN
[ Data ]2018.10.25
**********************************************************/
float GetMiddleNum(float * bArray, uint8_t iFilterLen)
{
uint8_t i,j;// 循环变量
float bTemp;
if(iFilterLen>100)
return 0;
// 用冒泡法对数组进行排序
for (j = 0; j < iFilterLen - 1; j ++) {
for (i = 0; i < iFilterLen - j - 1; i ++) {
if (bArray[i] > bArray[i + 1]) {
// 互换
bTemp = bArray[i];
bArray[i] = bArray[i + 1];
bArray[i + 1] = bTemp;
}
}
}
// 计算中值
if ((iFilterLen & 1) > 0) {
// 数组有奇数个元素,返回中间一个元素
bTemp = bArray[(iFilterLen -1) / 2];
}
else {
// 数组有偶数个元素,返回中间两个元素平均值
bTemp = (bArray[iFilterLen / 2-1] + bArray[iFilterLen / 2 ]) / 2;
}
return bTemp;
}
//
/********************************************************
[ Name ]ReadSht20_Medium
[Function] 获取中值
[ Notes ] 读取完后关闭上拉 设为低 (解决干扰问题)
[ Author ]
[ Data ]2018.10.25
**********************************************************/
float ReadSht20_Medium (void)
{
float arry3[3];
//SHT20_I2C_SET_PULL_UP(); //开启引脚上拉
for(uint8_t ui=0; ui<3; ui++) {
arry3[ui]= SHT2x_MeasureHM(SHT20_Measurement_T_HM);
delay_us(20);
//printf("sht origin %.2f \r\n",arry3[ui]);
}
float retv = GetMiddleNum(arry3, 3);
#ifdef I2C_SOFTWARE
//SHT20_I2C_SET_PULL_NO(); //关闭上拉
SHT20_I2C_LOW(); //读取完温度后拉低
#endif
return retv;
}
#else
/*
************************************************************
* 函数名称: SHT20_reset
*
* 函数功能: SHT20复位
*
* 入口参数: 无
*
* 返回参数: 无
*
* 说明:
************************************************************
*/
void SHT20_Reset(void)
{
uint8_t Data = SHT20_SOFT_RESET;
Sht20_Reg_Write(SHT20_ADDRESS, &Data, 1);
Sht20_Delay(15);
}
/*
************************************************************
* 函数名称: SHT20_read_user_reg
*
* 函数功能: SHT20读取用户寄存器
*
* 入口参数: 无
*
* 返回参数: 读取到的用户寄存器的值
*
* 说明:
************************************************************
*/
uint8_t SHT20_read_user_reg(void)
{
uint8_t val = 0;
uint8_t reg = SHT20_READ_REG;
Sht20_Read(SHT20_ADDRESS, &reg, &val, 1);
return val;
}
/*
************************************************************
* 函数名称: SHT2x_CalcTemperatureC
*
* 函数功能: 温度计算
*
* 入口参数: u16sT:读取到的温度原始数据
*
* 返回参数: 计算后的温度数据
*
* 说明:
************************************************************
*/
float SHT2x_CalcTemperatureC(uint16_t u16sT)
{
float temperatureC = 0; // variable for result
u16sT &= ~0x0003; // clear bits [1..0] (status bits)
//-- calculate temperature [℃] --
temperatureC = -46.85 + 175.72 / 65536 * (float)u16sT; //T= -46.85 + 175.72 * ST/2^16
return temperatureC;
}
/*
************************************************************
* 函数名称: SHT2x_CalcRH
*
* 函数功能: 湿度计算
*
* 入口参数: u16sRH:读取到的湿度原始数据
*
* 返回参数: 计算后的湿度数据
*
* 说明:
************************************************************
*/
float SHT2x_CalcRH(uint16_t u16sRH)
{
float humidityRH = 0; // variable for result
u16sRH &= ~0x0003; // clear bits [1..0] (status bits)
//-- calculate relative humidity [%RH] --
//humidityRH = -6.0 + 125.0/65536 * (float)u16sRH; // RH= -6 + 125 * SRH/2^16
humidityRH = ((float)u16sRH * 0.00190735) - 6;
return humidityRH;
}
/*
************************************************************
* 函数名称: SHT2x_MeasureHM
*
* 函数功能: 测量温湿度
*
* 入口参数: cmd:测量温度还是湿度
*
* 返回参数: 测量结果
*
* 说明:
************************************************************
*/
float SHT2x_MeasureHM(uint8_t cmd)
{
uint8_t checksum = 0; //checksum
uint8_t data[3]; //data array for checksum verification
uint16_t tmp = 0;
float t = 0;
Sht20_Read(SHT20_ADDRESS, &cmd, data, 3);
checksum = data[2];
if(SHT2x_CheckCrc(data, 2, checksum) == 0) {
tmp = (data[0] << 8) + data[1];
if(cmd == SHT20_Measurement_T_NHM)
t = SHT2x_CalcTemperatureC(tmp);
else
t = SHT2x_CalcRH(tmp);
}
return t;
}
#endif
/*
************************************************************
* 函数名称: SHT20_GetValue
*
* 函数功能: 获取温湿度数据
*
* 入口参数: 无
*
* 返回参数: 无
*
* 说明: 温湿度结果保存在SHT20结构体里
************************************************************
*/
void SHT20_GetValue(float *Tempreture, float *Humidity)
{
if(Tempreture != NULL) {
*Tempreture = SHT20.Tempreture;
}
if(Humidity != NULL) {
*Humidity = SHT20.Humidity;
}
//SHT20_reset();
}
void SHT20Start(void)
{
memset(&SHT20, 0x00, sizeof(SHT20));
SHT20.Sht20Status = SHT20_INIT;
}
void SHT20LoopHandler(void)
{
uint8_t ret;
uint8_t rData[3];
switch(SHT20.Sht20Status) {
case SHT20_IDLE:
break;
case SHT20_INIT:
SHT20_Reset();
SHT20.Sht201mSDelayCnt = 200;
SHT20.Sht20Status = SHT20_READ_HUMI;
break;
case SHT20_READ_TEMPR:
if(SHT20.Sht201mSDelayCnt > 0)
break;
SHT20.Cmd = SHT20_Measurement_T_NHM;
ret = SHT20_StartMeas(SHT20_ADDRESS, &SHT20.Cmd);
if(ret == true) {
SHT20.Sht201mSDelayCnt = 90;
SHT20.Sht20Status = SHT20_READ_DATA;
}
else {
SHT20.Sht201mSDelayCnt = 1000;
SHT20.Sht20Status = SHT20_INIT;
}
break;
case SHT20_READ_HUMI:
if(SHT20.Sht201mSDelayCnt > 0)
break;
SHT20.Cmd = SHT20_Measurement_RH_NHM;
ret = SHT20_StartMeas(SHT20_ADDRESS, &SHT20.Cmd);
if(ret == true) {
SHT20.Sht201mSDelayCnt = 90;
SHT20.Sht20Status = SHT20_READ_DATA;
}
else {
SHT20.Sht201mSDelayCnt = 1000;
SHT20.Sht20Status = SHT20_INIT;
}
break;
case SHT20_READ_DATA:
if(SHT20.Sht201mSDelayCnt > 0)
break;
ret = SHT20_Readata(SHT20_ADDRESS, rData, 3);
if(ret == true) {
if(SHT2x_CheckCrc(rData, 2, rData[2]) == 0) {
uint16_t tmp = (rData[0] << 8) + rData[1];
if(SHT20.Cmd == SHT20_Measurement_T_NHM) {
SHT20.Tempreture = SHT2x_CalcTemperatureC(tmp);
SHT20.Sht20Status = SHT20_READ_HUMI;
}
else {
SHT20.Humidity = SHT2x_CalcRH(tmp);
SHT20.Sht20Status = SHT20_READ_TEMPR;
}
SHT20.Sht201mSDelayCnt = 5;
}
}
else {
SHT20.Sht201mSDelayCnt = 1000;
SHT20.Sht20Status = SHT20_INIT;
}
}
}
void SHT201mSRoutine(void)
{
if(SHT20.Sht201mSDelayCnt > 0)
SHT20.Sht201mSDelayCnt--;
}
-156
View File
@@ -1,156 +0,0 @@
/***************************************************************
* File name : SHT20.h
* Description : SHT20 Humidity and Temperature Sensors
* M C U : STM32L051XX
* Compiler : Keil uVision V5.00a
* Created by :
* Copyright : Copyright(c) 2018
* Created data : 2018.03.16
* Modified data: 2018.03.16
* Vision : V1.0
*****************************************************************/
/*****************Function Declaration*************************/
/*----define to easier to use-----*/
#include <stdint.h>
#include "bsp.h"
typedef enum {
SHT20_IDLE,
SHT20_INIT,
SHT20_READ_TEMPR,
SHT20_READ_HUMI,
SHT20_READ_DATA
}SHT20Status_m;
typedef struct {
SHT20Status_m Sht20Status;
int Sht201mSDelayCnt;
float Tempreture;
float Humidity;
uint8_t Cmd;
}SHT20Var_t;
#define SHT20_Write_Add 0x80
#define SHT20_Read_Add 0x81
#define SHT20_Measurement_RH_HM 0XE5
#define SHT20_Measurement_T_HM 0XE3
#define SHT20_Measurement_RH_NHM 0XF5 //非主机模式地址
#define SHT20_Measurement_T_NHM 0XF3 //非主机模式地址
#define SHT20_READ_REG 0XE7
#define SHT20_WRITE_REG 0XE6
#define SHT20_SOFT_RESET 0XFE
//#define I2C_SOFTWARE
#ifdef I2C_SOFTWARE
#define SHT20_ADDRESS 0X80
#define SHT20_SDA_IN() I2C_SDA_IN() //设置引脚输入模式
#define SHT20_SDA_OUT() I2C_SDA_OUT() //设置引脚输出模式
#define SHT20_SDA_GET() I2C_SDA_GET()
#define SHT20_I2C_SDA_LOW() I2C_SDA_LOW()
#define SHT20_I2C_SCL_LOW() I2C_SCL_LOW()
#define SHT20_I2C_SDA_HIGH() I2C_SDA_HIGH()
#define SHT20_I2C_SCL_HIGH() I2C_SCL_HIGH()
#define SHT20_I2C_LOW() {SHT20_I2C_SDA_LOW();SHT20_I2C_SCL_LOW();}
/*================================================================
[ Name ]void IO_I2CInit(void)
[Function]I2C初始化 空闲状态
[ Notes ]
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void IO_I2CInit(void);
/*================================================================
[ Name ]I2CStart
[Function]开始
[ Notes ]
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void I2CStart(void);
/*================================================================
[ Name ]I2CStop
[Function]结束
[ Notes ]
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void I2CStop(void);
/*================================================================
[ Name ]I2C_Write_Byte
[Function]写一个字节 返回ACK或NACK
[ Notes ]从高到低发
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
uint8_t I2C_Write_Byte(uint8_t Write_Byte);
/*================================================================
[ Name ]I2C_Read_Byte
[Function]读一个字节,入库参数用于控制应答状态 ACK或NAC
[ Notes ]从高到低
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
uint8_t I2C_Read_Byte(uint8_t AckValue);
/*================================================================
[ Name ]SHT20_SoftReset
[Function]SHT20软件复位
[ Notes ]从高到低
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void SHT20_SoftReset(void);
/*================================================================
[ Name ]SET_Resolution
[Function]写寄存器 设置分辨率
[ Notes ]从高到低
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
void SET_Resolution(void);
/*================================================================
[ Name ]ReadSht20
[Function]非主机模式,读取温湿度值
[ Notes ]入口控制读取温度或湿度
[ Author ]LZH
[ Data ]2016.06.22
================================================================*/
float ReadSht20(char whatdo);
float ReadSht20_Medium (void);
#else
#define SHT20_ADDRESS 0X40
#define Sht20_Reg_Write(DevAddr, RegData, rLen) I2C_Write(DevAddr, NULL, RegData, rLen)
#define Sht20_Read(DevAddr, RegAddr, rData, rLen) I2C_Read(DevAddr, RegAddr, rData, rLen)
#define Sht20_Delay(x)
void SHT20_reset(void);
#endif
void SHT20_GetValue(float *Tempreture, float *Humidity);
void SHT20Start(void);
void SHT20LoopHandler(void);
void SHT201mSRoutine(void);
@@ -0,0 +1,130 @@
# ---> IAR
# Compiled binaries
*.o
*.bin
*.elf
*.hex
*.map
*.out
*.obj
# Trash
*.bak
thumbs.db
*.~*
# IAR Settings
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos
# IAR Debug Exe
**/Exe/*.sim
# IAR Debug Obj
**/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*
# IAR project "Debug" directory
Debug/
# IAR project "Release" directory
Release/
# IAR project settings directory
settings/
# IAR backup files
Backup*
# IAR .dep files
*.dep
# ---> IAR_EWARM
# gitignore template for the IAR EWARM
# website: https://www.iar.com/knowledge/support/technical-notes/ide/which-files-should-be-version-controlled/
# Some tools will put the EWARM files
# under a subdirectory with the same name
# as the configuration.
# Example
# EWARM/Config1/Obj /List /Exe
# EWARM/Config2/Obj /List /Exe
EWARM/**/Obj
EWARM/**/List
EWARM/**/Exe
# Autogenerated project files
*.dep
*.ewt
# Autogenerated folder for debugger
EWARM/settings
# ---> uVision
# git ignore file for Keil µVision Project
# µVision 5 and µVision 4 Project screen layout file
*.uvguix.*
*.uvgui.*
# Listing Files
*.i
*.lst
*.m51
*.m66
*.map
# Object Files
*.axf
*.b[0-2][0-9]
*.b3[0-1]
*.bak
*.build_log.htm
*.crf
*.d
*.dep
*.elf
*.htm
*.iex
*.lnp
*.o
*.obj
*.sbr
# Firmware Files
*.bin
*.h86
*.hex
# Build Files
.bat
# Debugger Files
.ini
# JLink Files
JLinkLog.txt
# Other Files
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
@@ -0,0 +1,8 @@
ISC License:
Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
Copyright (c) 1995-2003 by Internet Software Consortium
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,2 @@
# sx127x
@@ -3,7 +3,7 @@
#if (LORA_MODULE == SX1278W1) #if (LORA_MODULE == SX1278W1)
static Sx1276Type_t LoRaPara = { static Sx1276Type_t LoRaPara = {
.ucChannel = 4, .ucChannel = 8,
.dwFreqHz = FREQ_CENT, .dwFreqHz = FREQ_CENT,
.ucPower = 20, .ucPower = 20,
.SignalBw = SX1276_BW_250K, .SignalBw = SX1276_BW_250K,
@@ -62,8 +62,7 @@ void SX1276WriteBuffer(uint8_t ucAddr, uint8_t *pucBuff, uint8_t ucLen)
LORA_SPI_READ_WRITE(pucBuff[ucCnt]); LORA_SPI_READ_WRITE(pucBuff[ucCnt]);
} }
LORA_SPI_NSS_SET(); LORA_SPI_NSS_SET();
} }
void SX1276Write(uint8_t ucAddr, uint8_t ucData) void SX1276Write(uint8_t ucAddr, uint8_t ucData)
{ {
SX1276WriteBuffer(ucAddr, &ucData, 1); SX1276WriteBuffer(ucAddr, &ucData, 1);
@@ -295,8 +294,8 @@ void Sx1276LoRaInit(DataRevCallBack RxCallBack)
SX1276WriteBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS); SX1276WriteBuffer(REG_LR_OPMODE, (uint8_t*)&(LoRaPara.RegBuff) + 1, SIZE_OF_REGISTERS);
// set the RF settings // set the RF settings
SX1276LoRaWriteChannel(LoRaPara.ucChannel); //SX1276LoRaWriteChannel(LoRaPara.ucChannel);
//SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz); SX1276LoRaSetFreqHz(LoRaPara.dwFreqHz);
//REG_LR_MODEMCONFIG1 //REG_LR_MODEMCONFIG1
SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1)); SX1276Read(REG_LR_MODEMCONFIG1, &(LoRaPara.RegBuff.RegModemConfig1));
//SignalBandwidth //SignalBandwidth
@@ -320,6 +319,7 @@ void Sx1276LoRaInit(DataRevCallBack RxCallBack)
LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_SF_MASK ) | LoRaPara.SpreadFactor; LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_SF_MASK ) | LoRaPara.SpreadFactor;
//PacketCrcOn //PacketCrcOn
LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_RXPAYLOADCRC_MASK ) | SX1276_CRC_ON; //SX1276_CRC_OFF LoRaPara.RegBuff.RegModemConfig2 = (LoRaPara.RegBuff.RegModemConfig2 & RFLR_MODEMCONFIG2_RXPAYLOADCRC_MASK ) | SX1276_CRC_ON; //SX1276_CRC_OFF
SX1276Write(REG_LR_MODEMCONFIG2, LoRaPara.RegBuff.RegModemConfig2); SX1276Write(REG_LR_MODEMCONFIG2, LoRaPara.RegBuff.RegModemConfig2);
uint8_t Config2 = 0; uint8_t Config2 = 0;
SX1276Read(REG_LR_MODEMCONFIG2, &Config2); SX1276Read(REG_LR_MODEMCONFIG2, &Config2);
@@ -656,4 +656,14 @@ bool LoraSetRegPreamble(uint8_t RegPreamble)
LoRaPara.RegPreamble = RegPreamble; LoRaPara.RegPreamble = RegPreamble;
return true; return true;
} }
bool LoraSetFreqCent(uint32_t FreqCent)
{
if(FreqCent < 410000000 || FreqCent > 525000000)
return false;
LoRaPara.dwFreqHz = FreqCent;
return true;
}
#endif #endif
@@ -759,7 +759,7 @@ typedef struct {
/* /*
433100000ul + 200000*N 433100000ul + 200000*N
*/ */
#define CH0 (433100000ul + 0) //测试频率 #define CH0 (433100000ul + 0) //测试频率
#define CH1 (433100000ul + 200000) #define CH1 (433100000ul + 200000)
#define CH2 (433100000ul + 400000) #define CH2 (433100000ul + 400000)
@@ -825,6 +825,7 @@ void SX1276LoRaWriteRx(void);
void SX1276LoRaWriteSleep(bool Sleep); void SX1276LoRaWriteSleep(bool Sleep);
Sx1276StateType_t SX1276LoRaReadStatus(void); Sx1276StateType_t SX1276LoRaReadStatus(void);
void SX1276LoCalcRssiSnr(int16_t *pswRssi, int8_t *psbSnr); void SX1276LoCalcRssiSnr(int16_t *pswRssi, int8_t *psbSnr);
void SX1276Read(uint8_t ucAddr, uint8_t *pucData);
void Sx1276LoRaSleep(void); void Sx1276LoRaSleep(void);
void Sx1276LoRaWakeup(void); void Sx1276LoRaWakeup(void);
int GetSx1276RxRetValue(void); int GetSx1276RxRetValue(void);
@@ -836,5 +837,6 @@ bool LoraSetSignalBw(uint8_t SignalBw);
bool LoraSetSpreadFactor(uint8_t SpreadFactor); bool LoraSetSpreadFactor(uint8_t SpreadFactor);
bool LoraSetErrorCoding(uint8_t ErrorCoding); bool LoraSetErrorCoding(uint8_t ErrorCoding);
bool LoraSetRegPreamble(uint8_t RegPreamble); bool LoraSetRegPreamble(uint8_t RegPreamble);
bool LoraSetFreqCent(uint32_t FreqCent);
#endif #endif
+33 -1
View File
@@ -14,6 +14,15 @@
#define CAT_ONE_DELAY_1MS(X) #define CAT_ONE_DELAY_1MS(X)
// ETH状态机相关宏定义
#define ETH_RESET_DELAY_TIME_MAX (5 * 60 * 1000)
#define ETH_LINK_WAIT_TIME_MAX (10 * 1000)
#define ETH_REG_TIMEOUT_MAX (30 * 1000)
#define ETH_SEND_TIMEOUT_MAX (5 * 1000)
#define ETH_RECV_TIMEOUT_MAX (60 * 1000)
#define ETH_SEND_RETRY_MAX 3
#define ETH_FIRST_REG_DELAY (5 * 1000)
typedef enum { typedef enum {
CAT_ONE_AT_NULL, CAT_ONE_AT_NULL,
CAT_ONE_AT, //开机检测 CAT_ONE_AT, //开机检测
@@ -49,6 +58,17 @@ typedef enum {
CAT_ONE_CLOSE_TCP, CAT_ONE_CLOSE_TCP,
}CatOneStatus_m; }CatOneStatus_m;
typedef enum {
ETH_IDEL,
ETH_RESET,
ETH_WAIT_LINK,
ETH_REG_SVR,
ETH_WAIT_SEND,
ETH_SEND_DATA,
ETH_WAIT_RECV,
ETH_OFF,
}EthStatus_m;
typedef enum { typedef enum {
CAT_ONE_RET_NULL, CAT_ONE_RET_NULL,
CAT_ONE_RET_OK, CAT_ONE_RET_OK,
@@ -67,7 +87,7 @@ typedef enum {
}CatOneNetType_m; }CatOneNetType_m;
typedef struct { typedef struct {
CatOneStatus_m Status; CatOneStatus_m Cat1Status;
CatOneStatus_m NextStatus; CatOneStatus_m NextStatus;
CatOneRetStatus_m ATCmdRet; CatOneRetStatus_m ATCmdRet;
uint32_t CatOne1mSDelayCnt; uint32_t CatOne1mSDelayCnt;
@@ -90,17 +110,29 @@ typedef struct {
GateWayPara GateWay; GateWayPara GateWay;
DataRevCallBack CatOneRevCallBack; DataRevCallBack CatOneRevCallBack;
// ETH状态机相关字段
EthStatus_m EthStatus;
uint32_t EthResetDelayCnt;
uint32_t EthLinkWaitCnt;
uint32_t EthRecvTimeoutCnt;
uint8_t EthSendRetryCnt;
bool EthFirstRegFlag;
}CatOne_t, *pCatOne_t; }CatOne_t, *pCatOne_t;
CatOneRetStatus_m CatOneSend(uint8_t *sData, uint16_t sLen); CatOneRetStatus_m CatOneSend(uint8_t *sData, uint16_t sLen);
void CatOneStart(void); void CatOneStart(void);
void CatOneStop(void); void CatOneStop(void);
void CatOneReset(void); void CatOneReset(void);
void ETHStop(void);
void ETHReset(void);
void Cat1DBGOnOff(bool OnOff); void Cat1DBGOnOff(bool OnOff);
void CatOneGetLocationInfo(int *Longitude, int *Latitude); void CatOneGetLocationInfo(int *Longitude, int *Latitude);
void CatOneGetIMEIAndSIM(char *Imei, char *Sim); void CatOneGetIMEIAndSIM(char *Imei, char *Sim);
bool CatOneGetStatus(void); bool CatOneGetStatus(void);
bool CatOneEthSendQueue(uint8_t *sData, uint16_t sLen); bool CatOneEthSendQueue(uint8_t *sData, uint16_t sLen);
void CatOneTriggerRegister(void);
void ETHTriggerRegister(void);
void CatOne_Eth_Thread_Entry(void *parameter); void CatOne_Eth_Thread_Entry(void *parameter);
void EthRxOverhandler(void); void EthRxOverhandler(void);
void CatReadImeiOrSim(char *Imei, char *Sim); void CatReadImeiOrSim(char *Imei, char *Sim);
+50 -13
View File
@@ -28,7 +28,6 @@ typedef enum {
DEBUG_CH_RS485_2, DEBUG_CH_RS485_2,
}DebugChannel_m; }DebugChannel_m;
typedef enum { typedef enum {
DEV_TYPE_BROADCAST, DEV_TYPE_BROADCAST,
DEV_TYPE_INC_COMMUNIT = 0x8001, DEV_TYPE_INC_COMMUNIT = 0x8001,
@@ -57,6 +56,7 @@ typedef enum {
COMM_UNIT_CMD_SET_SENSOR_COLL_TIME = 5, COMM_UNIT_CMD_SET_SENSOR_COLL_TIME = 5,
COMM_UNIT_CMD_TIME_SYNC, COMM_UNIT_CMD_TIME_SYNC,
COMM_UNIT_CMD_CONT_LASER = 8,//激光独有指令 COMM_UNIT_CMD_CONT_LASER = 8,//激光独有指令
COMM_UNIT_CMD_GET_SIGNAL, //0x09 查询Lora信号质量
COMM_UNIT_CMD_END, COMM_UNIT_CMD_END,
}CommUnitCmd_m; }CommUnitCmd_m;
@@ -99,6 +99,7 @@ typedef enum {
SURFACE_STRESS, //0x0014 表面应力 SURFACE_STRESS, //0x0014 表面应力
PRESSURE, //0x0015 压力 PRESSURE, //0x0015 压力
MICROWAVE_DISPLACE, //0x0016 微波位移 MICROWAVE_DISPLACE, //0x0016 微波位移
DISPLACEMENT = 0x0020, //0x0020 位移监测传感器
}SensorType_m; }SensorType_m;
typedef struct {//主设备固定包头 typedef struct {//主设备固定包头
@@ -124,7 +125,21 @@ typedef struct {
int16_t PitchAngle; //俯仰角偏斜 (范围±900)单位0.1° int16_t PitchAngle; //俯仰角偏斜 (范围±900)单位0.1°
int16_t RollAngle; //横滚角偏斜 (范围±900)单位0.1° int16_t RollAngle; //横滚角偏斜 (范围±900)单位0.1°
int16_t YawAngle; //偏航角偏斜 (范围0~3600)单位0.1° int16_t YawAngle; //偏航角偏斜 (范围0~3600)单位0.1°
}__attribute__((packed))LaserTracingType_t; }__attribute__((packed))LaserTracingType_T;
typedef struct {//0x0020 位移计
MasterDev_T MasterDev;
int16_t PitchAngle; //俯仰角偏斜(范围±900)单位0.1°
int16_t RollAngle; //横滚角偏斜(范围±900)单位0.1°
int16_t YawAngle; //偏航角偏斜(范围0~3600)单位0.1°
float Temp; //温度
float Altitude; //海拔()单位cm
int16_t Distance; //1轴应力值转位移(范围±300,单位0.1mm)
}__attribute__ ((packed))Displacement_T,*DisplacementDp;
typedef struct {
int Distance;
}__attribute__((packed))LaserDistanceSensorType_t;
typedef struct { typedef struct {
uint8_t CommDevAddr[6]; //通讯单元地址 uint8_t CommDevAddr[6]; //通讯单元地址
@@ -134,10 +149,6 @@ typedef struct {
uint8_t ERTime; //紧急上报时长 uint8_t ERTime; //紧急上报时长
}__attribute__((packed))SvrDownLPDevConfigPara_t; }__attribute__((packed))SvrDownLPDevConfigPara_t;
typedef struct {
int Distance;
}__attribute__((packed))LaserDistanceSensorType_t;
typedef struct { typedef struct {
uint8_t AlarmType; uint8_t AlarmType;
uint8_t AlarmState; uint8_t AlarmState;
@@ -180,15 +191,20 @@ typedef struct {
uint16_t ReportInterval; //上报时间间隔 uint16_t ReportInterval; //上报时间间隔
uint8_t ERInterval; //紧急上报时间间隔 uint8_t ERInterval; //紧急上报时间间隔
uint8_t ERTime; //紧急上报时长 uint8_t ERTime; //紧急上报时长
}CommUnitPara_t, *CommUnitPara; }__attribute__((packed))CommUnitPara_t, *CommUnitPara;
typedef struct {
bool ExclFlag;
uint8_t ExclMac[6];//需要排除的通讯单元MAC
}__attribute__((packed))ExclCommUnit_t, *ExclCommUnit;
typedef struct { typedef struct {
uint8_t Data[SENSOR_NUM_MAX][SENSOR_DATA_LEN_MAX]; uint8_t Data[SENSOR_NUM_MAX][SENSOR_DATA_LEN_MAX];
}CommUnitData_t, *CommUnitData; }__attribute__((packed))CommUnitData_t, *CommUnitData;
typedef struct { typedef struct {
CommUnitPara_t Para; CommUnitPara_t Para;
}CommUnit_t, *CommUnit; }__attribute__((packed))CommUnit_t, *CommUnit;
typedef struct { typedef struct {
bool Enable; //串口使能 bool Enable; //串口使能
@@ -198,8 +214,9 @@ typedef struct {
uint8_t Power; uint8_t Power;
uint32_t BaudRate; uint32_t BaudRate;
SendData RS485Send; SendData RS485Send;
CommUnit_t CUData; CommUnit_t CUPara;
}RS485Para_t, *RS485Para; CommUnitData_t CUData;
}__attribute__((packed))RS485Para_t, *RS485Para;
typedef struct { typedef struct {
uint8_t Header; uint8_t Header;
@@ -234,14 +251,33 @@ typedef struct {
uint32_t FreqCent; uint32_t FreqCent;
}LoraPara_t, *pLoraPara; }LoraPara_t, *pLoraPara;
typedef struct {
uint8_t DestAddr[4]; //目的服务器地址
uint16_t DestPort; //目的服务器端口
uint8_t LocalAddr[4]; //本地客户端地址(预留)
uint16_t LocalPort; //本地客户端端口(预留)
}LTENetPara_t, *pLTENetPara;
typedef struct {
uint8_t IpMode; //IP模式:DHCP/静态
uint8_t IpAddr[4]; //本地IP地址
uint16_t IpPort; //本地端口
uint8_t WorkMode; //工作模式
uint8_t SubnetMask[4]; //子网掩码
uint8_t Gateway[4]; //网关
uint8_t DestIp[4]; //目的IP地址
uint16_t DestPort; //目的端口
}EthNetPara_t, *pEthNetPara;
typedef struct { typedef struct {
uint32_t SavFlag; //存储标志 uint32_t SavFlag; //存储标志
CommType_m Comm; //网关通讯方式 CommType_m Comm; //网关通讯方式
uint8_t GwMac[6]; //网关mac uint8_t GwMac[6]; //网关mac
char SvrAddr[4]; //服务器地址 LTENetPara_t LTENet; //Cat1/4G服务器参数
uint32_t SvrPort; //服务器端口 EthNetPara_t EthNet; //以太网网络参数
uint32_t CommUnitReadInterval; //通讯单元读取时间间隔,单位S uint32_t CommUnitReadInterval; //通讯单元读取时间间隔,单位S
CommUnitPara_t CommUnitArray[COMMUNIT_NUM_MAX]; //注册的通讯单元信息 CommUnitPara_t CommUnitArray[COMMUNIT_NUM_MAX]; //注册的通讯单元信息
ExclCommUnit_t ExclCommUnit[COMMUNIT_NUM_MAX]; //排除的通讯单元信息
RS485Para_t Rs485Ch1; //RS485通道1配置 RS485Para_t Rs485Ch1; //RS485通道1配置
RS485Para_t Rs485Ch2; //RS485通道2配置 RS485Para_t Rs485Ch2; //RS485通道2配置
uint8_t DebugChannel; //调试通道 uint8_t DebugChannel; //调试通道
@@ -277,6 +313,7 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen); void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen);
void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cmd, uint8_t *Payload, uint16_t PayloadLen, SendData Send); void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cmd, uint8_t *Payload, uint16_t PayloadLen, SendData Send);
int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac); int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac);
int CheckCommUnitExcl(GateWayPara GateWay, uint8_t *CommUnitMac);
int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUData, uint8_t *sData); int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUData, uint8_t *sData);
void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorData); void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorData);
#endif #endif
+10 -5
View File
@@ -10,6 +10,9 @@
#include "rtthread.h" #include "rtthread.h"
#include "ff.h" #include "ff.h"
#define SOFTWARE_VERSION 10
#define HARDWARE_VERSION 12
//#define USE_BOOTLOADER //#define USE_BOOTLOADER
//#define FLASH_SECTOR_SIZE 0x2000ul //#define FLASH_SECTOR_SIZE 0x2000ul
@@ -50,6 +53,7 @@
#define APP_START_FLAG 0x55AA5A5A #define APP_START_FLAG 0x55AA5A5A
#define APP_UPDATE_FLAG 0xA5A5AA55 #define APP_UPDATE_FLAG 0xA5A5AA55
#define APP_BOOT_UPGRADE_FLAG 0x5A5A55A5
#define WATCH_DOG 1 #define WATCH_DOG 1
@@ -164,8 +168,14 @@
#define ETH_OR_CAT1_CTRL_PORT (PortB) #define ETH_OR_CAT1_CTRL_PORT (PortB)
#define ETH_OR_CAT1_CTRL_PIN (Pin08) #define ETH_OR_CAT1_CTRL_PIN (Pin08)
#if (HARDWARE_VERSION == 12)
#define ETH_ON() PORT_SetBits(ETH_OR_CAT1_CTRL_PORT, ETH_OR_CAT1_CTRL_PIN) #define ETH_ON() PORT_SetBits(ETH_OR_CAT1_CTRL_PORT, ETH_OR_CAT1_CTRL_PIN)
#define CAT1_ON() PORT_ResetBits(ETH_OR_CAT1_CTRL_PORT, ETH_OR_CAT1_CTRL_PIN) #define CAT1_ON() PORT_ResetBits(ETH_OR_CAT1_CTRL_PORT, ETH_OR_CAT1_CTRL_PIN)
#elif (HARDWARE_VERSION >= 13)
#define ETH_ON() PORT_ResetBits(ETH_OR_CAT1_CTRL_PORT, ETH_OR_CAT1_CTRL_PIN)
#define CAT1_ON() PORT_SetBits(ETH_OR_CAT1_CTRL_PORT, ETH_OR_CAT1_CTRL_PIN)
#endif
//#define ETH_OR_CAT1_TX_CTRL_PORT (PortH) //#define ETH_OR_CAT1_TX_CTRL_PORT (PortH)
//#define ETH_OR_CAT1_TX_CTRL_PIN (Pin02) //#define ETH_OR_CAT1_TX_CTRL_PIN (Pin02)
@@ -182,11 +192,6 @@
#define CAT1_RESET_CLR() PORT_SetBits(CAT1_RESET_PORT, CAT1_RESET_PIN) #define CAT1_RESET_CLR() PORT_SetBits(CAT1_RESET_PORT, CAT1_RESET_PIN)
#define CAT1_RESET_SET() PORT_ResetBits(CAT1_RESET_PORT, CAT1_RESET_PIN) #define CAT1_RESET_SET() PORT_ResetBits(CAT1_RESET_PORT, CAT1_RESET_PIN)
//#define CAT1_POW_PORT (PortA)
//#define CAT1_POW_PIN (Pin00)
//#define CAT1_POW_ON() PORT_SetBits(CAT1_POW_PORT, CAT1_POW_PIN)
//#define CAT1_POW_OFF() PORT_ResetBits(CAT1_POW_PORT, CAT1_POW_PIN)
#define ETH_RESET_PORT (PortB) #define ETH_RESET_PORT (PortB)
#define ETH_RESET_PIN (Pin05) #define ETH_RESET_PIN (Pin05)
#define ETH_RESET_SET() PORT_SetBits(ETH_RESET_PORT, ETH_RESET_PIN) #define ETH_RESET_SET() PORT_SetBits(ETH_RESET_PORT, ETH_RESET_PIN)
+1 -4
View File
@@ -4,10 +4,7 @@
#include "Public.h" #include "Public.h"
#include "DebugCmd.h" #include "DebugCmd.h"
#define SOFTWARE_VERSION 12 #define MAC_ADDR_TYPE 0//0为测试服务器
#define HARDWARE_VERSION 12
#define MAC_ADDR_TYPE 1//0为测试服务器
extern bool MainDispEn; extern bool MainDispEn;
#define MAIN_DBG_LOG(...) { if(MainDispEn) Debug_Printf(__VA_ARGS__);} #define MAIN_DBG_LOG(...) { if(MainDispEn) Debug_Printf(__VA_ARGS__);}
+2 -2
View File
@@ -37,8 +37,8 @@ uint32_t SpiFlashReadId(void);
#define GATEWEY_PARA_SAV_ADDR 0x00 #define GATEWEY_PARA_SAV_ADDR 0x00
#define GATEWEY_PARA_SAV_SECTOR 0x00 #define GATEWEY_PARA_SAV_SECTOR 0x00
#define LOG_INFO_START_SECTOR 0x01 #define LOG_INFO_START_SECTOR 0x02
#define LOG_SAV_START_SECTOR 0x02 #define LOG_SAV_START_SECTOR 0x03
//#if (LORA_MODULE == WH_LR36_L) //#if (LORA_MODULE == WH_LR36_L)
//#define LOG_SAV_SIZE 78 //#define LOG_SAV_SIZE 78
+237 -66
View File
@@ -23,11 +23,33 @@ static uint8_t EthRevTimeOutCnt;
static uint16_t CatSendErrCnt = 0; static uint16_t CatSendErrCnt = 0;
// ETH状态机相关变量已移至 CatOne_t 结构体中
#define CAT1_DBG_LOG(...) { if(CAT1DispEn) Debug_Printf(__VA_ARGS__);} #define CAT1_DBG_LOG(...) { if(CAT1DispEn) Debug_Printf(__VA_ARGS__);}
//#define CAT1_DBG_ARRAY(ARRAY, SIZE) { if(CAT1DispEn) {DBG_ARRAY(ARRAY,SIZE)}} //#define CAT1_DBG_ARRAY(ARRAY, SIZE) { if(CAT1DispEn) {DBG_ARRAY(ARRAY,SIZE)}}
#define CATONE_RESET_DELAY_TIME_MAX (5 * 60 * 1000) #define CATONE_RESET_DELAY_TIME_MAX (5 * 60 * 1000)
//const char *CatOneATCmdStr[16] = {
// "NULL",
// "AT\r\n", //开机检测
// "ATE0\r\n", //关回显
// "AT+CPIN?\r\n", //识卡
//// "AT+CIMI\r\n", //IMEI
// "AT+CGSN=1\r\n",
// "AT+LCCID\r\n", //读卡号
// "AT+CEREG?\r\n", //查询注册状态
// "AT+CGPADDR=1\r\n", //查询IP地址
// "AT+CSQ\r\n", //查询信号强度
// "AT+LDNSGIP=gxjt.cui635.cn\r\n",
// "AT+LBS=0\r\n", //获取基站定位信息
// "AT+LIPOPEN=", //设置TCP服务器地址和端口,AT+LIPOPEN="TCP","114.55.52.96",6803
// "AT+LIPSEND=", //发送数据, AT+LIPSEND=0,1,20,"31313131313131323232323232"
// "AT+LIPCLOSE=0\r\n",//断开连接
// "AT+LBSPARA=http://locator-aep.xiot.senthink.com:80/locator/v0.1/locate,B84E427D95B1DF4A3F49B18DDF714C72\r\n",
// "AT+CCLK?\r\n", //获取时间
//};
const char *CatOneATCmdStr[16] = { const char *CatOneATCmdStr[16] = {
"NULL", "NULL",
"AT\r\n", //开机检测 "AT\r\n", //开机检测
@@ -35,17 +57,18 @@ const char *CatOneATCmdStr[16] = {
"AT+CPIN?\r\n", //识卡 "AT+CPIN?\r\n", //识卡
// "AT+CIMI\r\n", //IMEI // "AT+CIMI\r\n", //IMEI
"AT+CGSN=1\r\n", "AT+CGSN=1\r\n",
"AT+LCCID\r\n", //读卡号 "AT+QCCID\r\n", //读卡号
"AT+CEREG?\r\n", //查询注册状态 "AT+CEREG?\r\n", //查询注册状态
"AT+CGPADDR=1\r\n", //查询IP地址 "AT+CGPADDR=1\r\n", //查询IP地址
"AT+CSQ\r\n", //查询信号强度 "AT+CSQ\r\n", //查询信号强度
"AT+LDNSGIP=gxjt.cui635.cn\r\n", "AT+LDNSGIP=gxjt.cui635.cn\r\n",
"AT+LBS=0\r\n", //获取基站定位信息 "AT+QLBS\r\n", //获取基站定位信息
"AT+LIPOPEN=", //设置TCP服务器地址和端口,AT+LIPOPEN="TCP","114.55.52.96",6803 "AT+QIOPEN=", //设置TCP服务器地址和端口,AT+LIPOPEN="TCP","114.55.52.96",6803
"AT+LIPSEND=", //发送数据, AT+LIPSEND=0,1,20,"31313131313131323232323232" "AT+QISEND=", //发送数据, AT+LIPSEND=0,1,20,"31313131313131323232323232"
"AT+LIPCLOSE=0\r\n",//断开连接 "AT+QICLOSE=0\r\n",//断开连接
"AT+LBSPARA=http://locator-aep.xiot.senthink.com:80/locator/v0.1/locate,B84E427D95B1DF4A3F49B18DDF714C72\r\n", "AT+QLBSCFG=\"server\",http://locator-aep.xiot.senthink.com:80/locator/v0.1/locate\r\n",
"AT+CCLK?\r\n", //获取时间 "AT+QLBSCFG=\"token\",45B516D3078467E84DD2CFBF3532A4CB\r\n",
"AT+CCLK?\r\n", //获取时间
}; };
void Cat1DBGOnOff(bool OnOff) void Cat1DBGOnOff(bool OnOff)
@@ -77,10 +100,10 @@ const CatOneATCMD_m CatOneModeSetCmdArray[] = {
//{ //{
// rt_err_t result; // rt_err_t result;
// //
// if(CatOne.Status != CAT_ONE_IDEL && CatOne.Status != CAT_ONE_WAIT_SEND) // if(CatOne.Cat1Status != CAT_ONE_IDEL && CatOne.Cat1Status != CAT_ONE_WAIT_SEND)
// return CAT_ONE_RET_ERR; // return CAT_ONE_RET_ERR;
// //
// //CatOne.Status = CAT_ONE_RESET; // //CatOne.Cat1Status = CAT_ONE_RESET;
// result = rt_mq_send(CatOneRev_MQ, sData, sLen); // result = rt_mq_send(CatOneRev_MQ, sData, sLen);
// if(result != RT_EOK) { // if(result != RT_EOK) {
// CAT1_DBG_LOG("CatOne MQ Send ERR...\r\n"); // CAT1_DBG_LOG("CatOne MQ Send ERR...\r\n");
@@ -92,7 +115,17 @@ const CatOneATCMD_m CatOneModeSetCmdArray[] = {
void CatOneStop(void) void CatOneStop(void)
{ {
CatOne.Status = CAT_ONE_OFF; CatOne.Cat1Status = CAT_ONE_OFF;
}
void ETHStop(void)
{
CatOne.EthStatus = ETH_OFF;
}
void ETHReset(void)
{
CatOne.EthStatus = ETH_RESET;
} }
void CatOneGetLocationInfo(int *Longitude, int *Latitude) void CatOneGetLocationInfo(int *Longitude, int *Latitude)
@@ -116,14 +149,14 @@ void CatOneGetIMEIAndSIM(char *Imei, char *Sim)
//返回true-busy, false-Idle //返回true-busy, false-Idle
bool CatOneGetStatus(void) bool CatOneGetStatus(void)
{ {
if(CatOne.Status == CAT_ONE_IDEL) if(CatOne.Cat1Status == CAT_ONE_IDEL)
return false; return false;
return true; return true;
} }
void CatOneReset(void) void CatOneReset(void)
{ {
CatOne.Status = CAT_ONE_RESET; CatOne.Cat1Status = CAT_ONE_RESET;
} }
void CatTimeSync(char *Data) void CatTimeSync(char *Data)
@@ -213,22 +246,22 @@ void CatOneAtCmdAnalyze(char *RxBuff)
if(strstr(RxBuff, "OK") == NULL) { if(strstr(RxBuff, "OK") == NULL) {
CatOne.ATCmdRet = CAT_ONE_RET_ERR; CatOne.ATCmdRet = CAT_ONE_RET_ERR;
} }
p = strstr(RxBuff, "+LCCID"); p = strstr(RxBuff, "+QCCID");
if(p == NULL) { if(p == NULL) {
CatOne.ATCmdRet = CAT_ONE_RET_ERR; CatOne.ATCmdRet = CAT_ONE_RET_ERR;
} }
memset(CatOne.SIM, 0, 32); memset(CatOne.SIM, 0, 32);
ret = sscanf(p, "+LCCID: %s\r\n", CatOne.SIM); ret = sscanf(p, "+QCCID: %s\r\n", CatOne.SIM);
if(ret != 1) { if(ret != 1) {
memset(CatOne.SIM, 0, 32); memset(CatOne.SIM, 0, 32);
} }
break; break;
case CAT_ONE_LBS: case CAT_ONE_LBS:
p = strstr(RxBuff, "+LBS"); p = strstr(RxBuff, "+QLBS");
if(p != NULL) { if(p != NULL) {
double Longitude, Latitude; double Longitude, Latitude;
int ret = sscanf(p, "+LBS: %lf,%lf\r\n", &Longitude, &Latitude); int ret = sscanf(p, "+QLBS: %lf,%lf\r\n", &Longitude, &Latitude);
if(ret == 2) { if(ret == 2) {
CatOne.LBSFlag = true; CatOne.LBSFlag = true;
CatOne.Longitude = Longitude * 100000; CatOne.Longitude = Longitude * 100000;
@@ -239,7 +272,7 @@ void CatOneAtCmdAnalyze(char *RxBuff)
case CAT_ONE_LIPOPEN: case CAT_ONE_LIPOPEN:
if(strstr(RxBuff, "OK") != NULL) { if(strstr(RxBuff, "OK") != NULL) {
CatOne.Status = CatOne.NextStatus; CatOne.Cat1Status = CatOne.NextStatus;
CatOne.CatOne1mSDelayCnt = 10 * 1000; CatOne.CatOne1mSDelayCnt = 10 * 1000;
return; return;
} }
@@ -247,13 +280,13 @@ void CatOneAtCmdAnalyze(char *RxBuff)
if(strstr(RxBuff, "LIPOPEN: 0,1") != NULL) { if(strstr(RxBuff, "LIPOPEN: 0,1") != NULL) {
CAT1_DBG_LOG("Cat1 successfully to connect to the server.\r\n\r\n"); CAT1_DBG_LOG("Cat1 successfully to connect to the server.\r\n\r\n");
CatOne.TcpConnFlag = true; CatOne.TcpConnFlag = true;
CatOne.Status = CatOne.NextStatus; CatOne.Cat1Status = CatOne.NextStatus;
rt_sem_release(CatOneRev_Sem); rt_sem_release(CatOneRev_Sem);
} }
else if(strstr(RxBuff, "LIPOPEN: 0,0") != NULL) { else if(strstr(RxBuff, "LIPOPEN: 0,0") != NULL) {
CAT1_DBG_LOG("Cat1 failed to connect to the server.\r\n\r\n"); CAT1_DBG_LOG("Cat1 failed to connect to the server.\r\n\r\n");
CatOne.TcpConnFlag = false; CatOne.TcpConnFlag = false;
CatOne.Status = CAT_ONE_OFF; CatOne.Cat1Status = CAT_ONE_OFF;
} }
return; return;
} }
@@ -305,7 +338,7 @@ void CatOneAtCmdAnalyze(char *RxBuff)
if(strstr(p, "+LIPURC: 0,0") != NULL) { if(strstr(p, "+LIPURC: 0,0") != NULL) {
CAT1_DBG_LOG("TCP connection disconnected.\r\n\r\n"); CAT1_DBG_LOG("TCP connection disconnected.\r\n\r\n");
CatOne.TcpConnFlag = false; CatOne.TcpConnFlag = false;
CatOne.Status = CAT_ONE_OFF; CatOne.Cat1Status = CAT_ONE_OFF;
return; return;
} }
@@ -321,7 +354,7 @@ void CatOneAtCmdAnalyze(char *RxBuff)
else { else {
return; return;
} }
//CatOne.Status = CAT_ONE_CLOSE_TCP; //CatOne.Cat1Status = CAT_ONE_CLOSE_TCP;
rt_sem_release(CatOneRev_Sem);//接收任务 rt_sem_release(CatOneRev_Sem);//接收任务
return; return;
} }
@@ -330,7 +363,7 @@ void CatOneAtCmdAnalyze(char *RxBuff)
} }
if(CatOne.ATCmdRet == CAT_ONE_RET_OK) { if(CatOne.ATCmdRet == CAT_ONE_RET_OK) {
CatOne.Status = CatOne.NextStatus; CatOne.Cat1Status = CatOne.NextStatus;
if(CatOne.AtCmd == CAT_ONE_LIPSEND) if(CatOne.AtCmd == CAT_ONE_LIPSEND)
CatOne.CatOne1mSDelayCnt = 5 * 1000; CatOne.CatOne1mSDelayCnt = 5 * 1000;
else else
@@ -350,11 +383,11 @@ void CatOneAtCmdSend(CatOneATCMD_m Cmd, uint32_t Dly, CatOneStatus_m NextStatus)
} }
else if(CatOne.AtCmd == CAT_ONE_LIPOPEN) { else if(CatOne.AtCmd == CAT_ONE_LIPOPEN) {
sprintf(CatOne.CatOneSendBuff,"AT+LIPOPEN=\"TCP\",\"%d.%d.%d.%d\",%d\r\n", sprintf(CatOne.CatOneSendBuff,"AT+LIPOPEN=\"TCP\",\"%d.%d.%d.%d\",%d\r\n",
CatOne.GateWay->ConfigPara.SvrAddr[0], CatOne.GateWay->ConfigPara.LTENet.DestAddr[0],
CatOne.GateWay->ConfigPara.SvrAddr[1], CatOne.GateWay->ConfigPara.LTENet.DestAddr[1],
CatOne.GateWay->ConfigPara.SvrAddr[2], CatOne.GateWay->ConfigPara.LTENet.DestAddr[2],
CatOne.GateWay->ConfigPara.SvrAddr[3], CatOne.GateWay->ConfigPara.LTENet.DestAddr[3],
CatOne.GateWay->ConfigPara.SvrPort); CatOne.GateWay->ConfigPara.LTENet.DestPort);
} }
else { else {
strcpy(CatOne.CatOneSendBuff, CatOneATCmdStr[CatOne.AtCmd]); strcpy(CatOne.CatOneSendBuff, CatOneATCmdStr[CatOne.AtCmd]);
@@ -363,7 +396,7 @@ void CatOneAtCmdSend(CatOneATCMD_m Cmd, uint32_t Dly, CatOneStatus_m NextStatus)
EthRevTimeOutCnt = 0; EthRevTimeOutCnt = 0;
EthOrCat1UartSend((uint8_t *)CatOne.CatOneSendBuff, strlen(CatOne.CatOneSendBuff)); EthOrCat1UartSend((uint8_t *)CatOne.CatOneSendBuff, strlen(CatOne.CatOneSendBuff));
CatOne.CatOne1mSDelayCnt = Dly; CatOne.CatOne1mSDelayCnt = Dly;
CatOne.Status = CAT_ONE_WAIT_REV; CatOne.Cat1Status = CAT_ONE_WAIT_REV;
CatOne.NextStatus = NextStatus; CatOne.NextStatus = NextStatus;
} }
@@ -375,12 +408,12 @@ int GateWayRegister(uint8_t *TxBuff)
if(CatOne.GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true && CatOne.GateWay->ConfigPara.Rs485Ch1.Enable == true) { if(CatOne.GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true && CatOne.GateWay->ConfigPara.Rs485Ch1.Enable == true) {
UnitCommCnt++; UnitCommCnt++;
memcpy(&p[len], CatOne.GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0], 6); memcpy(&p[len], CatOne.GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0], 6);
len += 6; len += 6;
} }
if(CatOne.GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true && CatOne.GateWay->ConfigPara.Rs485Ch2.Enable == true) { if(CatOne.GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true && CatOne.GateWay->ConfigPara.Rs485Ch2.Enable == true) {
UnitCommCnt++; UnitCommCnt++;
memcpy(&p[len], CatOne.GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0], 6); memcpy(&p[len], CatOne.GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0], 6);
len += 6; len += 6;
} }
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) { for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {
@@ -407,14 +440,14 @@ void CatOneLoopHandler(void)
uint16_t ret; uint16_t ret;
static uint8_t Cat1RevErrCnt = 0; static uint8_t Cat1RevErrCnt = 0;
switch(CatOne.Status){ switch(CatOne.Cat1Status){
case CAT_ONE_IDEL: case CAT_ONE_IDEL:
rt_thread_delay(1); rt_thread_delay(1);
if(CatOne.ResetDelayCnt > 0) { if(CatOne.ResetDelayCnt > 0) {
CatOne.ResetDelayCnt--; CatOne.ResetDelayCnt--;
} }
else { else {
CatOne.Status = CAT_ONE_RESET; CatOne.Cat1Status = CAT_ONE_RESET;
} }
break; break;
@@ -429,9 +462,9 @@ void CatOneLoopHandler(void)
else { //3次错误,关机 else { //3次错误,关机
CAT1_DBG_LOG("Cat1 error, Close!\r\n"); CAT1_DBG_LOG("Cat1 error, Close!\r\n");
if(CatOne.AtCmd == CAT_ONE_LIPSEND) if(CatOne.AtCmd == CAT_ONE_LIPSEND)
CatOne.Status = CAT_ONE_CLOSE_TCP; CatOne.Cat1Status = CAT_ONE_CLOSE_TCP;
else else
CatOne.Status = CAT_ONE_OFF; CatOne.Cat1Status = CAT_ONE_OFF;
} }
} }
break; break;
@@ -446,7 +479,7 @@ void CatOneLoopHandler(void)
CatOneAtCmdSend(CatOneModeSetCmdArray[CatOne.AtCmdIdx], 1000, CAT_ONE_INIT); CatOneAtCmdSend(CatOneModeSetCmdArray[CatOne.AtCmdIdx], 1000, CAT_ONE_INIT);
} }
else { else {
CatOne.Status = CAT_ONE_TCP_CONN; CatOne.Cat1Status = CAT_ONE_TCP_CONN;
CatOne.CatOne1mSDelayCnt = 0; CatOne.CatOne1mSDelayCnt = 0;
CatOne.AtCmdIdx = 0; CatOne.AtCmdIdx = 0;
CatOne.AtCmd = CAT_ONE_AT_NULL; CatOne.AtCmd = CAT_ONE_AT_NULL;
@@ -460,39 +493,40 @@ void CatOneLoopHandler(void)
case CAT_ONE_WAIT_CONN: case CAT_ONE_WAIT_CONN:
if(CatOne.TcpConnFlag) { if(CatOne.TcpConnFlag) {
if(CatOne.GateWay->SvrRegFlag == false) if(CatOne.GateWay->SvrRegFlag == false)
CatOne.Status = CAT_ONE_REG_SVR; CatOne.Cat1Status = CAT_ONE_REG_SVR;
else else
CatOne.Status = CAT_ONE_WAIT_SEND; CatOne.Cat1Status = CAT_ONE_WAIT_SEND;
} }
break; break;
case CAT_ONE_REG_SVR: //注册服务器 case CAT_ONE_REG_SVR: //注册服务器
ret = GateWayRegister(CatOneEthTxBuff); ret = GateWayRegister(CatOneEthTxBuff);
rt_mq_send(CatOne.GateWay->NetSendData_MQ, CatOneEthTxBuff, ret); rt_mq_send(CatOne.GateWay->NetSendData_MQ, CatOneEthTxBuff, ret);
CatOne.Status = CAT_ONE_WAIT_SEND; CatOne.Cat1Status = CAT_ONE_WAIT_SEND;
break; break;
case CAT_ONE_WAIT_SEND: case CAT_ONE_WAIT_SEND:
result = rt_mq_recv(CatOne.GateWay->NetSendData_MQ, Payload, CAT_ONE_REV_LEN_MAX, 1000); result = rt_mq_recv(CatOne.GateWay->NetSendData_MQ, Payload, CAT_ONE_REV_LEN_MAX, 1000);
if(result == RT_EOK) { if(result == RT_EOK) {
CatSendErrCnt = 0;
CatOneEthTxLen = NetCommOrgData(CatOne.GateWay, Payload, CatOneEthTxBuff); CatOneEthTxLen = NetCommOrgData(CatOne.GateWay, Payload, CatOneEthTxBuff);
CatOne.Status = CAT_ONE_SEND_DATA; CatOne.Cat1Status = CAT_ONE_SEND_DATA;
} }
else { else {
if(CatOne.Status == CAT_ONE_RESET || CatOne.Status == CAT_ONE_OFF) //外部命令执行,状态改变 if(CatOne.Cat1Status == CAT_ONE_RESET || CatOne.Cat1Status == CAT_ONE_OFF) //外部命令执行,状态改变
return; return;
if(!CatOne.TcpConnFlag) { if(!CatOne.TcpConnFlag) {
CatOne.Status = CAT_ONE_OFF; CatOne.Cat1Status = CAT_ONE_OFF;
} }
else { else {
CatSendErrCnt++; CatSendErrCnt++;
if(CatSendErrCnt > CAT1_ERR_RESET_DLY_MAX) { if(CatSendErrCnt > CAT1_ERR_RESET_DLY_MAX) {
CatOne.Status = CAT_ONE_RESET; CatOne.Cat1Status = CAT_ONE_RESET;
CAT1_DBG_LOG("Cat1 has no data for a long time, Reset!\r\n"); CAT1_DBG_LOG("Cat1 has no data for a long time, Reset!\r\n");
CatSendErrCnt = 0; CatSendErrCnt = 0;
break; break;
} }
CatOne.Status = CAT_ONE_WAIT_SEND; CatOne.Cat1Status = CAT_ONE_WAIT_SEND;
} }
} }
break; break;
@@ -501,7 +535,7 @@ void CatOneLoopHandler(void)
CatOne.AtCmdResendCnt = 3; CatOne.AtCmdResendCnt = 3;
Cat1RevErrCnt++; Cat1RevErrCnt++;
if(Cat1RevErrCnt > 10) { if(Cat1RevErrCnt > 10) {
CatOne.Status = CAT_ONE_RESET; CatOne.Cat1Status = CAT_ONE_RESET;
CAT1_DBG_LOG("Cat1 has no receive data for a long time, Reset!\r\n"); CAT1_DBG_LOG("Cat1 has no receive data for a long time, Reset!\r\n");
Cat1RevErrCnt = 0; Cat1RevErrCnt = 0;
break; break;
@@ -521,9 +555,9 @@ void CatOneLoopHandler(void)
Cat1RevErrCnt = 0; Cat1RevErrCnt = 0;
} }
if(CatOne.GateWay->SvrRegFlag == false) //设备没注册,关闭4G,等待下一次重新注册 if(CatOne.GateWay->SvrRegFlag == false) //设备没注册,关闭4G,等待下一次重新注册
CatOne.Status = CAT_ONE_OFF; CatOne.Cat1Status = CAT_ONE_OFF;
else else
CatOne.Status = CAT_ONE_WAIT_SEND; CatOne.Cat1Status = CAT_ONE_WAIT_SEND;
break; break;
case CAT_ONE_CLOSE_TCP: case CAT_ONE_CLOSE_TCP:
@@ -538,13 +572,15 @@ void CatOneLoopHandler(void)
rt_thread_delay(3000); rt_thread_delay(3000);
CAT1_PWR_KEY_SET(); CAT1_PWR_KEY_SET();
CatSendErrCnt = 0; CatSendErrCnt = 0;
CatOne.GateWay->SvrRegFlag = false;
CAT1_DBG_LOG("Cat1 Power Off!\r\n"); CAT1_DBG_LOG("Cat1 Power Off!\r\n");
CatOne.Status = CAT_ONE_IDEL; CatOne.Cat1Status = CAT_ONE_IDEL;
CatOne.ResetDelayCnt = CATONE_RESET_DELAY_TIME_MAX; CatOne.ResetDelayCnt = CATONE_RESET_DELAY_TIME_MAX;
break; break;
case CAT_ONE_RESET: case CAT_ONE_RESET:
CatSendErrCnt = 0; CatSendErrCnt = 0;
CatOne.GateWay->SvrRegFlag = false;
CAT1_DBG_LOG("Cat1 Reset!\r\n"); CAT1_DBG_LOG("Cat1 Reset!\r\n");
CAT1_RESET_CLR(); CAT1_RESET_CLR();
CAT1_PWR_KEY_SET(); CAT1_PWR_KEY_SET();
@@ -554,7 +590,7 @@ void CatOneLoopHandler(void)
CAT1_PWR_KEY_CLR(); CAT1_PWR_KEY_CLR();
rt_thread_delay(1000); rt_thread_delay(1000);
CAT1_PWR_KEY_SET(); CAT1_PWR_KEY_SET();
CatOne.Status = CAT_ONE_INIT; CatOne.Cat1Status = CAT_ONE_INIT;
CatOne.AtCmdIdx = 0; CatOne.AtCmdIdx = 0;
rt_thread_delay(1000); rt_thread_delay(1000);
CatOne.GateWay->BatteryReadDlyCnt = 60; CatOne.GateWay->BatteryReadDlyCnt = 60;
@@ -566,27 +602,150 @@ void EthLoopHandler(void)
{ {
rt_err_t result; rt_err_t result;
if(CatOne.GateWay->SvrRegFlag == false) { switch(CatOne.EthStatus) {
if(CatOne.RegisterDelayCnt == 0) { case ETH_IDEL:
rt_thread_delay(1);
if(CatOne.EthResetDelayCnt > 0) {
CatOne.EthResetDelayCnt--;
}
else {
CatOne.EthStatus = ETH_RESET;
}
break;
case ETH_RESET:
CAT1_DBG_LOG("ETH Reset!\r\n");
ETH_RESET_CLR();
rt_thread_delay(10);
ETH_RESET_SET();
rt_thread_delay(2000); // 延长复位后稳定时间到2秒
CatOne.EthStatus = ETH_WAIT_LINK;
CatOne.EthLinkWaitCnt = 0;
CatOne.EthFirstRegFlag = true; // 重置首次注册标志
break;
case ETH_WAIT_LINK:
if(CatOne.EthLinkWaitCnt == 0) {
/* 首次进入等待链路状态,等待模块完全启动 */
CAT1_DBG_LOG("ETH Waiting for module ready...\r\n");
rt_thread_delay(2000);
}
if(ETH_LINK_GET() == Reset) { if(ETH_LINK_GET() == Reset) {
CatOne.RegisterDelayCnt = REGISTER_INTERVAL_MAX * 10; CAT1_DBG_LOG("ETH Link OK!\r\n");
if(CatOne.GateWay->SvrRegFlag == false) {
CatOne.EthStatus = ETH_REG_SVR;
}
else {
CatOne.EthStatus = ETH_WAIT_SEND;
}
}
else {
CatOne.EthLinkWaitCnt++;
if(CatOne.EthLinkWaitCnt >= ETH_LINK_WAIT_TIME_MAX) {
CAT1_DBG_LOG("ETH Link Timeout, Reset!\r\n");
CatOne.EthStatus = ETH_OFF;
}
rt_thread_delay(1);
}
break;
case ETH_REG_SVR:
{
// 首次注册时添加延迟,等待系统稳定
if(CatOne.EthFirstRegFlag) {
CAT1_DBG_LOG("ETH First Register, waiting for system stable...\r\n");
rt_thread_delay(ETH_FIRST_REG_DELAY);
CatOne.EthFirstRegFlag = false;
}
uint8_t ret = GateWayRegister(CatOneEthTxBuff); uint8_t ret = GateWayRegister(CatOneEthTxBuff);
rt_mq_send(CatOne.GateWay->NetSendData_MQ, CatOneEthTxBuff, ret); rt_mq_send(CatOne.GateWay->NetSendData_MQ, CatOneEthTxBuff, ret);
CAT1_DBG_LOG("ETH Register Server...\r\n");
CatOne.EthStatus = ETH_WAIT_SEND;
CatOne.EthSendRetryCnt = 0; // 重置重试计数器
} }
} break;
else {
CatOne.RegisterDelayCnt--; case ETH_WAIT_SEND:
} result = rt_mq_recv(CatOne.GateWay->NetSendData_MQ, Payload, CAT_ONE_REV_LEN_MAX, 100);
if(result == RT_EOK) {
CatOneEthTxLen = NetCommOrgData(CatOne.GateWay, Payload, CatOneEthTxBuff);
CatOne.EthStatus = ETH_SEND_DATA;
}
else {
if(CatOne.EthStatus == ETH_RESET || CatOne.EthStatus == ETH_OFF)
return;
if(ETH_LINK_GET() != Reset) {
CAT1_DBG_LOG("ETH Link Lost!\r\n");
CatOne.EthStatus = ETH_OFF;
}
else {
rt_thread_delay(1);
}
}
break;
case ETH_SEND_DATA:
HexToAscii(CatOneEthTxBuff, CommUnitSendASCII, CatOneEthTxLen);
EthRevTimeOutCnt = 0;
EthOrCat1UartSend((uint8_t *)CommUnitSendASCII, CatOneEthTxLen * 2);
CommUnitSendASCII[CatOneEthTxLen * 2] = 0;
CAT1_DBG_LOG("Eth Send: %s\r\n", CommUnitSendASCII);
CatOne.EthStatus = ETH_WAIT_RECV;
CatOne.EthRecvTimeoutCnt = 0;
CatOne.EthSendRetryCnt = 0;
break;
case ETH_WAIT_RECV:
rt_thread_delay(1);
CatOne.EthRecvTimeoutCnt++;
if(CatOne.EthRecvTimeoutCnt >= ETH_RECV_TIMEOUT_MAX) {
CAT1_DBG_LOG("ETH Recv Timeout!\r\n");
CatOne.EthSendRetryCnt++;
if(CatOne.EthSendRetryCnt >= ETH_SEND_RETRY_MAX) {
CAT1_DBG_LOG("ETH Send Retry Max, Reset!\r\n");
CatOne.EthStatus = ETH_OFF;
}
else {
if(CatOne.GateWay->SvrRegFlag == false) {
CatOne.EthStatus = ETH_REG_SVR;
}
else {
CatOne.EthStatus = ETH_WAIT_SEND;
}
}
}
if(ETH_LINK_GET() != Reset) {
CAT1_DBG_LOG("ETH Link Lost During Wait!\r\n");
CatOne.EthStatus = ETH_OFF;
}
if(CatOne.GateWay->SvrRegFlag == true) {
CAT1_DBG_LOG("ETH Register Success!\r\n");
CatOne.EthStatus = ETH_WAIT_SEND;
CatOne.EthRecvTimeoutCnt = 0;
CatOne.EthSendRetryCnt = 0;
}
break;
case ETH_OFF:
CAT1_DBG_LOG("ETH Power Off!\r\n");
CatOne.GateWay->SvrRegFlag = false;
//ETH_RESET_CLR();
//rt_thread_delay(3000);
//ETH_RESET_SET();
CatOne.EthStatus = ETH_IDEL;
CatOne.EthResetDelayCnt = ETH_RESET_DELAY_TIME_MAX;
break;
default:
CatOne.EthStatus = ETH_RESET;
break;
} }
result = rt_mq_recv(CatOne.GateWay->NetSendData_MQ, Payload, CAT_ONE_REV_LEN_MAX, 100);
if(result == RT_EOK) {
CatOneEthTxLen = NetCommOrgData(CatOne.GateWay, Payload, CatOneEthTxBuff);
HexToAscii(CatOneEthTxBuff, CommUnitSendASCII, CatOneEthTxLen);
EthRevTimeOutCnt = 0;
EthOrCat1UartSend((uint8_t *)CommUnitSendASCII, CatOneEthTxLen * 2);
CommUnitSendASCII[CatOneEthTxLen * 2] = 0;
CAT1_DBG_LOG("Eth Send: %s\r\n",CommUnitSendASCII);
}
} }
bool CatOneEthSendQueue(uint8_t *sData, uint16_t sLen) bool CatOneEthSendQueue(uint8_t *sData, uint16_t sLen)
@@ -600,7 +759,7 @@ bool CatOneEthSendQueue(uint8_t *sData, uint16_t sLen)
static void CatOneInit(GateWayPara GateWay) static void CatOneInit(GateWayPara GateWay)
{ {
memset(&CatOne, 0x00, sizeof(CatOne_t)); memset(&CatOne, 0x00, sizeof(CatOne_t));
CatOne.Status = CAT_ONE_RESET; CatOne.Cat1Status = CAT_ONE_RESET;
CatOne.GateWay = GateWay; CatOne.GateWay = GateWay;
CatOne.CatOneRevCallBack = GateWay->SvrRevCallBack; CatOne.CatOneRevCallBack = GateWay->SvrRevCallBack;
} }
@@ -707,7 +866,7 @@ void EthRxOverhandler(void)
{ {
if(EthRevTimeOutCnt > 0) if(EthRevTimeOutCnt > 0)
EthRevTimeOutCnt--; EthRevTimeOutCnt--;
if(CatOneEthRxLen > 5 && EthRevTimeOutCnt == 0) { if(CatOneEthRxLen > 5 && EthRevTimeOutCnt == 0) {
EthRevTimeOutCnt = 20; EthRevTimeOutCnt = 20;
if(CatOne.GateWay->ConfigPara.Comm == CATONE_COMM) if(CatOne.GateWay->ConfigPara.Comm == CATONE_COMM)
@@ -728,3 +887,15 @@ void CatReadImeiOrSim(char *Imei, char *Sim)
Sim[20] = 0x00; Sim[20] = 0x00;
} }
} }
void CatOneTriggerRegister(void)
{
ETHStop();
CAT1_ON();
CatOneReset();
}
void ETHTriggerRegister(void)
{
CatOne.EthStatus = ETH_REG_SVR;
}
+8 -8
View File
@@ -66,7 +66,7 @@ void LoraIRQ_Thread_Entry(void *parameter)
static void LoRaSendBuffer(uint8_t* pucBuff, uint16_t ucLen) static void LoRaSendBuffer(uint8_t* pucBuff, uint16_t ucLen)
{ {
if(GateWay->ConfigPara.Lora.OnOff) if(GateWay->ConfigPara.Lora.OnOff == true)
Sx1276LoRaSendBuffer(pucBuff, ucLen); Sx1276LoRaSendBuffer(pucBuff, ucLen);
} }
@@ -142,15 +142,15 @@ void Lora_Thread_Entry(void *parameter)
if(UnitCommSendFlag == false && UnitCommReadDelayCnt >= GateWay->ConfigPara.CommUnitReadInterval) { if(UnitCommSendFlag == false && UnitCommReadDelayCnt >= GateWay->ConfigPara.CommUnitReadInterval) {
if(SendUnitCommIdx < COMMUNIT_NUM_MAX) { if(SendUnitCommIdx < COMMUNIT_NUM_MAX) {
if(GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].RegFlag && if(GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].RegFlag &&
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[2] == 0x01) { GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0][2] == 0x01) {
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].RevNewDataFlag = false; GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].RevNewDataFlag = false;
Debug_Printf("Lora Read CommUnit: %02X:%02X:%02X:%02X:%02X:%02X\r\n", Debug_Printf("Lora Read CommUnit: %02X:%02X:%02X:%02X:%02X:%02X\r\n",
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0], GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0][0],
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[1], GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0][1],
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[2], GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0][2],
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[3], GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0][3],
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[4], GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0][4],
GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[5]); GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0][5]);
CommUnitCmdSend(GateWay, GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0], COMM_UNIT_CMD_READ, NULL, 0, Sx1276LoRaSendBuffer); CommUnitCmdSend(GateWay, GateWay->ConfigPara.CommUnitArray[SendUnitCommIdx].Mac[0], COMM_UNIT_CMD_READ, NULL, 0, Sx1276LoRaSendBuffer);
UnitCommSendFlag = true; UnitCommSendFlag = true;
} }
+91 -27
View File
@@ -5,26 +5,43 @@
#include "spiflash.h" #include "spiflash.h"
#include "CatOneTask.h" #include "CatOneTask.h"
#include <stdlib.h> #include <stdlib.h>
#include "sx127x.h"
//传感器对应的数据长度 //传感器对应的数据长度
const uint8_t SensorTypeDataLen[] = { const uint8_t SensorTypeDataLen[] = {
0, //0x0000-保留 0, //0x0000-保留
30, //0x0001-应力场检测单元 30, //0x0001-应力场检测单元
12, //0x0002-渗透压检测单元 12, //0x0002-渗透压检测单元
14, //0x0003-弹性波导检测单元 14, //0x0003-弹性波导检测单元
10, //0x0004-介电质普检测单元 10, //0x0004-介电质普检测单元
6, //0x0005-微振动 6, //0x0005-微振动
6, //0x0006-三维连续变形检测单元 6, //0x0006-三维连续变形检测单元
3, //0x0007-通讯单元 3, //0x0007-通讯单元
18, //0x0008-三维应力检测单元 18, //0x0008-三维应力检测单元
9, //0x0009-激光示踪(主设备) 9, //0x0009-激光示踪(主设备)
12, //0x000A-水位计 12, //0x000A-水位计
0, //0x000B-保留 0, //0x000B-保留
0, //0x000C-保留 0, //0x000C-保留
14, //0x000D-二维应力场检测单元 14, //0x000D-二维应力场检测单元
9, //0x000E-裂缝检测单元 9, //0x000E-裂缝检测单元
0, //0x000F-预留
8, //0x0010-姿态检测单元 8, //0x0010-姿态检测单元
4, //0x0011-激光位移检测单元 4, //0x0011-激光位移检测单元
4, //0x0012-表面应力传感器
4, //0x0013-压力传感器
4, //0x0014-微波测距传感器
0, //0x0015-表贴式结冰传感器
0, //0x0016-埋入式结冰传感器
4, //0x0017-单通道钢筋应力传感器
4, //0x0018-单通道锚杆轴力传感器
32, //0x0019-8通道钢筋拉压力传感器
32, //0x001A-8通道锚杆轴力传感器
0, //0x001B-16通道钢筋应力传感器
0, //0x001C-16通道锚杆轴力传感器
0, //0x001D-爆炸冲击传感器
0, //0x001E-随行支架传感器
0, //0x001F-冻融循环传感器
19, //0x0020-位移计
}; };
/***************************************************************************************** /*****************************************************************************************
@@ -184,7 +201,7 @@ int NetCommOrgData(GateWayPara GateWay, uint8_t *MegData, uint8_t *OutData)
* 功能描述: 检查设备是否注册 * 功能描述: 检查设备是否注册
* 参 数: GateWay,网关句柄 * 参 数: GateWay,网关句柄
CommUnitMac, 待检查的设备MAC CommUnitMac, 待检查的设备MAC
* 返 回 值: 已注册返回true,没注册返回false * 返 回 值: 已注册返回非0,没注册返回-1
*****************************************************************************************/ *****************************************************************************************/
int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac) int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac)
{ {
@@ -196,8 +213,23 @@ int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac)
} }
return -1; return -1;
} }
/*****************************************************************************************
* 函数名称: CheckCommUnitExcl
* 功能描述: 检查设备是否排除
* 参 数: GateWay,网关句柄
CommUnitMac, 待检查的设备MAC
* 返 回 值: 已排除返回非0,没排除返回-1
*****************************************************************************************/
int CheckCommUnitExcl(GateWayPara GateWay, uint8_t *CommUnitMac)
{
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {//判断是否被排除
if(memcmp(GateWay->ConfigPara.ExclCommUnit[i].ExclMac, CommUnitMac, 6) == 0) {
if(GateWay->ConfigPara.ExclCommUnit[i].ExclFlag == true)
return i;
}
}
return -1;
}
/***************************************************************************************** /*****************************************************************************************
* 函数名称: CommUnitSendCmd * 函数名称: CommUnitSendCmd
* 功能描述: 网关下发通讯单元指令函数 * 功能描述: 网关下发通讯单元指令函数
@@ -225,7 +257,7 @@ void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cm
} }
else { else {
int ret = CheckCommUnitReg(GateWay, CommUnitMac); int ret = CheckCommUnitReg(GateWay, CommUnitMac);
if(ret < 0) if(ret < 0 && Cmd != COMM_UNIT_CMD_GET_SIGNAL)
return; return;
memcpy(CUHeader->DevMac, CommUnitMac, 6); memcpy(CUHeader->DevMac, CommUnitMac, 6);
//CUHeader->DevType = GateWay->ConfigPara.CommUnitArray[ret].CUType; //CUHeader->DevType = GateWay->ConfigPara.CommUnitArray[ret].CUType;
@@ -249,8 +281,8 @@ void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cm
/***************************************************************************************** /*****************************************************************************************
* 函数名称: CommUintOrgData * 函数名称: CommUintOrgData
* 功能描述: 上传传感器数据函数 * 功能描述: 上传传感器数据函数
* 参 数: GWMac,网关mac地址 * 参 数: CUPara, 通讯单元参数
CUPara, 通讯单元 CUData, 通讯单元数
sData, 数据入口 sData, 数据入口
* 返 回 值: 数据长度 * 返 回 值: 数据长度
*****************************************************************************************/ *****************************************************************************************/
@@ -298,8 +330,8 @@ int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUDat
case FORCE_3D: case FORCE_3D:
break; break;
case LASER_TRACING: case LASER_TRACING:
memcpy(&sData[Len], CUData->Data[i], sizeof(LaserTracingType_t)); memcpy(&sData[Len], CUData->Data[i], sizeof(LaserTracingType_T));
Len += sizeof(LaserTracingType_t); Len += sizeof(LaserTracingType_T);
break; break;
case WATER_LEVEL: case WATER_LEVEL:
break; break;
@@ -327,6 +359,10 @@ int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUDat
break; break;
case MICROWAVE_DISPLACE: case MICROWAVE_DISPLACE:
break; break;
case DISPLACEMENT:
memcpy(&sData[Len], CUData->Data[i], sizeof(Displacement_T));
Len += sizeof(Displacement_T);
break;
} }
SensorN++; SensorN++;
} }
@@ -374,8 +410,8 @@ void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorD
break; break;
} }
case LASER_TRACING: { case LASER_TRACING: {
LaserTracingType_t Sensor; LaserTracingType_T Sensor;
memcpy((uint8_t *)&Sensor, SensorData, sizeof(LaserTracingType_t)); memcpy((uint8_t *)&Sensor, SensorData, sizeof(LaserTracingType_T));
MAIN_DBG_LOG("Sensor%d Type %04x: PitchAngle=%04d, RollAngle=%04d, YawAngle=%04d\r\n", MAIN_DBG_LOG("Sensor%d Type %04x: PitchAngle=%04d, RollAngle=%04d, YawAngle=%04d\r\n",
SensorIdx, SensorType, Sensor.PitchAngle, Sensor.RollAngle, Sensor.YawAngle); SensorIdx, SensorType, Sensor.PitchAngle, Sensor.RollAngle, Sensor.YawAngle);
break; break;
@@ -419,6 +455,13 @@ void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorD
case MICROWAVE_DISPLACE: { case MICROWAVE_DISPLACE: {
break; break;
} }
case DISPLACEMENT: {
Displacement_T Sensor;
memcpy((uint8_t *)&Sensor, SensorData, sizeof(Displacement_T));
MAIN_DBG_LOG("Sensor%d Type %04x: PitchAngle=%04d, RollAngle=%04d, YawAngle=%04d, Temp=%06f, Altitude=%06f, Distance=%04d\r\n",
SensorIdx, SensorType, Sensor.PitchAngle, Sensor.RollAngle, Sensor.YawAngle, Sensor.Temp, Sensor.Altitude, Sensor.Distance);
break;
}
default: default:
break; break;
} }
@@ -434,7 +477,7 @@ void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorD
int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData Response) int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData Response)
{ {
uint16_t check, crc16; uint16_t check, crc16;
int CommUnitIdx; int CommUnitIdx, ExclCommUnit;
uint16_t PayLoadLen; uint16_t PayLoadLen;
uint8_t *PayLoad; uint8_t *PayLoad;
uint8_t *MegData; uint8_t *MegData;
@@ -454,15 +497,20 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
if(check != crc16) if(check != crc16)
return -1; return -1;
if((CUHeader->Cmd != COMM_UNIT_CMD_REG) && (memcmp(GateWay->ConfigPara.GwMac, CUHeader->GWMac, 6) != 0)) if((CUHeader->Cmd != COMM_UNIT_CMD_REG && CUHeader->Cmd != COMM_UNIT_CMD_GET_SIGNAL) && (memcmp(GateWay->ConfigPara.GwMac, CUHeader->GWMac, 6) != 0))
return -1; return -1;
CommUnitIdx = CheckCommUnitReg(GateWay, CUHeader->DevMac); CommUnitIdx = CheckCommUnitReg(GateWay, CUHeader->DevMac);//判断是否是已注册的设备
if(CommUnitIdx < 0) { if(CommUnitIdx < 0) {
if(CUHeader->Cmd != COMM_UNIT_CMD_REG) if(CUHeader->Cmd != COMM_UNIT_CMD_REG && CUHeader->Cmd != COMM_UNIT_CMD_GET_SIGNAL){//判断是否是注册请求
return -1; return -1;
}
ExclCommUnit = CheckCommUnitExcl(GateWay, CUHeader->DevMac);//判断是否是被排除的设备
if(ExclCommUnit > -1) {
return -1;
}
} }
switch(CUHeader->Cmd) { switch(CUHeader->Cmd) {
case COMM_UNIT_CMD_REG:{ case COMM_UNIT_CMD_REG:{
if(PayLoad[0] > SENSOR_NUM_MAX) { if(PayLoad[0] > SENSOR_NUM_MAX) {
@@ -528,11 +576,13 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
MegData[0] = PayLoadLen & 0x00ff;; MegData[0] = PayLoadLen & 0x00ff;;
MegData[1] = (PayLoadLen >> 8) & 0x00ff; MegData[1] = (PayLoadLen >> 8) & 0x00ff;
MegData[2] = NET_COMM_CMD_ADD_UNIT; MegData[2] = NET_COMM_CMD_ADD_UNIT;
MegData[3] = (GateWay->ConfigPara.CommUnitArray[i].SensorN) & 0x00ff;;
MegData[4] = (GateWay->ConfigPara.CommUnitArray[i].SensorN >> 8) & 0x00ff;
for(uint8_t i = 0; i < GateWay->ConfigPara.CommUnitArray[i].SensorN; i++) for(uint8_t i = 0; i < GateWay->ConfigPara.CommUnitArray[i].SensorN; i++)
{ {
memcpy(&MegData[3], GateWay->ConfigPara.CommUnitArray[i].Mac[i], 6); memcpy(&MegData[5], GateWay->ConfigPara.CommUnitArray[i].Mac[i], 6);
} }
CatOneEthSendQueue(MegData, PayLoadLen+3); CatOneEthSendQueue(MegData, PayLoadLen+5);
rt_free(MegData); rt_free(MegData);
} }
return 0xff; return 0xff;
@@ -793,6 +843,19 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
break;} break;}
case COMM_UNIT_CMD_GET_SIGNAL:{
int16_t Rssi;
int8_t Snr;
uint8_t SignalPayload[2];
SX1276LoCalcRssiSnr(&Rssi, &Snr);
SignalPayload[0] = (uint8_t)Snr;
SignalPayload[1] = (uint8_t)(Rssi & 0xFF);
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_GET_SIGNAL, SignalPayload, 2, Response);
MAIN_DBG_LOG("\r\nCUMac:%02X-%02X-%02X-%02X-%02X-%02X, RX(Dev->GW): SNR:%d, RSSI:%d\r\n",
CUHeader->DevMac[0], CUHeader->DevMac[1], CUHeader->DevMac[2], CUHeader->DevMac[3], CUHeader->DevMac[4], CUHeader->DevMac[5],
Snr, Rssi);
break;}
default: default:
break; break;
} }
@@ -848,13 +911,13 @@ int Cat1EthRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen)
if(GateWay->ConfigPara.Rs485Ch1.Enable == true) { //内部通讯单元处理 if(GateWay->ConfigPara.Rs485Ch1.Enable == true) { //内部通讯单元处理
if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true)
CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_TIME_SYNC, &rData[14], 4, GateWay->ConfigPara.Rs485Ch1.RS485Send); CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_TIME_SYNC, (uint8_t *)&NCHeader->Timestamp, 4, GateWay->ConfigPara.Rs485Ch1.RS485Send);
else else
RS485CmdSend(GateWay, 1, &SCPara); RS485CmdSend(GateWay, 1, &SCPara);
} }
if(GateWay->ConfigPara.Rs485Ch2.Enable == true) { if(GateWay->ConfigPara.Rs485Ch2.Enable == true) {
if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true)
CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_TIME_SYNC, &rData[14], 4, GateWay->ConfigPara.Rs485Ch2.RS485Send); CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_TIME_SYNC, (uint8_t *)&NCHeader->Timestamp, 4, GateWay->ConfigPara.Rs485Ch2.RS485Send);
else else
RS485CmdSend(GateWay, 2, &SCPara); RS485CmdSend(GateWay, 2, &SCPara);
} }
@@ -909,7 +972,7 @@ int Cat1EthRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen)
CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_CAIL, NULL, 0, GateWay->ConfigPara.Rs485Ch1.RS485Send); CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_CAIL, NULL, 0, GateWay->ConfigPara.Rs485Ch1.RS485Send);
} }
if(GateWay->ConfigPara.Rs485Ch2.Enable == true) { if(GateWay->ConfigPara.Rs485Ch2.Enable == true) {
if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true)
RS485CmdSend(GateWay, 2, &SCPara); RS485CmdSend(GateWay, 2, &SCPara);
else else
CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_CAIL, NULL, 0, GateWay->ConfigPara.Rs485Ch2.RS485Send); CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_CAIL, NULL, 0, GateWay->ConfigPara.Rs485Ch2.RS485Send);
@@ -964,14 +1027,14 @@ int Cat1EthRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen)
if(GateWay->ConfigPara.Rs485Ch1.Enable == true) { //内部通讯单元处理 if(GateWay->ConfigPara.Rs485Ch1.Enable == true) { //内部通讯单元处理
if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) { if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) {
SensorCnt++; SensorCnt++;
memcpy(&MegData[sLen], GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0], 6); memcpy(&MegData[sLen], GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0], 6);
sLen += 6; sLen += 6;
} }
} }
if(GateWay->ConfigPara.Rs485Ch2.Enable == true) { if(GateWay->ConfigPara.Rs485Ch2.Enable == true) {
if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) { if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) {
SensorCnt++; SensorCnt++;
memcpy(&MegData[sLen], GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0], 6); memcpy(&MegData[sLen], GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0], 6);
sLen += 6; sLen += 6;
} }
} }
@@ -1051,6 +1114,7 @@ int Cat1EthRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen)
} }
} }
break;
case NET_COMM_CMD_ADD_UNIT:{ case NET_COMM_CMD_ADD_UNIT:{
if(*Data == 1) { //录入成功 if(*Data == 1) { //录入成功
MAIN_DBG_LOG("Adding CommUnit succeeded...\r\n"); MAIN_DBG_LOG("Adding CommUnit succeeded...\r\n");
+22 -21
View File
@@ -289,18 +289,18 @@ void RS485LoopHandler(GateWayPara GateWay, RS485Para RS485Ch, SensorCommPara SCP
} }
} }
} }
else if(RS485Ch->CUData.Para.SensorN > 0){ else if(RS485Ch->CUPara.Para.SensorN > 0){
SCPara->SendFlag = false; SCPara->SendFlag = false;
if(SCPara->ReadSensorInterval > 0) { if(SCPara->ReadSensorInterval > 0) {
SCPara->ReadSensorInterval--; SCPara->ReadSensorInterval--;
} }
else { else {
if(SCPara->ReadSensorCnt >= RS485Ch->CUData.Para.SensorN || SCPara->SensorCnt >= SENSOR_NUM_MAX) { if(SCPara->ReadSensorCnt >= RS485Ch->CUPara.Para.SensorN || SCPara->SensorCnt >= SENSOR_NUM_MAX) {
SCPara->SensorCnt = 0; SCPara->SensorCnt = 0;
SCPara->ReadSensorCnt = 0; SCPara->ReadSensorCnt = 0;
SCPara->ReadSensorInterval = GateWay->ConfigPara.CommUnitReadInterval * 5; SCPara->ReadSensorInterval = GateWay->ConfigPara.CommUnitReadInterval * 5;
RS485Ch->CUData.Para.BatLevel = GateWay->Battery; RS485Ch->CUPara.Para.BatLevel = GateWay->Battery;
CommUintLen = CommUintOrgData(GateWay, &RS485Ch->CUData.Para, &SCPara->SensorData, CommUintData); CommUintLen = CommUintOrgData(GateWay, &RS485Ch->CUPara.Para, &SCPara->SensorData, CommUintData);
//AddLog(&CommUintData[2], CommUintLen - 2); //AddLog(&CommUintData[2], CommUintLen - 2);
CatOneEthSendQueue(CommUintData, CommUintLen); CatOneEthSendQueue(CommUintData, CommUintLen);
if(RS485Ch == &GateWay->ConfigPara.Rs485Ch1) { if(RS485Ch == &GateWay->ConfigPara.Rs485Ch1) {
@@ -312,11 +312,11 @@ void RS485LoopHandler(GateWayPara GateWay, RS485Para RS485Ch, SensorCommPara SCP
SCPara->SensorCnt = 0; SCPara->SensorCnt = 0;
} }
else { else {
if(RS485Ch->CUData.Para.SensorType[SCPara->SensorCnt] != 0) { if(RS485Ch->CUPara.Para.SensorType[SCPara->SensorCnt] != 0) {
rt_thread_delay(50); rt_thread_delay(50);
SCPara->Cmd = RS485_SENSOR_CMD_READ; SCPara->Cmd = RS485_SENSOR_CMD_READ;
SCPara->SensorAddr = SCPara->SensorCnt + 1; SCPara->SensorAddr = SCPara->SensorCnt + 1;
SCPara->SensorType = RS485Ch->CUData.Para.SensorType[SCPara->SensorCnt]; SCPara->SensorType = RS485Ch->CUPara.Para.SensorType[SCPara->SensorCnt];
SCPara->CmdParaLen = RS485SensorCmdPayLoadLen[RS485_SENSOR_CMD_READ]; SCPara->CmdParaLen = RS485SensorCmdPayLoadLen[RS485_SENSOR_CMD_READ];
SCPara->CmdPara = NULL; SCPara->CmdPara = NULL;
//rt_mutex_take(GateWay->UartRevMutex, RT_WAITING_FOREVER); //rt_mutex_take(GateWay->UartRevMutex, RT_WAITING_FOREVER);
@@ -402,7 +402,7 @@ void RS485LoopHandler(GateWayPara GateWay, RS485Para RS485Ch, SensorCommPara SCP
else { else {
if(RS485Ch->CommUnitEnable == true) { if(RS485Ch->CommUnitEnable == true) {
//rt_mutex_release(GateWay->UartRevMutex); //rt_mutex_release(GateWay->UartRevMutex);
if(SCPara->SendFlag == true) { //&& RS485Ch->CUData.Para.SensorN > 0 && RS485Ch->QuerySensorFlag == false){ if(SCPara->SendFlag == true) { //&& RS485Ch->CUPara.Para.SensorN > 0 && RS485Ch->QuerySensorFlag == false){
if(RS485Ch == &GateWay->ConfigPara.Rs485Ch1) { if(RS485Ch == &GateWay->ConfigPara.Rs485Ch1) {
test++; test++;
MAIN_DBG_LOG("InCommUint1, Sensor %d Comm Error, Cmd %d...\r\n", SCPara->SensorAddr, SCPara->Cmd); MAIN_DBG_LOG("InCommUint1, Sensor %d Comm Error, Cmd %d...\r\n", SCPara->SensorAddr, SCPara->Cmd);
@@ -422,10 +422,11 @@ void RS485LoopHandler(GateWayPara GateWay, RS485Para RS485Ch, SensorCommPara SCP
if(GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].CommStatus) { if(GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].CommStatus) {
GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].CommStatus = 0; GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].CommStatus = 0;
MegData[0] = 7; MegData[0] = 7;
MegData[1] = COMM_UNIT_CMD_READ; MegData[1] = 0;
memcpy(&MegData[2], GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].Mac[0], 6); MegData[2] = COMM_UNIT_CMD_READ;
MegData[8] = GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].CommStatus; memcpy(&MegData[3], GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].Mac[0], 6);
CatOneEthSendQueue(MegData, 9); //发送离线消息 MegData[9] = GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].CommStatus;
CatOneEthSendQueue(MegData, 10); //发送离线消息
} }
} }
SCPara->SendUnitCommIdx++; SCPara->SendUnitCommIdx++;
@@ -455,13 +456,13 @@ void RS485Ch1_Thread_Entry(void *parameter)
InCommUnitMac[3] = GateWay->ConfigPara.GwMac[4]; InCommUnitMac[3] = GateWay->ConfigPara.GwMac[4];
InCommUnitMac[4] = GateWay->ConfigPara.GwMac[5]; InCommUnitMac[4] = GateWay->ConfigPara.GwMac[5];
RS485Ch = &GateWay->ConfigPara.Rs485Ch1; RS485Ch = &GateWay->ConfigPara.Rs485Ch1;
memcpy(RS485Ch->CUData.Para.Mac, InCommUnitMac, 6); memcpy(RS485Ch->CUPara.Para.Mac, InCommUnitMac, 6);
if(RS485Ch->CommUnitEnable == true) { if(RS485Ch->CommUnitEnable == true) {
RS485_CH1_POW_ON(); RS485_CH1_POW_ON();
RS485Ch->CUData.Para.SensorN = 0; RS485Ch->CUPara.Para.SensorN = 0;
memset(RS485Ch->CUData.Para.SensorType, 0x00, sizeof(SENSOR_NUM_MAX * 2)); memset(RS485Ch->CUPara.Para.SensorType, 0x00, sizeof(SENSOR_NUM_MAX * 2));
RS485Ch->QuerySensorFlag = true; RS485Ch->QuerySensorFlag = true;
RS485Ch->CUData.Para.CommStatus = true; RS485Ch->CUPara.Para.CommStatus = true;
} }
SCPara->RS485CommUnitReadTimeDelay = 100; SCPara->RS485CommUnitReadTimeDelay = 100;
SCPara->RS485Rev_Sem = rt_sem_create("rsch1sem", 0, RT_IPC_FLAG_FIFO); SCPara->RS485Rev_Sem = rt_sem_create("rsch1sem", 0, RT_IPC_FLAG_FIFO);
@@ -519,13 +520,13 @@ void RS485Ch2_Thread_Entry(void *parameter)
InCommUnitMac[3] = GateWay->ConfigPara.GwMac[4]; InCommUnitMac[3] = GateWay->ConfigPara.GwMac[4];
InCommUnitMac[4] = GateWay->ConfigPara.GwMac[5]; InCommUnitMac[4] = GateWay->ConfigPara.GwMac[5];
RS485Ch = &GateWay->ConfigPara.Rs485Ch2; RS485Ch = &GateWay->ConfigPara.Rs485Ch2;
memcpy(RS485Ch->CUData.Para.Mac, InCommUnitMac, 6); memcpy(RS485Ch->CUPara.Para.Mac, InCommUnitMac, 6);
if(RS485Ch->CommUnitEnable == true) { if(RS485Ch->CommUnitEnable == true) {
RS485_CH2_POW_ON(); RS485_CH2_POW_ON();
RS485Ch->CUData.Para.SensorN = 0; RS485Ch->CUPara.Para.SensorN = 0;
memset(RS485Ch->CUData.Para.SensorType, 0x00, sizeof(SENSOR_NUM_MAX * 2)); memset(RS485Ch->CUPara.Para.SensorType, 0x00, sizeof(SENSOR_NUM_MAX * 2));
RS485Ch->QuerySensorFlag = true; RS485Ch->QuerySensorFlag = true;
RS485Ch->CUData.Para.CommStatus = 1; RS485Ch->CUPara.Para.CommStatus = 1;
} }
SCPara->RS485CommUnitReadTimeDelay = 100; SCPara->RS485CommUnitReadTimeDelay = 100;
SCPara->RS485Rev_Sem = rt_sem_create("rsch2sem", 0, RT_IPC_FLAG_FIFO); SCPara->RS485Rev_Sem = rt_sem_create("rsch2sem", 0, RT_IPC_FLAG_FIFO);
@@ -565,7 +566,7 @@ void RS485RxOverhandler(void)
if(SComm1Para.RS485TimeOutCnt > 0) if(SComm1Para.RS485TimeOutCnt > 0)
SComm1Para.RS485TimeOutCnt--; SComm1Para.RS485TimeOutCnt--;
if(SComm1Para.RS485RxLen > 5 && SComm1Para.RS485TimeOutCnt == 0) { if(SComm1Para.RS485RxLen >= 1 && SComm1Para.RS485TimeOutCnt == 0) {
if(SComm1Para.InitOverFlag == true) { if(SComm1Para.InitOverFlag == true) {
rt_sem_release(SComm1Para.RS485Rev_Sem); rt_sem_release(SComm1Para.RS485Rev_Sem);
SComm1Para.RS485TimeOutCnt = 20; SComm1Para.RS485TimeOutCnt = 20;
@@ -579,7 +580,7 @@ void RS485RxOverhandler(void)
if(SComm2Para.RS485TimeOutCnt > 0) if(SComm2Para.RS485TimeOutCnt > 0)
SComm2Para.RS485TimeOutCnt--; SComm2Para.RS485TimeOutCnt--;
if(SComm2Para.RS485RxLen > 5 && SComm2Para.RS485TimeOutCnt == 0) { if(SComm2Para.RS485RxLen >= 1 && SComm2Para.RS485TimeOutCnt == 0) {
if(SComm2Para.InitOverFlag == true) { if(SComm2Para.InitOverFlag == true) {
SComm2Para.RS485TimeOutCnt = 20; SComm2Para.RS485TimeOutCnt = 20;
rt_sem_release(SComm2Para.RS485Rev_Sem); rt_sem_release(SComm2Para.RS485Rev_Sem);
+52 -65
View File
@@ -129,18 +129,35 @@ void GateWayInit(void)
Debug_Printf("FlashID: %08x\r\n", FlashID); Debug_Printf("FlashID: %08x\r\n", FlashID);
memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t)); memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t));
boot_para_t bootParam;
dev_boot_read_param(&bootParam);
if(bootParam.AppFlag == APP_BOOT_UPGRADE_FLAG) {
rt_kprintf("Boot upgrade detected, erasing external Flash...\r\n");
SpiFlashEraseChip();
bootParam.AppFlag = 0;
dev_boot_write_param(bootParam);
}
int ret = ReadPara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); int ret = ReadPara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t));
if(GateWay.ConfigPara.SavFlag != LOG_SAV_FLAG) { if(GateWay.ConfigPara.SavFlag != LOG_SAV_FLAG) {
memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t)); memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t));
GateWay.ConfigPara.SavFlag = LOG_SAV_FLAG; GateWay.ConfigPara.SavFlag = LOG_SAV_FLAG;
GateWay.ConfigPara.Comm = CATONE_COMM; GateWay.ConfigPara.Comm = CATONE_COMM;
// memcpy(GateWay.ConfigPara.GwMac, GateWayMac, 6); #if MAC_ADDR_TYPE == 0//测试服务器
GateWay.ConfigPara.SvrAddr[0] = 8; GateWay.ConfigPara.LTENet.DestAddr[0] = 39;
GateWay.ConfigPara.SvrAddr[1] = 137; GateWay.ConfigPara.LTENet.DestAddr[1] = 106;
GateWay.ConfigPara.SvrAddr[2] = 104; GateWay.ConfigPara.LTENet.DestAddr[2] = 103;
GateWay.ConfigPara.SvrAddr[3] = 4; GateWay.ConfigPara.LTENet.DestAddr[3] = 147;
GateWay.ConfigPara.SvrPort = 8007; GateWay.ConfigPara.LTENet.DestPort = 8080;
GateWay.ConfigPara.CommUnitReadInterval = COMMUNIT_READ_SENSOR_INTERVAL_MAX; #elif MAC_ADDR_TYPE > 0
GateWay.ConfigPara.LTENet.DestAddr[0] = 103;
GateWay.ConfigPara.LTENet.DestAddr[1] = 217;
GateWay.ConfigPara.LTENet.DestAddr[2] = 192;
GateWay.ConfigPara.LTENet.DestAddr[3] = 248;
GateWay.ConfigPara.LTENet.DestPort = 12111;
#endif
GateWay.ConfigPara.CommUnitReadInterval = COMMUNIT_READ_SENSOR_INTERVAL_MAX;//非低功耗设备
memset(GateWay.ConfigPara.CommUnitArray, 0x00, sizeof(CommUnitData_t) * COMMUNIT_NUM_MAX); memset(GateWay.ConfigPara.CommUnitArray, 0x00, sizeof(CommUnitData_t) * COMMUNIT_NUM_MAX);
GateWay.ConfigPara.Rs485Ch1.Enable = true; GateWay.ConfigPara.Rs485Ch1.Enable = true;
GateWay.ConfigPara.Rs485Ch1.CommUnitEnable = false; GateWay.ConfigPara.Rs485Ch1.CommUnitEnable = false;
@@ -151,7 +168,9 @@ void GateWayInit(void)
GateWay.ConfigPara.Rs485Ch2.BaudRate = 500000; GateWay.ConfigPara.Rs485Ch2.BaudRate = 500000;
GateWay.ConfigPara.Rs485Ch2.UpgradeEnable = false; GateWay.ConfigPara.Rs485Ch2.UpgradeEnable = false;
GateWay.ConfigPara.Rs485Ch2.CommUnitEnable = false; GateWay.ConfigPara.Rs485Ch2.CommUnitEnable = false;
GateWay.ConfigPara.Rs485Ch2.Power = true; GateWay.ConfigPara.Rs485Ch2.Power = false;
GateWay.ConfigPara.Rs485Ch1.RS485Send = RS485Ch1UartSend;
GateWay.ConfigPara.Rs485Ch2.RS485Send = RS485Ch2UartSend;
GateWay.ConfigPara.Lora.OnOff = true; GateWay.ConfigPara.Lora.OnOff = true;
GateWay.ConfigPara.Lora.ucChannel = 8; GateWay.ConfigPara.Lora.ucChannel = 8;
@@ -161,49 +180,22 @@ void GateWayInit(void)
GateWay.ConfigPara.Lora.ErrorCoding = 2; GateWay.ConfigPara.Lora.ErrorCoding = 2;
GateWay.ConfigPara.Lora.RegPreamble = 10; GateWay.ConfigPara.Lora.RegPreamble = 10;
GateWay.ConfigPara.Lora.FreqCent = FREQ_CENT; GateWay.ConfigPara.Lora.FreqCent = FREQ_CENT;
GateWay.ConfigPara.OutageFlag = false; GateWay.ConfigPara.OutageFlag = false;
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1; GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
}
if(GateWay.ConfigPara.OutageFlag != true && GateWay.ConfigPara.OutageFlag != false)
GateWay.ConfigPara.OutageFlag = false;
GateWay.SvrRegFlag = false;
memset(GateWay.SvrMac, 0x00, 6);
GateWay.ConfigPara.Rs485Ch1.RS485Send = RS485Ch1UartSend;
GateWay.ConfigPara.Rs485Ch2.RS485Send = RS485Ch2UartSend;
GateWay.ConfigPara.Rs485Ch1.Enable = true;
GateWay.ConfigPara.Rs485Ch1.CommUnitEnable = false;
GateWay.ConfigPara.Rs485Ch1.UpgradeEnable = true;
GateWay.ConfigPara.Rs485Ch1.BaudRate = 500000;
GateWay.ConfigPara.Rs485Ch1.Power = false;
GateWay.ConfigPara.Rs485Ch2.Enable = true;
GateWay.ConfigPara.Rs485Ch2.BaudRate = 500000;
GateWay.ConfigPara.Rs485Ch2.CommUnitEnable = false;
GateWay.ConfigPara.Rs485Ch2.UpgradeEnable = false;
GateWay.ConfigPara.Rs485Ch2.Power = false;
GateWay.ConfigPara.Lora.OnOff = true;
GateWay.ConfigPara.Lora.ucChannel = 8;
GateWay.ConfigPara.Lora.ucPower = 20;
GateWay.ConfigPara.Lora.SignalBw = 8;
GateWay.ConfigPara.Lora.SpreadFactor = 9;
GateWay.ConfigPara.Lora.ErrorCoding = 2;
GateWay.ConfigPara.Lora.RegPreamble = 10;
GateWay.ConfigPara.Lora.FreqCent = FREQ_CENT;
#if MAC_ADDR_TYPE == 0 #if MAC_ADDR_TYPE == 0
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_Test, 6); memcpy(GateWay.ConfigPara.GwMac, GateWayMac_Test, 6);
GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG; // GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG;
#elif MAC_ADDR_TYPE == 1 #elif MAC_ADDR_TYPE == 1
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL1, 6); memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL1, 6);
//GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1; GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG; // GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG;
#elif MAC_ADDR_TYPE == 2 #elif MAC_ADDR_TYPE == 2
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL2, 6); memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL2, 6);
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1; GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
//GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG; // GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG;
#elif MAC_ADDR_TYPE == 3 #elif MAC_ADDR_TYPE == 3
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL3, 6); memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL3, 6);
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1; GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
@@ -229,26 +221,14 @@ void GateWayInit(void)
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL10, 6); memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL10, 6);
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1; GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
#endif #endif
}
#if MAC_ADDR_TYPE == 0//测试服务器
GateWay.ConfigPara.SvrAddr[0] = 39; if(GateWay.ConfigPara.OutageFlag != true && GateWay.ConfigPara.OutageFlag != false)
GateWay.ConfigPara.SvrAddr[1] = 106; GateWay.ConfigPara.OutageFlag = false;
GateWay.ConfigPara.SvrAddr[2] = 103;
GateWay.ConfigPara.SvrAddr[3] = 147; GateWay.SvrRegFlag = false;
GateWay.ConfigPara.SvrPort = 8080; memset(GateWay.SvrMac, 0x00, 6);
#elif MAC_ADDR_TYPE > 0
// GateWay.ConfigPara.SvrAddr[0] = 39;
// GateWay.ConfigPara.SvrAddr[1] = 106;
// GateWay.ConfigPara.SvrAddr[2] = 103;
// GateWay.ConfigPara.SvrAddr[3] = 147;
// GateWay.ConfigPara.SvrPort = 8080;
GateWay.ConfigPara.SvrAddr[0] = 103;
GateWay.ConfigPara.SvrAddr[1] = 217;
GateWay.ConfigPara.SvrAddr[2] = 192;
GateWay.ConfigPara.SvrAddr[3] = 248;
GateWay.ConfigPara.SvrPort = 12111;
#endif
if(GateWay.ConfigPara.DebugChannel == DEBUG_CH_RS485_1) { if(GateWay.ConfigPara.DebugChannel == DEBUG_CH_RS485_1) {
GateWay.ConfigPara.Rs485Ch1.Enable = true; GateWay.ConfigPara.Rs485Ch1.Enable = true;
GateWay.ConfigPara.Rs485Ch1.BaudRate = 500000; GateWay.ConfigPara.Rs485Ch1.BaudRate = 500000;
@@ -289,6 +269,11 @@ void GateWayInit(void)
LoraSetChannel(GateWay.ConfigPara.Lora.ucChannel); LoraSetChannel(GateWay.ConfigPara.Lora.ucChannel);
//WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); //WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t));
} }
if(LoraSetFreqCent(GateWay.ConfigPara.Lora.FreqCent) == false)
{
GateWay.ConfigPara.Lora.FreqCent = 433100000;
LoraSetFreqCent(GateWay.ConfigPara.Lora.FreqCent);
}
if(LoraSetPower(GateWay.ConfigPara.Lora.ucPower) == false) { if(LoraSetPower(GateWay.ConfigPara.Lora.ucPower) == false) {
GateWay.ConfigPara.Lora.ucPower = 20; GateWay.ConfigPara.Lora.ucPower = 20;
LoraSetPower(GateWay.ConfigPara.Lora.ucPower); LoraSetPower(GateWay.ConfigPara.Lora.ucPower);
@@ -311,12 +296,12 @@ void GateWayInit(void)
} }
if(GateWay.ConfigPara.Lora.RegPreamble > 0xFE) { if(GateWay.ConfigPara.Lora.RegPreamble > 0xFE) {
GateWay.ConfigPara.Lora.RegPreamble = 10; GateWay.ConfigPara.Lora.RegPreamble = 10;
LoraSetRegPreamble(GateWay.ConfigPara.Lora.RegPreamble);
//WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); //WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t));
} }
LoraSetRegPreamble(GateWay.ConfigPara.Lora.RegPreamble);
WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t));
LogInit(); LogInit();
Header.LogEndAddr = 0; Header.LogEndAddr = 0;
@@ -337,6 +322,8 @@ void GateWayInit(void)
} }
else { else {
ETH_ON(); ETH_ON();
rt_thread_delay(1000);
ETHReset();
} }
} }
@@ -373,7 +360,7 @@ int main(void)
uint8_t AlarmType = 0; uint8_t AlarmType = 0;
GateWayInit(); GateWayInit();
rt_kprintf("\r\n\r\n"); rt_kprintf("\r\n\r\n");
rt_kprintf("****************************************************\r\n"); rt_kprintf("****************************************************\r\n");
rt_kprintf("** **\r\n"); rt_kprintf("** **\r\n");
+2 -1
View File
@@ -33,6 +33,7 @@ static void SpiFlashWaitForWriteEnd(void)
SpiFlashSendByte(SPIFLASH_CMD_RDSR); SpiFlashSendByte(SPIFLASH_CMD_RDSR);
do{ do{
flashstatus = SpiFlashReadByte(); flashstatus = SpiFlashReadByte();
FeedDog();
} }
while ((flashstatus & SPIFLASH_WIP_FLAG) == SPIFLASH_WIP_FLAG); while ((flashstatus & SPIFLASH_WIP_FLAG) == SPIFLASH_WIP_FLAG);
SpiFlashSetNss(); SpiFlashSetNss();
@@ -106,7 +107,7 @@ void SpiFlashWriteAnyLengthData(uint8_t* wData, uint32_t wAddr, uint16_t wLen)
uint16_t FirstPageRemainSpace = SPIFLASH_PAGESIZE - (WriteAddr % SPIFLASH_PAGESIZE); uint16_t FirstPageRemainSpace = SPIFLASH_PAGESIZE - (WriteAddr % SPIFLASH_PAGESIZE);
// //判断是否跨扇区,跨扇区需要先擦除下一扇区 // //判断是否跨扇区,跨扇区需要先擦除下一扇区
// CheckDelSecter(wAddr, wLen); CheckDelSecter(wAddr, wLen);
if(wLen < FirstPageRemainSpace) { if(wLen < FirstPageRemainSpace) {
FirstPageWriteSize = wLen; //计算首页写入长度 FirstPageWriteSize = wLen; //计算首页写入长度
+8
View File
@@ -0,0 +1,8 @@
<<<<<<< HEAD
# GateWay
一代网关
=======
# LaserTracing_Debug
>>>>>>> aaff1aeec5ea03de83eee8888e10da1bf6a62ded
+8
View File
@@ -0,0 +1,8 @@
<<<<<<< HEAD
# GateWay
一代网关
=======
# LaserTracing_Debug
>>>>>>> aaff1aeec5ea03de83eee8888e10da1bf6a62ded
View File
View File
+3
View File
@@ -0,0 +1,3 @@
# GateWay
一代网关
+3
View File
@@ -0,0 +1,3 @@
# GateWay
一代网关
+2
View File
@@ -0,0 +1,2 @@
# LaserTracing_Debug
+2
View File
@@ -0,0 +1,2 @@
# LaserTracing_Debug
BIN
View File
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
old=b"b'\xb7\xb5\xbb\xd8\xd6\xb5,\xd5\xe2\xc0\xef\xbc\xf2\xb5\xa5\xb5\xc8\xb4\xfd\xba\xf3\xbc\xcc\xd0\xf8 */\r\n\t}\r\n\tCAT1_DBG_LOG("ETH Init check done");\r\n\r\n\t/* \xb2\xbd\xd6\xe81: \xd2\xbb\xb4\xce\xd0\xd4\xd0\xb4\xc8\xeb\xb4\xd30x00\xbf\xaa\xca\xbc\xb5\xc4\xcd\xf8\xc2\xe7\xb2\xce\xca\xfd(LocalIP~WorkMode, \xb9\xb20x15\xd7\xd6\xbd\xda)\r\n\t * \xc6\xab\xd2\xc60x00~0x14: LocalIP(4) + NetMask(4) + Gateway(4) + DestIP(4) + LocalPort(2) + DestPort(2) + WorkMode(1)\r\n\t */\r\n\tidx = 0;\r\n\tcmdBuf[idx++] = 0xED; cmdBuf[idx++] = 0xF2; cmdBuf[idx++] = 0xA3; cmdBuf[idx++] = 0x56;\r\n\tcmdBuf[idx++] = 0xCA; cmdBuf[idx++] = 0xDB; cmdBuf[idx++] = 0x91; cmdBuf[idx++] = 0x84;\r\n\tcmdBuf[idx++] = 0xB0; cmdBuf[idx++] = 0xD7;\r\n\tcmdBuf[idx++] = 0x03; /* \xc3\xfc\xc1\xee\xc0\xe0\xd0\xcd: \xd0\xb4\xb2\xce\xca\xfd\xb2\xa2\xb1\xa3\xb4\xe6\xb5\xbdFlash */\r\n\tcmdBuf[idx++] = 0x00; /* \xc6\xab\xd2\xc6: 0x00 */\r\n\tcmdBuf[idx++] = 0x15; /* \xb3\xa4\xb6\xc8: 21\xd7\xd6\xbd\xda */\r\n\r\n\t/* Local IP */\r\n\tcmdBuf[idx++] = pCfg->EthNet.IpAddr[0];\r\n\tcmdBuf[idx++] = pCfg->EthNet.IpAddr[1];\r\n\tcmdBuf[idx++] = pCfg->EthNet.IpAddr[2];\r\n\tcmdBuf[idx++] = pCfg->EthNet.IpAddr[3];\r\n\t/* Net Mask */\r\n\tcmdBuf[idx++] = pCfg->EthNet.SubnetMask[0];\r\n\tcmdBuf[idx++] = pCfg->EthNet.SubnetMask[1];\r\n\tcmdBuf[idx++] = pCfg->EthNet.SubnetMask[2];\r\n\tcmdBuf[idx++] = pCfg->EthNet.SubnetMask[3];\r\n\t/* Gateway */\r\n\tcmdBuf[idx++] = pCfg->EthNet.Gateway[0];\r\n\tcmdBuf[idx++] = pCfg->EthNet.Gateway[1];\r\n\tcmdBuf[idx++] = pCfg->EthNet.Gateway[2];\r\n\tcmdBuf[idx++] = pCfg->EthNet.Gateway[3];\r\n\t/* Dest IP */\r\n\tcmdBuf[idx++] = pCfg->EthNet.DestIp[0];\r\n\tcmdBuf[idx++] = pCfg->EthNet.DestIp[1];\r\n\tcmdBuf[idx++] = pCfg->EthNet.DestIp[2];\r\n\tcmdBuf[idx++] = pCfg->EthNet.DestIp[3];\r\n\t/* Local Port (\xb4\xf3\xb6\xcb) */\r\n\tcmdBuf[idx++] = (uint8_t)(pCfg->EthNet.IpPort >> 8);\r\n\tcmdBuf[idx++] = (uint8_t)(pCfg->EthNet.IpPort & 0xFF);\r\n\t/* Dest Port (\xb4\xf3\xb6\xcb) */\r\n\tcmdBuf[idx++] = (uint8_t)(pCfg->EthNet.DestPort >> 8);\r\n\tcmdBuf[idx++] = (uint8_t)(pCfg->EthNet.DestPort & 0xFF);\r\n\t/* Work Mode: 0=TCP Server, 1=TCP Client, 2=UDP */\r\n\tif(pCfg->EthNet.WorkMode == ETH_MODE_TCP_SERVER) {\r\n\t\tcmdBuf[idx++] = 0x00;\r\n\t} else if(pCfg->EthNet.WorkMode == ETH_MODE_TCP_CLIENT) {\r\n\t\tcmdBuf[idx++] = 0x01;\r\n\t} else {\r\n\t\tcmdBuf[idx++] = 0x02;\r\n\t}\r\n\r\n\tCAT1_DBG_LOG("ETH Write IP/Mode, len=%d", idx);\r\n'"