阿里物联平台SDK的小改造

发布于 2019-05-27 22:51:41    浏览:886
    本帖最后由 Spunky 于 2019-5-27 23:02 编辑


目前项目使用阿里物联网平台遇到1个问题比较现实的问题,产品需求要求除了具备常规的MQTT功能外还需要具备OTA功能,造成SRAM不够,动态内存分配失败。如果取消TLS功能内存就有富余了,但是OTA功能又不行。本想不想去造轮子直接用,但没办法,只能搞清楚SDK的实现原理和框架再做打算。经过上周周日一天的源码浏览,发现其实阿里SDK的脉络还是比较清晰的,因此也有了比较粗糙的改造方案。

1. 先说说阿里OTA的实现原理:
***SDK利用MQTT通道实现控制类消息的传送,例如版本号信息和HTTPS的URL地址,注意这个MQTT通道可以不使用TLS加密(明文传输)。
***OTA模块得到HTTPS的URL后采用TLS连接,实现文件传送。
按照阿里SDK的思路,如果要实现OTA,MQTT也必须使用TLS。这样程序会建立两个TLS的链路通道,消耗内存巨大。

2. 基于以上原理,为了节约内存,改造方案采用MQTT不加密,而OTA使用加密。原则上,尽量少变动SDK源码。
具体实现如下:
1. 修改ca.c文件,将root证书iotx_ca_crt的条件编译去掉,然后增加一个iotx_ota_ca_get()函数: // #ifndef IOTX_WITHOUT_TLS
static const char *iotx_ca_crt = \
{
\
"-----BEGIN CERTIFICATE-----\r\n"
"MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG\r\n" \
"A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv\r\n" \
"b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw\r\n" \
"MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i\r\n" \
"YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT\r\n" \
"aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ\r\n" \
"jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp\r\n" \
"xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp\r\n" \
"1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG\r\n" \
"snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ\r\n" \
"U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8\r\n" \
"9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E\r\n" \
"BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B\r\n" \
"AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz\r\n" \
"yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE\r\n" \
"38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP\r\n" \
"AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad\r\n" \
"DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME\r\n" \
"HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\r\n" \
"-----END CERTIFICATE-----"
};
// #endif /* #ifndef IOTX_WITHOUT_TLS */

const char *iotx_ota_ca_get(void)
{
return iotx_ca_crt;
}

const char *iotx_ca_get(void)
{
#ifdef IOTX_WITHOUT_TLS
return NULL;
#else
return iotx_ca_crt;
#endif
}

2. 修改ota_fetch.c文件中的ofc_Fetch()函数内容
int32_t ofc_Fetch(void *handle, char *buf, uint32_t buf_len, uint32_t timeout_s)
{
int diff;
otahttp_Struct_pt h_odc = (otahttp_Struct_pt)handle;

h_odc->http_data.response_buf = buf;
h_odc->http_data.response_buf_len = buf_len;
diff = h_odc->http_data.response_content_len - h_odc->http_data.retrieve_len;;

if (0 != httpclient_common(&h_odc->http, h_odc->url, 443, iotx_ota_ca_get(), HTTPCLIENT_GET, timeout_s * 1000,
&h_odc->http_data)) {
OTA_LOG_ERROR("fetch firmware failed");
return -1;
}
// if (0 != httpclient_common(&h_odc->http, h_odc->url, 443, iotx_ca_get(), HTTPCLIENT_GET, timeout_s * 1000,
// &h_odc->http_data)) {
// OTA_LOG_ERROR("fetch firmware failed");
// return -1;
// }

return h_odc->http_data.response_content_len - h_odc->http_data.retrieve_len - diff;
}

3. 修改utils_net.c文件,首先把文件里面utils_net_read(),utils_net_write(),utils_net_connect()和utils_net_disconnect()函数内部的IOTX_WITHOUT_TLS条件编译去掉。
然后将read_ssl(),write_ssl(),connect_ssl(),disconnect_ssl()函数外部的IOTX_WITHOUT_TLS条件编译去掉。修改之后如下:
/*** SSL connection ***/
// #ifndef IOTX_WITHOUT_TLS
static int read_ssl(utils_network_pt pNetwork, char *buffer, uint32_t len, uint32_t timeout_ms)
{
if (NULL == pNetwork) {
log_err("network is null");
return -1;
}

return HAL_SSL_Read((uintptr_t)pNetwork->handle, buffer, len, timeout_ms);
}

