-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
luatos_bot
committed
Dec 9, 2024
1 parent
5284e64
commit 29c78ee
Showing
14 changed files
with
2,050 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# ercoap - 新的Coap协议解析库 | ||
|
||
{bdg-secondary}`适配状态未知` | ||
|
||
```{note} | ||
本页文档由[这个文件](https://gitee.com/openLuat/LuatOS/tree/master/luat/../components/network/ercoap/binding/luat_lib_ercoap.c)自动生成。如有错误,请提交issue或帮忙修改后pr,谢谢! | ||
``` | ||
|
||
```{tip} | ||
本库有专属demo,[点此链接查看ercoap的demo例子](https://gitee.com/openLuat/LuatOS/tree/master/demo/ercoap) | ||
``` | ||
|
||
## ercoap.parse(data) | ||
|
||
|
||
|
||
解析coap数据包 | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|string|coap数据包| | ||
|
||
**返回值** | ||
|
||
|返回值类型|解释| | ||
|-|-| | ||
|table|成功返回table,否则返回nil| | ||
|
||
**例子** | ||
|
||
```lua | ||
-- 本函数是解析coap数据包 | ||
local rcoap = ercoap.parse(data) | ||
if rcoap then | ||
log.info("coap", rcoap.type, rcoap.code, rcoap.payload) | ||
-- rcoap的属性 | ||
-- type 消息类型, 0 - CON 需要答复, 1 - NON 无需答复, 2 - ACK 已收到, 3 - RST 出错了 | ||
-- msgid 消息id | ||
-- payload 携带的数据 | ||
-- code 类似于http的statue code, 通过有 2xx 正常, 4xx 出错了 | ||
else | ||
log.info("ercoap", "数据包解析失败") | ||
end | ||
|
||
``` | ||
|
||
--- | ||
|
||
## ercoap.print(data) | ||
|
||
|
||
|
||
打印coap数据包 | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|string|coap数据包| | ||
|
||
**返回值** | ||
|
||
|返回值类型|解释| | ||
|-|-| | ||
|boolean|解析成功返回true| | ||
|
||
**例子** | ||
|
||
```lua | ||
-- 本函数单纯就打印一下coap数据包 | ||
|
||
``` | ||
|
||
--- | ||
|
||
## ercoap.onenet(tp, product_id, device_name, token, payload) | ||
|
||
|
||
|
||
快速生成onenet数据包 | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|string|请求类型,作为reply时可选,其他情况必选| | ||
|string|项目id,必须填写| | ||
|string|设备名称,必须填写| | ||
|string|token,必须填写| | ||
|string|物模型json字符串,可选| | ||
|
||
**返回值** | ||
|
||
|返回值类型|解释| | ||
|-|-| | ||
|string|合成好的数据包,可通过UDP上行| | ||
|
||
**例子** | ||
|
||
```lua | ||
-- 参考文档: coap接入 https://open.iot.10086.cn/doc/v5/fuse/detail/924 | ||
-- 参考文档: 物模型 https://open.iot.10086.cn/doc/v5/fuse/detail/902 | ||
|
||
-- 类型 tp值 token来源 payload | ||
-- 登陆 login iotauth.onenet函数生成 无 | ||
-- 心跳 keep_live iotauth.onenet函数生成 无 | ||
-- 登出 logout iotauth.onenet函数生成 无 | ||
-- 属性上报 thing/property/post login时获取 必须有 | ||
-- 属性回复 thing/property/reply login时获取 必须有 | ||
-- 事件上报 thing/event/post login时获取 必须有 | ||
-- 远程调用答复 无 login时获取 必须有 | ||
|
||
``` | ||
|
||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# natp - 网络地址端口转换(开发中) | ||
|
||
{bdg-success}`已适配` {bdg-primary}`Air780EP` | ||
|
||
```{note} | ||
本页文档由[这个文件](https://gitee.com/openLuat/LuatOS/tree/master/luat/../components/network/ulwip/binding/luat_lib_napt.c)自动生成。如有错误,请提交issue或帮忙修改后pr,谢谢! | ||
``` | ||
|
||
|
||
**示例** | ||
|
||
```lua | ||
-- 开发中, 请关注 https://github.com/wendal/xt804-spinet | ||
|
||
``` | ||
|
||
## napt.init(adapter) | ||
|
||
|
||
|
||
初始化NAPT | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|int|adapter 目标网卡索引, 默认是socket.LWIP_AP, 这里指内网| | ||
|
||
**返回值** | ||
|
||
|返回值类型|解释| | ||
|-|-| | ||
|nil|无返回值| | ||
|
||
**例子** | ||
|
||
无 | ||
|
||
--- | ||
|
||
## napt.rebuild(buff, is_inet, adapter) | ||
|
||
|
||
|
||
重建MAC包 | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|userdata|待处理的MAC包,必须是zbuff对象| | ||
|bool|来源是不是内网| | ||
|int|目标网络适配器的索引, 例如socket.LWIP_GP| | ||
|
||
**返回值** | ||
|
||
|返回值类型|解释| | ||
|-|-| | ||
|bool|成功返回true,失败返回false| | ||
|
||
**例子** | ||
|
||
无 | ||
|
||
--- | ||
|
||
## napt.check() | ||
|
||
|
||
|
||
检查和清理NAT表 | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|return|nil| | ||
|
||
**返回值** | ||
|
||
无 | ||
|
||
**例子** | ||
|
||
```lua | ||
-- 两次check之间没有数据包的映射记录,会被清理 | ||
|
||
``` | ||
|
||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# nes - nes模拟器 | ||
|
||
{bdg-success}`已适配` {bdg-primary}`Air780E` {bdg-primary}`Air780EP` | ||
|
||
```{note} | ||
本页文档由[这个文件](https://gitee.com/openLuat/LuatOS/tree/master/luat/../components/nes/luat_lib_nes.c)自动生成。如有错误,请提交issue或帮忙修改后pr,谢谢! | ||
``` | ||
|
||
|
||
## nes.init(file_path) | ||
|
||
|
||
|
||
nes模拟器初始化 | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|string|file_path 文件路径| | ||
|
||
**返回值** | ||
|
||
|返回值类型|解释| | ||
|-|-| | ||
|bool|成功返回true,否则返回false| | ||
|
||
**例子** | ||
|
||
```lua | ||
nes.init("/luadb/super_mario.nes") | ||
|
||
``` | ||
|
||
--- | ||
|
||
## nes.key(key,val) | ||
|
||
|
||
|
||
nes模拟器初始化 | ||
|
||
**参数** | ||
|
||
|传入值类型|解释| | ||
|-|-| | ||
|number|key 按键| | ||
|number|val 状态 1按下 0抬起| | ||
|
||
**返回值** | ||
|
||
|返回值类型|解释| | ||
|-|-| | ||
|bool|成功返回true,否则返回false| | ||
|
||
**例子** | ||
|
||
```lua | ||
nes.init("/luadb/super_mario.nes") | ||
|
||
``` | ||
|
||
--- | ||
|
Oops, something went wrong.