Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeBo committed Oct 28, 2018
1 parent 52e7c0a commit dc417ac
Show file tree
Hide file tree
Showing 64 changed files with 12,677 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"aliosStudio.sdkPath": "/Users/miaogs/.aos/AliOS-Things",
"aliosStudio.sdkPath": "C:\\Users\\Administrator\\.aos\\AliOS-Things",
"files.associations": {
"emh_api.h": "c",
"atcmdparser.h": "c"
Expand Down
165 changes: 163 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


## 1. 简介
本 sdk 提供一个基于 Linux,通过与 Wi-Fi 模块进行 AT 指令串口通信,实现与阿里云 ILOP 和 sds 直连的 IoT 物联网典型开发应用示例源代码。
本 sdk 提供一个基于 Linux和STM32F411RE,通过与 Wi-Fi 模块进行 AT 指令串口通信,实现与阿里云 ILOP 和 sds 以及中国移动杭研平台 直连的 IoT 物联网典型开发应用示例源代码,master分支是基于linux平台,NUCLEOF411RE分支是基于IAR和GCC平台

## 2. 目录结构

Expand All @@ -11,6 +11,7 @@
| |---ilopicaapp /*ilop平台 ica标准数据格式的demo*/
| |---iloprawapp /*ilop平台 自定义数据格式的demo*/
| |---sdsapp /*sds平台的demo*/
| |---qlinkapp /*杭研平台的demo*/
| |---test /*测试demo*/
|
|---platform
Expand Down Expand Up @@ -89,6 +90,166 @@ open at uart succeed

### 4.2 阿里 ilop 平台的透传demo

## 4. 移植SDK
### 4.3 杭研 qlink 平台的demo

#### 4.3.1 使用流程

(1) 获取客户在杭研申请账号密码

(2) 商务洽谈后,提交资料,完成后台产品创建,后台地址:[https://open.home.komect.com/partner/](https://open.home.komect.com/partner/)

(3) 搭建虚拟网关开发环境(详见examples/qlink中materials文件夹)

(4) 进行本地能网关环境下验证(使用虚拟网关开发调试)

(5) 杭研现场验收

(6) 项目入库

(7) 厂家提交配网相关资料,杭研配置成XML文件集成到H5开发的和家亲APP(此步奏或许可以提前,需要厂商和杭研沟通)

(8) 使用materials/下的和家亲APP测试(开发环境获取到的mqtt服务器地址以.199结尾,测试环境以.207结尾,生产环境以205结尾)

(8) 杭研云网关验证

#### 4.3.2 使用方法

* (1) 庆科wifi模块烧录杭研qlink最新[AT固件](http://developer.mxchip.com/downloads/22/)


固件烧录具体方法可以参考resource/common/烧录路径下相关文档。

* (2) 修改产品信息


新建产品后,可以获得product_token,andlink_token,product_id,豪恩报警盒子产品信息如下:
![30531](./resource/qlink/image/产品资料.png)
```
初始化产品参数
const emh_qlink_config_t config = {
.product_info = {
.product_id = "30531",
.product_token = "PXmsE6kQmxEgc0e3",
.andlink_token = "ZxMo0zJvvZMWP3Az",
.format = EMH_ARG_QLINK_FORMAT_JSON,
},
.version_info = {
.firmware_version = "1.4.3",
.software_version = "1.0.1",
}
};
```

* (3) 编译运行demo


* make clean
```
wumingju@ubuntu:/mnt/hgfs/Work/project/AT_demo/at_host_qlink$ make clean
cleaning...
done
```

* make qlinkapp

```
mkdir build
compiling platform/linux/mx_serial.c
compiling platform/linux/mx_stdio.c
compiling platform/linux/mx_tick.c
compiling platform/linux/mx_uart.c
compiling src/helper/cli/mx_cli.c
compiling src/helper/emhost/ATCmdParser/ATCmdParser.c
compiling src/helper/emhost/emh_alisds.c
compiling src/helper/emhost/emh_arg.c
compiling src/helper/emhost/emh_ilop.c
compiling src/helper/emhost/emh_qlink.c
generating build/iot-qlinkapp.elf
text data bss dec hex filename
22826 1168 3696 27690 6c2a build/iot-qlinkapp.elf
```

* 运行 sudo ./build/iot-qlinkapp.elf

```
dev[/dev/ttyUSB0]
[APP: main.c: 150] open cli function
open at uart succeed
[QLINK: cloud_qlink.c: 119] FW version: basic_AT_v2.1.2
[APP: main.c: 30] WiFi config in AP mode......
[APP: main.c: 30] WiFi config in AP mode......
[APP: main.c: 34] Wi-Fi connected
[APP: main.c: 42] Cloud connected
```

* (4) 基于虚拟网关使用说明


* 按照4.3.1使用流程中说明搭建好本地虚拟网关开发环境

* 测试本地环境是否OK

如果本地环境OK,点击配网andlinkdemo1.0.apk 开始连接按钮,会有如下页面:
![环境OK](./resource/qlink/image/环境OK.png)

* 配网操作

通过cli串口发送 raw start命令 或者 按键触发调用qlink_raw_start()接口使设备进入本地网关一键配网模式,

同时手机APP点击开始连接按钮,绑定成功后APP提示添加成功,后台虚拟网关下面会显示出设备,如下:
![bind_ok](./resource/qlink/image/bind_ok.png)

* 数据下发

通过后台获取所有字段,操作如下所示:
![request_all_data](./resource/qlink/image/request_all_data.png)

通过后台获取部分字段,操作如下所示:
![request_some_data](./resource/qlink/image/request_some_data.png)

通过后台下发命令,操作如下所示:
![control_data](./resource/qlink/image/control_data.png)

设备收到云端获取字段指令后,需要调用mx_status emh_qlink_send_json_to_cloud( char *type, uint8_t *data, uint32_t len ) 函数将数据发送到云端

* 数据上传

mx_status qlink_send_data(char *type, uint8_t *data, uint32_t len),通过此函数 即可完成发送数据的功能

```
type: 为发送数据的类型,注意主动上报和响应要选择不同类型
设备主动上报: type = Inform
人为触发的数据上报: type = ParamChange
云端请求上报: type = Data
文件操作: type = File
data:上传具体内容
```
也可通过cli串口输入send type <data> 发送数据

* (5) 基于云网关使用说明

* 提交XML配网资料

完成本地网关验证后,可以提交配网引导界面相关资料,杭研配置XML到手机APP,之后方可进行云网关验证操作,
提交配网资料可以提交本地网关+云网关方式资料或者仅通过云网关配网资料,建议提供只用云网关配网资料,
如此一来,上线验证只需要验证云网关部分即可,减少验证流程,提高上线时间

* 配网操作

通过cli串口发送 user start命令 或者 按键触发调用qlink_user_start()接口使设备进入云网关用户配网模式,

同时手机APP(resource/qlink/2.云网关/app路径)进入添加设备页面,扫描到如下页面,说明设备进入了配网页面:
![user_config](.resource/qlink/image/user_config.png)
点击弹出来的添加按钮即可进行配网操作


#### 4.3.3 注意事项



## 5. 移植SDK

- 只需要实现platform/mx_hal.h文件中的函数即可
22 changes: 12 additions & 10 deletions examples/qlinkapp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ const emh_qlink_config_t config = {
.product_info = {
.product_token = "PXmsE6kQmxEgc0e3",
.andlink_token = "ZxMo0zJvvZMWP3Az",
.device_type = "30531",
.product_id = "30531",
.format = EMH_ARG_QLINK_FORMAT_JSON,
},
// .product_info = {
// .product_token = "38Szyd6i1240elbV",
// .andlink_token = "wWppJIdROfQkcsMW",
// .device_type = "30413",
// .format = EMH_ARG_QLINK_FORMAT_JSON,
// },
.version_info = {
.firmware_version = "1.4.3",
.software_version = "1.0.1",
}
};

// .product_info = {
// .product_token = "38Szyd6i1240elbV",
// .andlink_token = "wWppJIdROfQkcsMW",
// .product_id = "30413",
// .format = EMH_ARG_QLINK_FORMAT_JSON,
// },

void qlink_event_handler(qlink_event_t event)
{
switch (event) {
Expand Down Expand Up @@ -118,15 +118,17 @@ static void handle_reboot_cmd(char* pwbuf, int blen, int argc, char** argv)

}

// {"deviceId":"CMCC-30531-B0F89327CDF4","childDeviceId":"","eventType":"Inform","timestamp":0,"data":{"params":[{"paramCode":"permitJoining","paramValue":"0"},{"paramCode":"firmware","paramValue":"1.6.0"},{"paramCode":"softVersion","paramValue":"V1.0.6"}]}}
static void handle_send_cmd(char* pwbuf, int blen, int argc, char** argv)
{
if (argc != 3)
{
app_log("input param error!!!");
return;
}

emh_qlink_send_json_to_cloud( QLINK_EVENT_TYPE_INFORM, *argv[2], strlen(*argv[2]) );
app_log("type is:%s\r\n data is:%s\r\ndata's length is:%d", argv[1], argv[2], strlen(argv[2]) );

qlink_send_data( argv[1], argv[2], strlen(argv[2]) );
}

struct cli_command qlinkcmds[] = {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ע�⣺
1. �����ԡ�����Ա���ݡ����д˳���
2. ���޷��������У���򿪡�Windows 7������ģʽ��
3.��ʹ��factoryģʽ����¼�̼�������full bin����ʱ�Ѿ��������棬ÿ�ο���Ĭ�ϵ�factory mode��������������Normal Mode ,��ִ����MXCHIP_IMG_TOOL_RESET���򡣼��ɻָ���
4.ʹ��ATE�̼�������Ҫ�Ƚ�COM�ڸ��µ�3���ڡ����ɶ�ȡģ�顣
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#Californium CoAP Properties file
#Thu Jun 28 11:25:11 CST 2018
HTTP_SERVER_SOCKET_BUFFER_SIZE=8192
UDP_CONNECTOR_OUT_CAPACITY=2147483647
CONGESTION_CONTROL_ALGORITHM=Cocoa
USE_CONGESTION_CONTROL=false
ACK_TIMEOUT=2000
MAX_ACTIVE_PEERS=150000
TCP_CONNECT_TIMEOUT=10000
NOTIFICATION_CHECK_INTERVAL_COUNT=100
MAX_MESSAGE_SIZE=1024
DEDUPLICATOR=DEDUPLICATOR_MARK_AND_SWEEP
TCP_CONNECTION_IDLE_TIMEOUT=10
COAP_PORT=5683
ACK_TIMEOUT_SCALE=2.0
PREFERRED_BLOCK_SIZE=512
NETWORK_STAGE_RECEIVER_THREAD_COUNT=4
PROTOCOL_STAGE_THREAD_COUNT=4
MAX_TRANSMIT_WAIT=93000
USE_STRICT_RESPONSE_MATCHING=false
UDP_CONNECTOR_RECEIVE_BUFFER=0
EXCHANGE_LIFETIME=247000
HTTP_SERVER_SOCKET_TIMEOUT=100000
CROP_ROTATION_PERIOD=2000
UDP_CONNECTOR_DATAGRAM_SIZE=2048
MAX_RETRANSMIT=4
MAX_PEER_INACTIVITY_PERIOD=600
MAX_RESOURCE_BODY_SIZE=8192
NOTIFICATION_CHECK_INTERVAL=86400000
LEISURE=5000
HTTP_CACHE_RESPONSE_MAX_AGE=86400
BLOCKWISE_STATUS_LIFETIME=300000
UDP_CONNECTOR_SEND_BUFFER=0
TCP_WORKER_THREADS=1
HEALTH_STATUS_PRINT_LEVEL=FINEST
NETWORK_STAGE_SENDER_THREAD_COUNT=4
NON_LIFETIME=145000
TOKEN_SIZE_LIMIT=8
HTTP_PORT=8080
MARK_AND_SWEEP_INTERVAL=10000
HEALTH_STATUS_INTERVAL=60
ACK_RANDOM_FACTOR=1.5
NSTART=1
USE_RANDOM_MID_START=true
HTTP_CACHE_SIZE=32
PROBING_RATE=1.0
NOTIFICATION_REREGISTRATION_BACKOFF=2000
COAP_SECURE_PORT=5684
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#My customized log properties
#Thu Jun 28 11:25:11 CST 2018
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.File.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH\:mm\:ss,SSS} %l%n%m%n%n
log4j.appender.Console.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH\:mm\:ss,SSS} %l%n%m%n%n
log4j.appender.File=org.apache.log4j.DailyRollingFileAppender
log4j.rootLogger=INFO,Console,File
log4j.appender.File.File=D\:\\Work\\project\\factory\\onenet_hangzhou\\debug\\gateay_tool\\logs\\log.log
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.File.Append=true
log4j.appender.File.Threshold=DEBUG
log4j.appender.Console.Target=System.out
log4j.appender.File.layout=org.apache.log4j.PatternLayout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
���� 28, 2018 5:54:11 ���� org.eclipse.californium.core.network.config.NetworkConfig load
��Ϣ: loading properties from file D:\Work\project\factory\onenet_hangzhou\debug\gateay_tool\Californium.properties
���� 28, 2018 5:54:14 ���� org.eclipse.californium.core.network.CoapEndpoint start
��Ϣ: Starting endpoint at coap://0.0.0.0:0
���� 28, 2018 5:54:15 ���� org.eclipse.californium.core.network.CoapEndpoint start
��Ϣ: Started endpoint at coap://0.0.0.0:62565
���� 28, 2018 5:54:15 ���� org.eclipse.californium.core.network.EndpointManager createDefaultEndpoint
��Ϣ: Created implicit endpoint coap://0.0.0.0:62565 for coap
Loading

0 comments on commit dc417ac

Please sign in to comment.