static int write_ssl(utils_network_pt pNetwork, const char *buffer, uint32_t len, uint32_t timeout_ms)
{
if (NULL == pNetwork) {
log_err("network is null");
return -1;
}

return HAL_SSL_Write((uintptr_t)pNetwork->handle, buffer, len, timeout_ms);
}

static int disconnect_ssl(utils_network_pt pNetwork)
{
if (NULL == pNetwork) {
log_err("network is null");
return -1;
}

HAL_SSL_Destroy((uintptr_t)pNetwork->handle);
pNetwork->handle = 0;

return 0;
}

static int connect_ssl(utils_network_pt pNetwork)
{
if (NULL == pNetwork) {
log_err("network is null");
return 1;
}

if (0 != (pNetwork->handle = (intptr_t)HAL_SSL_Establish(
pNetwork->pHostAddress,
pNetwork->port,
pNetwork->ca_crt,
pNetwork->ca_crt_len + 1))) {
return 0;
} else {
/* TODO SHOLUD not remove this handle space */
/* The space will be freed by calling disconnect_ssl() */
/* utils_memory_free((void *)pNetwork->handle); */
return -1;
}
}
// #endif /* #ifndef IOTX_WITHOUT_TLS */


/****** network interface ******/
int utils_net_read(utils_network_pt pNetwork, char *buffer, uint32_t len, uint32_t timeout_ms)
{
int ret = 0;

if (NULL == pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = read_tcp(pNetwork, buffer, len, timeout_ms);
}
#ifndef IOTX_WITHOUT_ITLS
else if (NULL == pNetwork->ca_crt && NULL != pNetwork->product_key) {
ret = read_itls(pNetwork, buffer, len, timeout_ms);
}
#endif
// #ifndef IOTX_WITHOUT_TLS
else if (NULL != pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = read_ssl(pNetwork, buffer, len, timeout_ms);
}
// #endif
else {
ret = -1;
log_err("no method match!");
}

return ret;
}

int utils_net_write(utils_network_pt pNetwork, const char *buffer, uint32_t len, uint32_t timeout_ms)
{
int ret = 0;

if (NULL == pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = write_tcp(pNetwork, buffer, len, timeout_ms);
}
#ifndef IOTX_WITHOUT_ITLS
else if (NULL == pNetwork->ca_crt && NULL != pNetwork->product_key) {
ret = write_itls(pNetwork, buffer, len, timeout_ms);
}
#endif
// #ifndef IOTX_WITHOUT_TLS
else if (NULL != pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = write_ssl(pNetwork, buffer, len, timeout_ms);
}
// #endif
else {
ret = -1;
log_err("no method match!");
}

return ret;
}

int iotx_net_disconnect(utils_network_pt pNetwork)
{
int ret = 0;

if (NULL == pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = disconnect_tcp(pNetwork);
}
#ifndef IOTX_WITHOUT_ITLS
else if (NULL == pNetwork->ca_crt && NULL != pNetwork->product_key) {
ret = disconnect_itls(pNetwork);
}
#endif
// #ifndef IOTX_WITHOUT_TLS
else if (NULL != pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = disconnect_ssl(pNetwork);
}
// #endif
else {
ret = -1;
log_err("no method match!");
}

return ret;
}

int iotx_net_connect(utils_network_pt pNetwork)
{
int ret = 0;

if (NULL == pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = connect_tcp(pNetwork);
}
#ifndef IOTX_WITHOUT_ITLS
else if (NULL == pNetwork->ca_crt && NULL != pNetwork->product_key) {
ret = connect_itls(pNetwork);
}
#endif
// #ifndef IOTX_WITHOUT_TLS
else if (NULL != pNetwork->ca_crt && NULL == pNetwork->product_key) {
ret = connect_ssl(pNetwork);
}
// #endif
else {
ret = -1;
log_err("no method match!");
}

return ret;
}


4. 在ali-iotkit文件夹里修改SConscript文件的124行,添加宏定义IOTX_WITHOUT_TLS,具体如下
CPPDEFINES += ['IOTX_NET_INIT_WITH_PK_EXT', '_PLATFORM_IS_RTTHREAD_', 'IOTX_WITHOUT_ITLS', 'IOTX_WITHOUT_TLS']
5. 然后老规矩scons --target=mdk5,然后打开MDK5编译下载。

运行结果如下:

\ | /
- RT - Thread Operating System
/ | \ 4.0.1 build May 27 2019
2006 - 2019 Copyright by rt-thread team
lwIP-2.1.0 initialized!
[SFUD] Find a Winbond flash chip. Size is 16777216 bytes.
[SFUD] flash0 flash device is initialize success.
[70] I/sal.skt: Socket Abstraction Layer initialize success.
[D/FAL] (fal_flash_init:61) Flash device | onchip_flash | addr: 0x08000000 | len: 0x00100000 | blk_siz e: 0x00020000 |initialized finish.
[D/FAL] (fal_flash_init:61) Flash device | nor_flash | addr: 0x00000000 | len: 0x01000000 | blk_siz e: 0x00001000 |initialized finish.
[I/FAL] ==================== FAL partition table ====================
[I/FAL] | name | flash_dev | offset | length |
[I/FAL] -------------------------------------------------------------
[I/FAL] | app | onchip_flash | 0x00000000 | 0x00100000 |
[I/FAL] | easyflash | nor_flash | 0x00000000 | 0x00100000 |
[I/FAL] | def_imge | nor_flash | 0x00100000 | 0x00100000 |
[I/FAL] | download | nor_flash | 0x00200000 | 0x00100000 |
[I/FAL] | filesystem | nor_flash | 0x00300000 | 0x00d00000 |
[I/FAL] =============================================================
[I/FAL] RT-Thread Flash Abstraction Layer (V0.4.0) initialize success.
[Flash] (packages\EasyFlash-latest\src\ef_env.c:1419) ENV start address is 0x00000000, size is 8192 bytes.
[Flash] EasyFlash V4.0.0 is initialize success.
[Flash] You can get the latest version on .
[I/FAL] The FAL block device (filesystem) created successfully
[1919] I/at.clnt: AT client(V1.2.0) on device uart3 initialize success.
msh />[4936] I/at.sim800c: CHN-UNICOM
LINUXSOCK 83 HAL_TCP_Establish() | establish tcp connection with server(host=a1crq8qKAZz.iot-as-mqtt.cn-shanghai.a liyuncs.com LINUXSOCK 122 HAL_TCP_Establish() | success to establish tcp, fd=5
[5280] I/ali-sdk: subscribe success, packet-id=2
[5286] I/ali-sdk: subscribe success, packet-id=3
[5292] I/ali-sdk: subscribe success, packet-id=7
[5298] I/ali-sdk: subscribe success, packet-id=5
[5305] I/ali-sdk: subscribe success, packet-id=6
[5311] I/ali-sdk: subscribe success, packet-id=1
[5317] I/ali-sdk: subscribe success, packet-id=4
[5641] I/at.sim800c: AT network initialize success!
[6636] I/ali-sdk: subscribe success, packet-id=8


其中:
1) 8号packet-id就是OTA订阅的MQTT控制主题,作用是接收平台的升级通知(里面包含了HTTPS的URL地址),收到后SDK开始使用HTTPS连接下载固件:
/ota/device/upgrade/${YourProductKey}/${YourDeviceName}


2) SDK通过Publish /ota/device/inform/${YourProductKey}/${YourDeviceName}向平台发布版本号


3)SDK通过Publish /ota/device/progress/${YourProductKey}/${YourDeviceName}向平台报告进度或错误
这里要注意,平台不依据此判断是否下载成功,只通过你最后上报的版本号为准。(这里要吐槽一下:你可以欺骗平台,应为阿里的OTA平台不管固件是否下载完毕,你只要上传的版本号和正在下载的版本号一致,他就认为你升级成功了)

下面的运行时得到平台通过/ota/device/upgrade/${YourProductKey}/${YourDeviceName}下发的升级通知后开始通过HTTPS连接指定的URL,并且开始下载。 我把单个下载包设置为4096(例程是5000),比较适合SPI FLASH的写入效率.
在最后下载完毕后我释放了所有OTA的资源,再重新订阅升级的主题地址,就是那个packet-id=18,保证再正常下载顺利。


msh />[inf] _ssl_client_init(175): Loading the CA root certificate ...
cert. version : 3
serial number : 04:00:00:00:00:01:15:4B:5A:C3:94
issuer name : C=BE, O=GlobalSign nv-sa, OU=Root CA, CN=GlobalSign Root CA
subject name : C=BE, O=GlobalSign nv-sa, OU=Root CA, CN=GlobalSign Root CA
issued on : 1998-09-01 12:00:00
expires on : 2028-01-28 12:00:00
signed using : RSA with SHA1
RSA key size : 2048 bits
basic constraints : CA=true
key usage : Key Cert Sign, CRL Sign
[inf] _ssl_parse_crt(143): crt content:451
[inf] _ssl_client_init(183): ok (0 skipped)
[inf] _TLSConnectNetwork(345): Connecting to /iotx-ota.oss-cn-shanghai.aliyuncs.com/443...
[inf] _TLSConnectNetwork(359): ok
[inf] _TLSConnectNetwork(364): . Setting up the SSL/TLS structure...
[inf] _TLSConnectNetwork(374): ok
[inf] _TLSConnectNetwork(409): Performing the SSL/TLS handshake...
[inf] _TLSConnectNetwork(417): ok
[inf] _TLSConnectNetwork(421): . Verifying peer X.509 certificate..
[inf] _real_confirm(92): certificate verification result: 0x00
[29179] I/ali-ota: receive 4096 bytes, total recieve: 0 bytes
[29311] I/ali-ota: receive 4096 bytes, total recieve: 4096 bytes
[29443] I/ali-ota: receive 4096 bytes, total recieve: 8192 bytes
[29575] I/ali-ota: receive 4096 bytes, total recieve: 12288 bytes
[29704] I/ali-ota: receive 4096 bytes, total recieve: 16384 bytes
[29836] I/ali-ota: receive 4096 bytes, total recieve: 20480 bytes
[29968] I/ali-ota: receive 4096 bytes, total recieve: 24576 bytes
[30100] I/ali-ota: receive 4096 bytes, total recieve: 28672 bytes
[30232] I/ali-ota: receive 4096 bytes, total recieve: 32768 bytes
[30364] I/ali-ota: receive 4096 bytes, total recieve: 36864 bytes
[30496] I/ali-ota: receive 4096 bytes, total recieve: 40960 bytes
[30628] I/ali-ota: receive 4096 bytes, total recieve: 45056 bytes
[30760] I/ali-ota: receive 4096 bytes, total recieve: 49152 bytes
[30892] I/ali-ota: receive 4096 bytes, total recieve: 53248 bytes
[31024] I/ali-ota: receive 4096 bytes, total recieve: 57344 bytes
[31156] I/ali-ota: receive 4096 bytes, total recieve: 61440 bytes
[31288] I/ali-ota: receive 4096 bytes, total recieve: 65536 bytes
[31420] I/ali-ota: receive 4096 bytes, total recieve: 69632 bytes
[31549] I/ali-ota: receive 4096 bytes, total recieve: 73728 bytes
[31681] I/ali-ota: receive 4096 bytes, total recieve: 77824 bytes
[31813] I/ali-ota: receive 4096 bytes, total recieve: 81920 bytes
[31945] I/ali-ota: receive 4096 bytes, total recieve: 86016 bytes
[32081] I/ali-ota: receive 4096 bytes, total recieve: 90112 bytes
[32213] I/ali-ota: receive 4096 bytes, total recieve: 94208 bytes
[32345] I/ali-ota: receive 4096 bytes, total recieve: 98304 bytes
[32477] I/ali-ota: receive 4096 bytes, total recieve: 102400 bytes
[32609] I/ali-ota: receive 4096 bytes, total recieve: 106496 bytes
[32741] I/ali-ota: receive 4096 bytes, total recieve: 110592 bytes
[32873] I/ali-ota: receive 4096 bytes, total recieve: 114688 bytes
[33005] I/ali-ota: receive 4096 bytes, total recieve: 118784 bytes
[33137] I/ali-ota: receive 4096 bytes, total recieve: 122880 bytes
[33266] I/ali-ota: receive 4096 bytes, total recieve: 126976 bytes
[33398] I/ali-ota: receive 4096 bytes, total recieve: 131072 bytes
[33530] I/ali-ota: receive 4096 bytes, total recieve: 135168 bytes
[33662] I/ali-ota: receive 4096 bytes, total recieve: 139264 bytes
[33794] I/ali-ota: receive 4096 bytes, total recieve: 143360 bytes
[33926] I/ali-ota: receive 4096 bytes, total recieve: 147456 bytes
[34058] I/ali-ota: receive 4096 bytes, total recieve: 151552 bytes
[34190] I/ali-ota: receive 4096 bytes, total recieve: 155648 bytes
[34322] I/ali-ota: receive 4096 bytes, total recieve: 159744 bytes
[34454] I/ali-ota: receive 4096 bytes, total recieve: 163840 bytes
[34586] I/ali-ota: receive 4096 bytes, total recieve: 167936 bytes
[34718] I/ali-ota: receive 4096 bytes, total recieve: 172032 bytes
[34850] I/ali-ota: receive 4096 bytes, total recieve: 176128 bytes
[34982] I/ali-ota: receive 4096 bytes, total recieve: 180224 bytes
[35111] I/ali-ota: receive 4096 bytes, total recieve: 184320 bytes
[35243] I/ali-ota: receive 4096 bytes, total recieve: 188416 bytes
[35375] I/ali-ota: receive 4096 bytes, total recieve: 192512 bytes
[35507] I/ali-ota: receive 4096 bytes, total recieve: 196608 bytes
[35639] I/ali-ota: receive 4096 bytes, total recieve: 200704 bytes
[35771] I/ali-ota: receive 4096 bytes, total recieve: 204800 bytes
[35903] I/ali-ota: receive 4096 bytes, total recieve: 208896 bytes
[36035] I/ali-ota: receive 4096 bytes, total recieve: 212992 bytes
[36167] I/ali-ota: receive 4096 bytes, total recieve: 217088 bytes
[36299] I/ali-ota: receive 4096 bytes, total recieve: 221184 bytes
[36431] I/ali-ota: receive 4096 bytes, total recieve: 225280 bytes
[36563] I/ali-ota: receive 4096 bytes, total recieve: 229376 bytes
[36695] I/ali-ota: receive 4096 bytes, total recieve: 233472 bytes
[36824] I/ali-ota: receive 4096 bytes, total recieve: 237568 bytes
[36956] I/ali-ota: receive 4096 bytes, total recieve: 241664 bytes
[37093] I/ali-ota: receive 4096 bytes, total recieve: 245760 bytes
[37225] I/ali-ota: receive 4096 bytes, total recieve: 249856 bytes
[37357] I/ali-ota: receive 4096 bytes, total recieve: 253952 bytes
[37489] I/ali-ota: receive 4096 bytes, total recieve: 258048 bytes
[37621] I/ali-ota: receive 4096 bytes, total recieve: 262144 bytes
[37753] I/ali-ota: receive 4096 bytes, total recieve: 266240 bytes
[37885] I/ali-ota: receive 4096 bytes, total recieve: 270336 bytes
[38017] I/ali-ota: receive 4096 bytes, total recieve: 274432 bytes
[38149] I/ali-ota: receive 4096 bytes, total recieve: 278528 bytes
[38281] I/ali-ota: receive 4096 bytes, total recieve: 282624 bytes
[38418] I/ali-ota: receive 4096 bytes, total recieve: 286720 bytes
[38547] I/ali-ota: receive 4096 bytes, total recieve: 290816 bytes
[38679] I/ali-ota: receive 4096 bytes, total recieve: 294912 bytes
[38811] I/ali-ota: receive 4096 bytes, total recieve: 299008 bytes
[38943] I/ali-ota: receive 4096 bytes, total recieve: 303104 bytes
[39075] I/ali-ota: receive 4096 bytes, total recieve: 307200 bytes
[39207] I/ali-ota: receive 4096 bytes, total recieve: 311296 bytes
[39339] I/ali-ota: receive 4096 bytes, total recieve: 315392 bytes
[39471] I/ali-ota: receive 4096 bytes, total recieve: 319488 bytes
[39603] I/ali-ota: receive 4096 bytes, total recieve: 323584 bytes
[39735] I/ali-ota: receive 4096 bytes, total recieve: 327680 bytes
[39867] I/ali-ota: receive 4096 bytes, total recieve: 331776 bytes
[39999] I/ali-ota: receive 4096 bytes, total recieve: 335872 bytes
[40131] I/ali-ota: receive 4096 bytes, total recieve: 339968 bytes
[40263] I/ali-ota: receive 4096 bytes, total recieve: 344064 bytes
[40392] I/ali-ota: receive 4096 bytes, total recieve: 348160 bytes
[40524] I/ali-ota: receive 4096 bytes, total recieve: 352256 bytes
[40656] I/ali-ota: receive 4096 bytes, total recieve: 356352 bytes
[40788] I/ali-ota: receive 4096 bytes, total recieve: 360448 bytes
[40920] I/ali-ota: receive 4096 bytes, total recieve: 364544 bytes
[41052] I/ali-ota: receive 4096 bytes, total recieve: 368640 bytes
[41184] I/ali-ota: receive 4096 bytes, total recieve: 372736 bytes
[41321] I/ali-ota: receive 4096 bytes, total recieve: 376832 bytes
[41453] I/ali-ota: receive 4096 bytes, total recieve: 380928 bytes
[41585] I/ali-ota: receive 4096 bytes, total recieve: 385024 bytes
[41717] I/ali-ota: receive 4096 bytes, total recieve: 389120 bytes
[41849] I/ali-ota: receive 4096 bytes, total recieve: 393216 bytes
[41981] I/ali-ota: receive 4096 bytes, total recieve: 397312 bytes
[42110] I/ali-ota: receive 4096 bytes, total recieve: 401408 bytes
[42242] I/ali-ota: receive 4096 bytes, total recieve: 405504 bytes
[42374] I/ali-ota: receive 4096 bytes, total recieve: 409600 bytes
[42619] I/ali-ota: receive 4096 bytes, total recieve: 413696 bytes
[42751] I/ali-ota: receive 4096 bytes, total recieve: 417792 bytes
[42883] I/ali-ota: receive 4096 bytes, total recieve: 421888 bytes
[43015] I/ali-ota: receive 4096 bytes, total recieve: 425984 bytes
[43147] I/ali-ota: receive 4096 bytes, total recieve: 430080 bytes
[43279] I/ali-ota: receive 4096 bytes, total recieve: 434176 bytes
[43411] I/ali-ota: receive 4096 bytes, total recieve: 438272 bytes
[43543] I/ali-ota: receive 4096 bytes, total recieve: 442368 bytes
[43675] I/ali-ota: receive 4096 bytes, total recieve: 446464 bytes
[43807] I/ali-ota: receive 4096 bytes, total recieve: 450560 bytes
[43939] I/ali-ota: receive 4096 bytes, total recieve: 454656 bytes
[44068] I/ali-ota: receive 4096 bytes, total recieve: 458752 bytes
[44200] I/ali-ota: receive 4096 bytes, total recieve: 462848 bytes
[44332] I/ali-ota: receive 4096 bytes, total recieve: 466944 bytes
[44464] I/ali-ota: receive 4096 bytes, total recieve: 471040 bytes
[44596] I/ali-ota: receive 4096 bytes, total recieve: 475136 bytes
[44728] I/ali-ota: receive 4096 bytes, total recieve: 479232 bytes
[44860] I/ali-ota: receive 4096 bytes, total recieve: 483328 bytes
[44992] I/ali-ota: receive 4096 bytes, total recieve: 487424 bytes
[45124] I/ali-ota: receive 4096 bytes, total recieve: 491520 bytes
[45256] I/ali-ota: receive 4096 bytes, total recieve: 495616 bytes
[45388] I/ali-ota: receive 4096 bytes, total recieve: 499712 bytes
[45520] I/ali-ota: receive 4096 bytes, total recieve: 503808 bytes
[45657] I/ali-ota: receive 4096 bytes, total recieve: 507904 bytes
[45786] I/ali-ota: receive 4096 bytes, total recieve: 512000 bytes
[45918] I/ali-ota: receive 4096 bytes, total recieve: 516096 bytes
[46050] I/ali-ota: receive 4096 bytes, total recieve: 520192 bytes
[46182] I/ali-ota: receive 4096 bytes, total recieve: 524288 bytes
[46314] I/ali-ota: receive 4096 bytes, total recieve: 528384 bytes
[46446] I/ali-ota: receive 4096 bytes, total recieve: 532480 bytes
[46578] I/ali-ota: receive 4096 bytes, total recieve: 536576 bytes
[46710] I/ali-ota: receive 4096 bytes, total recieve: 540672 bytes
[46842] I/ali-ota: receive 4096 bytes, total recieve: 544768 bytes
[46974] I/ali-ota: receive 4096 bytes, total recieve: 548864 bytes
[47106] I/ali-ota: receive 4096 bytes, total recieve: 552960 bytes
[47238] I/ali-ota: receive 4096 bytes, total recieve: 557056 bytes
[47370] I/ali-ota: receive 4096 bytes, total recieve: 561152 bytes
[47502] I/ali-ota: receive 4096 bytes, total recieve: 565248 bytes
[47631] I/ali-ota: receive 4096 bytes, total recieve: 569344 bytes
[47763] I/ali-ota: receive 4096 bytes, total recieve: 573440 bytes
[47895] I/ali-ota: receive 4096 bytes, total recieve: 577536 bytes
[48027] I/ali-ota: receive 4096 bytes, total recieve: 581632 bytes
[48159] I/ali-ota: receive 4096 bytes, total recieve: 585728 bytes
[48406] I/ali-ota: receive 4096 bytes, total recieve: 589824 bytes
[48543] I/ali-ota: receive 4096 bytes, total recieve: 593920 bytes
[48675] I/ali-ota: receive 4096 bytes, total recieve: 598016 bytes
[48807] I/ali-ota: receive 4096 bytes, total recieve: 602112 bytes
[48939] I/ali-ota: receive 4096 bytes, total recieve: 606208 bytes
[49071] I/ali-ota: receive 4096 bytes, total recieve: 610304 bytes
[49203] I/ali-ota: receive 4096 bytes, total recieve: 614400 bytes
[49335] I/ali-ota: receive 4096 bytes, total recieve: 618496 bytes
[49464] I/ali-ota: receive 4096 bytes, total recieve: 622592 bytes
[49596] I/ali-ota: receive 4096 bytes, total recieve: 626688 bytes
[49728] I/ali-ota: receive 4096 bytes, total recieve: 630784 bytes
[49860] I/ali-ota: receive 4096 bytes, total recieve: 634880 bytes
[49992] I/ali-ota: receive 4096 bytes, total recieve: 638976 bytes
[50124] I/ali-ota: receive 4096 bytes, total recieve: 643072 bytes
[50256] I/ali-ota: receive 4096 bytes, total recieve: 647168 bytes
[50388] I/ali-ota: receive 4096 bytes, total recieve: 651264 bytes
[50520] I/ali-ota: receive 4096 bytes, total recieve: 655360 bytes
[50652] I/ali-ota: receive 4096 bytes, total recieve: 659456 bytes
[50784] I/ali-ota: receive 4096 bytes, total recieve: 663552 bytes
[50916] I/ali-ota: receive 4096 bytes, total recieve: 667648 bytes
[51048] I/ali-ota: receive 4096 bytes, total recieve: 671744 bytes
[51180] I/ali-ota: receive 4096 bytes, total recieve: 675840 bytes
[51309] I/ali-ota: receive 4096 bytes, total recieve: 679936 bytes
[inf] _network_ssl_disconnect(520): ssl_disconnect
[51436] I/ali-ota: receive 2060 bytes, total recieve: 684032 bytes
[51543] D/ali-ota: The firmware is valid! Download firmware successfully.
[51550] D/ali-ota: OTA FW version: sw_1.1.0
[51554] D/ali-ota: OTA FW MD5 Sum: 2a336cd12b7b445344967fc3bc4970f3
[53003] I/ali-sdk: subscribe success, packet-id=18



以上就是大概步骤,还是比较简单粗暴的,后续就是需要测试这些修改有没有对SDK的稳定性造成影响。 在做这个改造前我在阿里平台提交了工单,询问如何实现这些功能,他们直接给我建议使用最新的SDK,说是稳定性比较好(的确是,我根据他们提供的提示我修改了reconnect的内存泄漏问题)。因此也下载了最新的V3.0.1版本SDK,使用KConfig进行代码提取。感觉整个脉络还是比较清晰,在RTT的移植基础上去做,基本不用怎么修改就可以使用。后续这个项目忙完我抽空移植下,感觉成功的把握比较大,如果哪位老兄已经做了就最好了:lol。










查看更多

2 个回答
Spunky
Spunky 2019-05-27
This guy hasn't written anything yet
论坛的代码粘贴比较让人发狂,粘贴上去都是乱码,没有找到窍门。
aozima
aozima 2019-05-28
拒绝白嫖,拒绝键盘侠!
加个code标签,至少不会乱码。

然后再把代码贴个附件就完美了。

撰写答案

请登录后再发布答案,点击登录
关注者
0
被浏览
886

发布
问题

分享
好友

手机
浏览

扫码手机浏览