一 概述
1.1 什么是 JSON
JSON是JavaScript Object Notation的簡稱,中文含義為“JavaScript 對象表示法”,它是一種數(shù)據(jù)交換的文本格式,而不是一種編程語言。
JSON 是一種輕量級的數(shù)據(jù)交換格式,它基于 ECMAScript (w3c制定的js規(guī)范)的一個子集,采用完全獨立于編程語言的文本格式來存儲和表示數(shù)據(jù)。簡潔和清晰的層次結(jié)構(gòu)使得 JSON 成為理想的數(shù)據(jù)交換語言。
JSON之所以受歡迎,主要是因為它仍然使用 JavaScript 語法來描述數(shù)據(jù)對象,并沒有改變開發(fā)人員的使用習(xí)慣,這更容易被開發(fā)人員接受。由于這種相似性,JavaScript 程序就無需解析器,便可以直接用 JSON 數(shù)據(jù)來生成原生的 JavaScript 對象。
1.2 JSON 的特點
JSON 主要具有以下特性,這些特性使它成為理想的數(shù)據(jù)交換語言:
JSON 是輕量級的文本數(shù)據(jù)交換格式
JSON 具有自我描述性,更易理解
JSON 采用完全獨立于語言的文本格式:JSON 使用 JavaScript 語法來描述數(shù)據(jù)對象,但是 JSON 仍然獨立于語言和平臺。JSON 解析器和 JSON 庫支持許多不同的編程語言。 目前常見的動態(tài)編程語言(PHP,JSP,.NET)都支持JSON。
JSON 是存儲和交換文本信息的一種語法,它與XML具有相同的特性,是一種數(shù)據(jù)存儲格式,卻比 XML 更小、更快、 更易于人編寫和閱讀、更易于生成和解析。
類似于 XML 的特性:
JSON 是純文本
JSON 具有“自我描述性”(人類可讀)
JSON 具有層級結(jié)構(gòu)(值中存在值)
JSON 可通過 JavaScript 進(jìn)行解析
JSON 數(shù)據(jù)可使用 AJAX 進(jìn)行傳輸
相比 XML 的不同之處:
沒有結(jié)束標(biāo)簽
更短
讀寫的速度更快
能夠使用內(nèi)建的 JavaScript eval() 方法進(jìn)行解析
使用數(shù)組
不使用保留字
二 JSON語法
在 JavaScript 語言中,一切皆對象。任何支持的類型,如字符串、數(shù)值、對象、數(shù)組等,都可以通過 JSON 來表示。
JSON 語法是 JavaScript 對象表示法的子集:
數(shù)據(jù)在鍵/值對中,鍵/值對可以嵌套
數(shù)據(jù)由逗號分隔
花括號保存對象,對象可以包含多個鍵/值對
方括號保存數(shù)組,數(shù)組可以包含多個對象
JSON不是JavaScript語句,對象的末尾沒有分號,對象和數(shù)組的最后一個成員后面,也不能加逗號。
2.1 JSON 鍵/值對
JSON鍵/值對由鍵和值組成,鍵必須是字符串,值可以是字符串(string)、數(shù)值(number) 、對象(object)、數(shù)組(array)、true、false、 null。如圖所示:
在定義JSON鍵/值時,先是鍵名,后面寫一個冒號,然后是值。如:
"github": "https://github.com/leiqikui"
這就等價于這條 JavaScript 語句:
github = "https://github.com/leiqikui"
2.2 JSON 字符串
JSON 的字符串(string)跟C或者Java的字符串非常相似,是由雙引號包圍的任意數(shù)量Unicode字符的集合,使用反斜線轉(zhuǎn)義。如圖所示:
由于JSON 字符串不能使用單引號,因此一個字符(character)就是一個單獨的字符串(character string)。
2.3 JSON 數(shù)值
JSON 數(shù)值(number)與C或者Java的數(shù)值非常相似,支持整型、浮點型,浮點型也可以用指數(shù)表示。如圖所示:
JSON不支持八進(jìn)制和十六進(jìn)制, 數(shù)值必須以十進(jìn)制表示,且不能使用NaN和Infinity。以下是合法的JSON數(shù)值:
{ "age": 30 }
2.4 JSON 對象
JSON 對象是一個無序的key/value對的集合。一個對象以 '{' 開始,以 '}' 結(jié)束;每個key 和 value 中使用冒號分隔;每個 key/value 對之間使用逗號分隔。如圖 14所示:
JSON 對象語法:
對象在大括號({})中書寫。
對象可以包含多個 key/value(鍵/值)對。
key是字符串,必須放在雙引號里面。value 可以是合法的 JSON 數(shù)據(jù)類型(字符串, 數(shù)值, 對象, 數(shù)組, 布爾值或 null)。
一個 key/value 對內(nèi)部,key 和 value使用冒號(:)分隔。
key/value 對之間,使用逗號(,)分隔。
對象可以嵌套
2.5 JSON 數(shù)組
數(shù)組是值(value)的有序集合。一個數(shù)組以“[”(左中括號)開始,“]”(右中括號)結(jié)束。值之間使用“,”(逗號)分隔。如圖 15所示:
JSON 數(shù)組:
數(shù)組在中括號中書寫。
數(shù)組的值必須是合法的 JSON 數(shù)據(jù)類型(字符串, 數(shù)值, 對象, 數(shù)組, 布爾值或 null),也可以是 JavaScript 的表達(dá)式,包括函數(shù)、日期、undefined。
2.6 JSON 布爾值
JSON 布爾值可以是 true 或者 false。如:
{ "flag":true }
2.7 JSON null
JSON 可以設(shè)置 null 值。如:
{ "zhihu":null }
2.8 JSON 文件
JSON 文件的文件類型是 ".json"
JSON 文本的 MIME 類型是 "application/json"
三 JSON協(xié)議組件的使用
1 Gitee鏈接地址
組件位于amaziot_bloom_os_sdklibrariesamxtuam_json.c
Gitee源碼地址:https://gitee.com/ning./hongdou
Github源碼地址:https://github.com/ayumid/hongdou
2 應(yīng)用層組件功能介紹
提供JSON協(xié)議和服務(wù)器通信連接實例。
使用該組件,必須同時使用AT組件,文件組件,TCP組件,掉線組件,掉線重連組件,DI組件,DO組件,AI組件,JSON組件,CLK組件。
3 代碼講解
1 dtu_json_task_send_msgq
發(fā)送消息給模塊主任務(wù),錯誤后串口輸出信息
/** * Function : dtu_json_task_send_msgq * Description : 發(fā)送消息給模塊主任務(wù),錯誤后串口輸出信息 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ int dtu_json_task_send_msgq(DTU_JSON_MSG_T * msg) { int ret = 0; //發(fā)送消息給json主任務(wù) OSA_STATUS status = OSAMsgQSend(dtu_json_msgq, DTU_JSON_TASK_MSGQ_MSG_SIZE, (void*)msg, OSA_NO_SUSPEND); if (status != OS_SUCCESS) { printf("%s, OSAMsgQSend lose, msg->id=%d, status=%d", __FUNCTION__, msg->msgId, status); ret = -1; } return ret; }
2 dtu_sys_json_get_sys_config
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_sys_json_get_sys_config * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_sys_json_get_sys_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID為獲取配置回復(fù) p_smsg.msgId = DTU_SYS_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
3 dtu_sys_json_get_sys_config_res
回復(fù)服務(wù)器獲取sys配置
/** * Function : dtu_sys_json_get_sys_config_res * Description : 回復(fù)服務(wù)器獲取sys配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_sys_json_get_sys_config_res(void) { cJSON *gdocr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gdocr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "enHb", cJSON_CreateNumber(dtu_file_ctx->hb.heartflag)); cJSON_AddItemToObject(data, "cycHb", cJSON_CreateNumber(dtu_file_ctx->hb.hearttime)); cJSON_AddItemToObject(data, "hbPkg", cJSON_CreateString(dtu_file_ctx->hb.heart)); cJSON_AddItemToObject(data, "enReg", cJSON_CreateNumber(dtu_file_ctx->reg.linkflag)); cJSON_AddItemToObject(data, "regpkg", cJSON_CreateString(dtu_file_ctx->reg.link)); cJSON_AddItemToObject(gdocr, "msgType", cJSON_CreateString("getSysConfigRes")); cJSON_AddItemToObject(gdocr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdocr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdocr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdocr); }
4 dtu_sys_json_set_sys_config
設(shè)置sys配置
/** * Function : dtu_sys_json_set_sys_config * Description : 設(shè)置sys配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_sys_json_set_sys_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; DTU_TIME_PARAM_T* dtu_timer_ctx = NULL; cJSON * gdocg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); dtu_timer_ctx = dtu_get_timer_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_SYS_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gdocg = cJSON_Parse(rcvdata); if(NULL != gdocg) { data = cJSON_GetObjectItem(gdocg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "enHb"); dtu_file_ctx->hb.heartflag = item->valueint; item = cJSON_GetObjectItem(data, "cycHb"); dtu_file_ctx->hb.hearttime = item->valueint; item = cJSON_GetObjectItem(data, "hbPkg"); memset(dtu_file_ctx->hb.heart, 0, sizeof(dtu_file_ctx->hb.heart)); memcpy(dtu_file_ctx->hb.heart, item->valuestring, strlen(item->valuestring)); item = cJSON_GetObjectItem(data, "enReg"); dtu_file_ctx->reg.linkflag = item->valueint; item = cJSON_GetObjectItem(data, "regpkg"); memset(dtu_file_ctx->reg.link, 0, sizeof(dtu_file_ctx->reg.link)); memcpy(dtu_file_ctx->reg.link, item->valuestring, strlen(item->valuestring)); if(1 == dtu_file_ctx->hb.heartflag) { //開始心跳定時器 OSATimerStart(dtu_timer_ctx->dtu_timer_ref, dtu_file_ctx->hb.hearttime * 200, dtu_file_ctx->hb.hearttime * 200 , dtu_hb_timer_callback, 0); } else if(0 == dtu_file_ctx->hb.heartflag) { //關(guān)閉心跳定時器 OSATimerStop(dtu_timer_ctx->dtu_timer_ref); } //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("enHb: %d, cycHb: %d, hbPkg: %s, enReg: %d, regpkg: %srn", dtu_file_ctx->hb.heartflag, dtu_file_ctx->hb.hearttime, dtu_file_ctx->hb.heart, dtu_file_ctx->reg.linkflag, dtu_file_ctx->reg.link); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
5 dtu_sys_json_set_sys_config_res
回復(fù)服務(wù)器設(shè)置sys
/** * Function : dtu_sys_json_set_sys_config_res * Description : 回復(fù)服務(wù)器設(shè)置sys * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_sys_json_set_sys_config_res(UINT8 res) { cJSON *gdocr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdocr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gdocr, "msgType", cJSON_CreateString("setSysConfigRes")); cJSON_AddItemToObject(gdocr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdocr))); if(NULL != gdocr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdocr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdocr); }
6 dtu_net_json_get_net_config
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_net_json_get_net_config * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_net_json_get_net_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_NET_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
7 dtu_net_json_get_net_config_res
回復(fù)服務(wù)器獲net配置
/** * Function : dtu_net_json_get_net_config_res * Description : 回復(fù)服務(wù)器獲net配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_net_json_get_net_config_res(void) { cJSON *gdocr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gdocr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "IP", cJSON_CreateString(dtu_file_ctx->socket.ip)); cJSON_AddItemToObject(data, "port", cJSON_CreateNumber(dtu_file_ctx->socket.port)); cJSON_AddItemToObject(data, "type", cJSON_CreateNumber(dtu_file_ctx->socket.type)); cJSON_AddItemToObject(gdocr, "msgType", cJSON_CreateString("getNetConfigRes")); cJSON_AddItemToObject(gdocr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdocr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdocr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdocr); }
8 dtu_net_json_set_net_config
設(shè)置網(wǎng)絡(luò)配置
/** * Function : dtu_net_json_set_net_config * Description : 設(shè)置網(wǎng)絡(luò)配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_net_json_set_net_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gdocg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_NET_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gdocg = cJSON_Parse(rcvdata); if(NULL != gdocg) { data = cJSON_GetObjectItem(gdocg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "IP"); memset(dtu_file_ctx->socket.ip, 0, sizeof(dtu_file_ctx->socket.ip)); memcpy(dtu_file_ctx->socket.ip, item->valuestring, strlen(item->valuestring)); item = cJSON_GetObjectItem(data, "port"); dtu_file_ctx->socket.port = item->valueint; item = cJSON_GetObjectItem(data, "type"); dtu_file_ctx->socket.type = item->valueint; //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("IP %s, port %d, type %d", dtu_file_ctx->socket.ip, dtu_file_ctx->socket.port, dtu_file_ctx->socket.type); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
9 dtu_net_json_set_net_config
設(shè)置網(wǎng)絡(luò)配置
/** * Function : dtu_net_json_set_net_config * Description : 設(shè)置網(wǎng)絡(luò)配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_net_json_set_net_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gdocg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_NET_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gdocg = cJSON_Parse(rcvdata); if(NULL != gdocg) { data = cJSON_GetObjectItem(gdocg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "IP"); memset(dtu_file_ctx->socket.ip, 0, sizeof(dtu_file_ctx->socket.ip)); memcpy(dtu_file_ctx->socket.ip, item->valuestring, strlen(item->valuestring)); item = cJSON_GetObjectItem(data, "port"); dtu_file_ctx->socket.port = item->valueint; item = cJSON_GetObjectItem(data, "type"); dtu_file_ctx->socket.type = item->valueint; //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("IP %s, port %d, type %d", dtu_file_ctx->socket.ip, dtu_file_ctx->socket.port, dtu_file_ctx->socket.type); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
10 dtu_net_json_set_net_config_res
回復(fù)服務(wù)器設(shè)置net
/** * Function : dtu_net_json_set_net_config_res * Description : 回復(fù)服務(wù)器設(shè)置net * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_net_json_set_net_config_res(UINT8 res) { cJSON *gdocr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdocr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gdocr, "msgType", cJSON_CreateString("setNetConfigRes")); cJSON_AddItemToObject(gdocr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdocr))); if(NULL != gdocr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdocr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdocr); }
11 dtu_di_json_get_di_value
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_di_json_get_di_value * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_di_json_get_di_value(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_DI_MSG_ID_GET_VALUE_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
12 dtu_di_json_get_di_value_res
回復(fù)服務(wù)器獲取di值
/** * Function : dtu_di_json_get_di_value_res * Description : 回復(fù)服務(wù)器獲取di值 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_di_json_get_di_value_res(void) { cJSON *gdivr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdivr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "DI1", cJSON_CreateNumber(dtu_di_read_pin_1())); cJSON_AddItemToObject(data, "DI2", cJSON_CreateNumber(dtu_di_read_pin_2())); cJSON_AddItemToObject(data, "DI3", cJSON_CreateNumber(dtu_di_read_pin_3())); cJSON_AddItemToObject(data, "DI4", cJSON_CreateNumber(dtu_di_read_pin_4())); cJSON_AddItemToObject(data, "DI5", cJSON_CreateNumber(dtu_di_read_pin_5())); cJSON_AddItemToObject(gdivr, "msgType", cJSON_CreateString("getDiValueRes")); cJSON_AddItemToObject(gdivr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdivr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdivr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdivr); }
13 dtu_di_json_get_di_config
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_di_json_get_di_config * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_di_json_get_di_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_DI_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
14 dtu_di_json_get_di_config_res
回復(fù)服務(wù)器獲取di配置
/** * Function : dtu_di_json_get_di_config_res * Description : 回復(fù)服務(wù)器獲取di配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_di_json_get_di_config_res(void) { cJSON *gdicr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gdicr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "enRpt1", cJSON_CreateNumber(dtu_file_ctx->di.di1.di_type)); cJSON_AddItemToObject(data, "cyc1", cJSON_CreateNumber(dtu_file_ctx->di.di1.di_interval)); cJSON_AddItemToObject(data, "edge1", cJSON_CreateNumber(dtu_file_ctx->di.di1.di_edge)); cJSON_AddItemToObject(data, "enRpt2", cJSON_CreateNumber(dtu_file_ctx->di.di2.di_type)); cJSON_AddItemToObject(data, "cyc2", cJSON_CreateNumber(dtu_file_ctx->di.di2.di_interval)); cJSON_AddItemToObject(data, "edge2", cJSON_CreateNumber(dtu_file_ctx->di.di2.di_edge)); cJSON_AddItemToObject(data, "enRpt3", cJSON_CreateNumber(dtu_file_ctx->di.di3.di_type)); cJSON_AddItemToObject(data, "cyc3", cJSON_CreateNumber(dtu_file_ctx->di.di3.di_interval)); cJSON_AddItemToObject(data, "edge3", cJSON_CreateNumber(dtu_file_ctx->di.di3.di_edge)); cJSON_AddItemToObject(data, "enRpt4", cJSON_CreateNumber(dtu_file_ctx->di.di4.di_type)); cJSON_AddItemToObject(data, "cyc4", cJSON_CreateNumber(dtu_file_ctx->di.di4.di_interval)); cJSON_AddItemToObject(data, "edge4", cJSON_CreateNumber(dtu_file_ctx->di.di4.di_edge)); cJSON_AddItemToObject(data, "enRpt5", cJSON_CreateNumber(dtu_file_ctx->di.di5.di_type)); cJSON_AddItemToObject(data, "cyc5", cJSON_CreateNumber(dtu_file_ctx->di.di5.di_interval)); cJSON_AddItemToObject(data, "edge5", cJSON_CreateNumber(dtu_file_ctx->di.di5.di_edge)); cJSON_AddItemToObject(gdicr, "msgType", cJSON_CreateString("getDiConfigRes")); cJSON_AddItemToObject(gdicr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdicr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdicr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdicr); }
15 dtu_di_json_set_di_config
設(shè)置di配置
/** * Function : dtu_di_json_set_di_config * Description : 設(shè)置di配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_di_json_set_di_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gdicg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_DI_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gdicg = cJSON_Parse(rcvdata); if(NULL != gdicg) { data = cJSON_GetObjectItem(gdicg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "enRpt1"); dtu_file_ctx->di.di1.di_type = item->valueint; item = cJSON_GetObjectItem(data, "cyc1"); dtu_file_ctx->di.di1.di_interval = item->valueint; item = cJSON_GetObjectItem(data, "defaultLv1"); dtu_file_ctx->di.di1.di_edge = item->valueint; item = cJSON_GetObjectItem(data, "enRpt2"); dtu_file_ctx->di.di2.di_type = item->valueint; item = cJSON_GetObjectItem(data, "cyc2"); dtu_file_ctx->di.di2.di_interval = item->valueint; item = cJSON_GetObjectItem(data, "defaultLv2"); dtu_file_ctx->di.di2.di_edge = item->valueint; item = cJSON_GetObjectItem(data, "enRpt3"); dtu_file_ctx->di.di3.di_type = item->valueint; item = cJSON_GetObjectItem(data, "cyc3"); dtu_file_ctx->di.di3.di_interval = item->valueint; item = cJSON_GetObjectItem(data, "defaultLv3"); dtu_file_ctx->di.di3.di_edge = item->valueint; item = cJSON_GetObjectItem(data, "enRpt4"); dtu_file_ctx->di.di4.di_type = item->valueint; item = cJSON_GetObjectItem(data, "cyc4"); dtu_file_ctx->di.di4.di_interval = item->valueint; item = cJSON_GetObjectItem(data, "defaultLv4"); dtu_file_ctx->di.di4.di_edge = item->valueint; item = cJSON_GetObjectItem(data, "enRpt5"); dtu_file_ctx->di.di5.di_type = item->valueint; item = cJSON_GetObjectItem(data, "cyc5"); dtu_file_ctx->di.di5.di_interval = item->valueint; item = cJSON_GetObjectItem(data, "defaultLv5"); dtu_file_ctx->di.di5.di_edge = item->valueint; if(DTU_DI_REPORT_INITIATIVE == dtu_file_ctx->di.di1.di_type) { //開定時器 dtu_di1_report_timer_start(dtu_file_ctx->di.di1.di_interval); } else if(DTU_DI_REPORT_NONE == dtu_file_ctx->di.di1.di_type) { dtu_di1_report_timer_stop(); } if(DTU_DI_REPORT_INITIATIVE == dtu_file_ctx->di.di2.di_type) { //開定時器 dtu_di2_report_timer_start(dtu_file_ctx->di.di2.di_interval); } else if(DTU_DI_REPORT_NONE == dtu_file_ctx->di.di2.di_type) { dtu_di2_report_timer_stop(); } if(DTU_DI_REPORT_INITIATIVE == dtu_file_ctx->di.di3.di_type) { //開定時器 dtu_di3_report_timer_start(dtu_file_ctx->di.di3.di_interval); } else if(DTU_DI_REPORT_NONE == dtu_file_ctx->di.di3.di_type) { dtu_di3_report_timer_stop(); } if(DTU_DI_REPORT_INITIATIVE == dtu_file_ctx->di.di4.di_type) { //開定時器 dtu_di4_report_timer_start(dtu_file_ctx->di.di4.di_interval); } else if(DTU_DI_REPORT_NONE == dtu_file_ctx->di.di4.di_type) { dtu_di4_report_timer_stop(); } if(DTU_DI_REPORT_INITIATIVE == dtu_file_ctx->di.di5.di_type) { //開定時器 dtu_di5_report_timer_start(dtu_file_ctx->di.di5.di_interval); } else if(DTU_DI_REPORT_NONE == dtu_file_ctx->di.di5.di_type) { dtu_di5_report_timer_stop(); } //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("DI1:type %d, interval %d, pull %drn" "DI2:type %d, interval %d, pull %drn" "DI3:type %d, interval %d, pull %drn" "DI4:type %d, interval %d, pull %drn" "DI5:type %d, interval %d, pull %drn", dtu_file_ctx->di.di1.di_type, dtu_file_ctx->di.di1.di_interval, dtu_file_ctx->di.di1.di_edge, dtu_file_ctx->di.di2.di_type, dtu_file_ctx->di.di2.di_interval, dtu_file_ctx->di.di2.di_edge, dtu_file_ctx->di.di3.di_type, dtu_file_ctx->di.di3.di_interval, dtu_file_ctx->di.di3.di_edge, dtu_file_ctx->di.di4.di_type, dtu_file_ctx->di.di4.di_interval, dtu_file_ctx->di.di4.di_edge, dtu_file_ctx->di.di5.di_type, dtu_file_ctx->di.di5.di_interval, dtu_file_ctx->di.di5.di_edge); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
16 dtu_di_set_di_value_res
回復(fù)服務(wù)器設(shè)置di值
/** * Function : dtu_di_set_di_value_res * Description : 回復(fù)服務(wù)器設(shè)置di值 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_di_json_set_di_config_res(UINT8 res) { cJSON *gdivr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdivr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gdivr, "msgType", cJSON_CreateString("setDiConfigRes")); cJSON_AddItemToObject(gdivr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdivr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdivr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdivr); }
17 dtu_di_json_res
DI主動上報
/** * Function : dtu_di_json_res * Description : DI主動上報 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_di_json_res(UINT8 type, UINT8 channel, UINT8 level) { cJSON *gdivr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdivr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 if(DTU_GPIO_CHNNEL_1 == channel) { cJSON_AddItemToObject(data, "DI1", cJSON_CreateNumber(level)); } else if(DTU_GPIO_CHNNEL_2 == channel) { cJSON_AddItemToObject(data, "DI2", cJSON_CreateNumber(level)); } else if(DTU_GPIO_CHNNEL_3 == channel) { cJSON_AddItemToObject(data, "DI3", cJSON_CreateNumber(level)); } else if(DTU_GPIO_CHNNEL_4 == channel) { cJSON_AddItemToObject(data, "DI4", cJSON_CreateNumber(level)); } else if(DTU_GPIO_CHNNEL_5 == channel) { cJSON_AddItemToObject(data, "DI5", cJSON_CreateNumber(level)); } if(DTU_DI_REPORT_INTER == type) { cJSON_AddItemToObject(gdivr, "msgType", cJSON_CreateString("diValueRpt")); } else if(DTU_DI_REPORT_TRIG == type) { cJSON_AddItemToObject(gdivr, "msgType", cJSON_CreateString("diValueRptTrig")); } cJSON_AddItemToObject(gdivr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdivr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdivr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdivr); }
18 dtu_do_json_get_do_value
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_do_json_get_do_value * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_do_json_get_do_value(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_DO_MSG_ID_GET_VALUE_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
19 dtu_do_json_get_do_value_res
回復(fù)服務(wù)器獲取di值
/** * Function : dtu_do_json_get_do_value_res * Description : 回復(fù)服務(wù)器獲取di值 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_do_json_get_do_value_res(void) { cJSON *gdovr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdovr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "DO1", cJSON_CreateNumber(dtu_do_read_pin(DTU_GPIO_DO_PIN1))); cJSON_AddItemToObject(data, "DO2", cJSON_CreateNumber(dtu_do_read_pin(DTU_GPIO_DO_PIN2))); cJSON_AddItemToObject(data, "DO3", cJSON_CreateNumber(dtu_do_read_pin(DTU_GPIO_DO_PIN3))); cJSON_AddItemToObject(data, "DO4", cJSON_CreateNumber(dtu_do_read_pin(DTU_GPIO_DO_PIN4))); cJSON_AddItemToObject(data, "DO5", cJSON_CreateNumber(dtu_do_read_pin(DTU_GPIO_DO_PIN5))); cJSON_AddItemToObject(gdovr, "msgType", cJSON_CreateString("getDoValueRes")); cJSON_AddItemToObject(gdovr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdovr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdovr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdovr); }
20 dtu_do_json_set_do_value
設(shè)置di配置
/** * Function : dtu_do_json_set_do_value * Description : 設(shè)置di配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_do_json_set_do_value(int len , char *rcvdata) { UINT8 res = 0; UINT8 do1 = 0; UINT8 do2 = 0; UINT8 do3 = 0; UINT8 do4 = 0; UINT8 do5 = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gdov = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_DO_MSG_ID_SET_VALUE_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gdov = cJSON_Parse(rcvdata); if(NULL != gdov) { data = cJSON_GetObjectItem(gdov, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "DO1"); dtu_do_write_pin("DO1", item->valueint); item = cJSON_GetObjectItem(data, "DO2"); dtu_do_write_pin("DO2", item->valueint); item = cJSON_GetObjectItem(data, "DO3"); dtu_do_write_pin("DO3", item->valueint); item = cJSON_GetObjectItem(data, "DO4"); dtu_do_write_pin("DO4", item->valueint); do1 = GpioGetLevel(DTU_GPIO_DO_PIN1); do2 = GpioGetLevel(DTU_GPIO_DO_PIN2); do3 = GpioGetLevel(DTU_GPIO_DO_PIN3); do4 = GpioGetLevel(DTU_GPIO_DO_PIN4); do5 = GpioGetLevel(DTU_GPIO_DO_PIN5); //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("DO1:%d, DO2:%d, DO3:%d, DO4:%d, DO5:%d", do1, do2, do3, do4, do5); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
21 dtu_do_json_set_do_value_res
回復(fù)服務(wù)器設(shè)置di值
/** * Function : dtu_do_json_set_do_value_res * Description : 回復(fù)服務(wù)器設(shè)置di值 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_do_json_set_do_value_res(UINT8 res) { cJSON *gdovr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdovr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gdovr, "msgType", cJSON_CreateString("setDoValueRes")); cJSON_AddItemToObject(gdovr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdovr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdovr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdovr); }
22 dtu_do_json_get_do_config
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_do_json_get_do_config * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_do_json_get_do_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_DO_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
23 dtu_do_json_get_do_config_res
回復(fù)服務(wù)器獲取di配置
/** * Function : dtu_do_json_get_do_config_res * Description : 回復(fù)服務(wù)器獲取di配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_do_json_get_do_config_res(void) { cJSON *gdocr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gdocr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "enRpt1", cJSON_CreateNumber(dtu_file_ctx->doo.do1.do_type)); cJSON_AddItemToObject(data, "enRpt2", cJSON_CreateNumber(dtu_file_ctx->doo.do2.do_type)); cJSON_AddItemToObject(data, "enRpt3", cJSON_CreateNumber(dtu_file_ctx->doo.do3.do_type)); cJSON_AddItemToObject(data, "enRpt4", cJSON_CreateNumber(dtu_file_ctx->doo.do4.do_type)); cJSON_AddItemToObject(data, "enRpt5", cJSON_CreateNumber(dtu_file_ctx->doo.do5.do_type)); cJSON_AddItemToObject(data, "rptInterval1", cJSON_CreateNumber(dtu_file_ctx->doo.do1.do_interval)); cJSON_AddItemToObject(data, "rptInterval2", cJSON_CreateNumber(dtu_file_ctx->doo.do2.do_interval)); cJSON_AddItemToObject(data, "rptInterval3", cJSON_CreateNumber(dtu_file_ctx->doo.do3.do_interval)); cJSON_AddItemToObject(data, "rptInterval4", cJSON_CreateNumber(dtu_file_ctx->doo.do4.do_interval)); cJSON_AddItemToObject(data, "rptInterval5", cJSON_CreateNumber(dtu_file_ctx->doo.do5.do_interval)); cJSON_AddItemToObject(data, "rstStatus1", cJSON_CreateNumber(dtu_file_ctx->doo.do1.do_status)); cJSON_AddItemToObject(data, "rstStatus2", cJSON_CreateNumber(dtu_file_ctx->doo.do2.do_status)); cJSON_AddItemToObject(data, "rstStatus3", cJSON_CreateNumber(dtu_file_ctx->doo.do3.do_status)); cJSON_AddItemToObject(data, "rstStatus4", cJSON_CreateNumber(dtu_file_ctx->doo.do4.do_status)); cJSON_AddItemToObject(data, "rstStatus5", cJSON_CreateNumber(dtu_file_ctx->doo.do5.do_status)); // cJSON_AddItemToObject(data, "holdTime1", cJSON_CreateNumber(dtu_file_ctx->doo.do1.do_time)); // cJSON_AddItemToObject(data, "holdTime2", cJSON_CreateNumber(dtu_file_ctx->doo.do2.do_time)); // cJSON_AddItemToObject(data, "holdTime3", cJSON_CreateNumber(dtu_file_ctx->doo.do3.do_time)); // cJSON_AddItemToObject(data, "holdTime4", cJSON_CreateNumber(dtu_file_ctx->doo.do4.do_time)); // cJSON_AddItemToObject(data, "holdTime5", cJSON_CreateNumber(dtu_file_ctx->doo.do5.do_time)); // cJSON_AddItemToObject(data, "turnTime1", cJSON_CreateNumber(dtu_file_ctx->doo.do1.do_flip)); // cJSON_AddItemToObject(data, "turnTime2", cJSON_CreateNumber(dtu_file_ctx->doo.do2.do_flip)); // cJSON_AddItemToObject(data, "turnTime3", cJSON_CreateNumber(dtu_file_ctx->doo.do3.do_flip)); // cJSON_AddItemToObject(data, "turnTime4", cJSON_CreateNumber(dtu_file_ctx->doo.do4.do_flip)); // cJSON_AddItemToObject(data, "turnTime5", cJSON_CreateNumber(dtu_file_ctx->doo.do5.do_flip)); cJSON_AddItemToObject(gdocr, "msgType", cJSON_CreateString("getDoConfigRes")); cJSON_AddItemToObject(gdocr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdocr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdocr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdocr); }
24 dtu_do_json_set_do_config
設(shè)置do配置
/** * Function : dtu_do_json_set_do_config * Description : 設(shè)置do配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_do_json_set_do_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gdocg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_DO_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gdocg = cJSON_Parse(rcvdata); if(NULL != gdocg) { data = cJSON_GetObjectItem(gdocg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "enRpt1"); dtu_file_ctx->doo.do1.do_type = item->valueint; item = cJSON_GetObjectItem(data, "rptInterval1"); dtu_file_ctx->doo.do1.do_interval = item->valueint; item = cJSON_GetObjectItem(data, "rstStatus1"); dtu_file_ctx->doo.do1.do_status = item->valueint; // item = cJSON_GetObjectItem(data, "holdTime1"); // dtu_file_ctx->doo.do1.do_time = item->valueint; // item = cJSON_GetObjectItem(data, "turnTime1"); // dtu_file_ctx->doo.do1.do_flip = item->valueint; item = cJSON_GetObjectItem(data, "enRpt2"); dtu_file_ctx->doo.do2.do_type = item->valueint; item = cJSON_GetObjectItem(data, "rptInterval2"); dtu_file_ctx->doo.do2.do_interval = item->valueint; item = cJSON_GetObjectItem(data, "rstStatus2"); dtu_file_ctx->doo.do2.do_status = item->valueint; // item = cJSON_GetObjectItem(data, "holdTime2"); // dtu_file_ctx->doo.do2.do_time = item->valueint; // item = cJSON_GetObjectItem(data, "turnTime2"); // dtu_file_ctx->doo.do2.do_flip = item->valueint; item = cJSON_GetObjectItem(data, "enRpt3"); dtu_file_ctx->doo.do3.do_type = item->valueint; item = cJSON_GetObjectItem(data, "rptInterval3"); dtu_file_ctx->doo.do3.do_interval = item->valueint; item = cJSON_GetObjectItem(data, "rstStatus3"); dtu_file_ctx->doo.do3.do_status = item->valueint; // item = cJSON_GetObjectItem(data, "holdTime3"); // dtu_file_ctx->doo.do3.do_time = item->valueint; // item = cJSON_GetObjectItem(data, "turnTime3"); // dtu_file_ctx->doo.do3.do_flip = item->valueint; item = cJSON_GetObjectItem(data, "enRpt4"); dtu_file_ctx->doo.do4.do_type = item->valueint; item = cJSON_GetObjectItem(data, "rptInterval4"); dtu_file_ctx->doo.do4.do_interval = item->valueint; item = cJSON_GetObjectItem(data, "rstStatus4"); dtu_file_ctx->doo.do4.do_status = item->valueint; // item = cJSON_GetObjectItem(data, "holdTime4"); // dtu_file_ctx->doo.do4.do_time = item->valueint; // item = cJSON_GetObjectItem(data, "turnTime4"); // dtu_file_ctx->doo.do4.do_flip = item->valueint; item = cJSON_GetObjectItem(data, "enRpt5"); dtu_file_ctx->doo.do5.do_type = item->valueint; item = cJSON_GetObjectItem(data, "rptInterval5"); dtu_file_ctx->doo.do5.do_interval = item->valueint; item = cJSON_GetObjectItem(data, "rstStatus5"); dtu_file_ctx->doo.do5.do_status = item->valueint; // item = cJSON_GetObjectItem(data, "holdTime5"); // dtu_file_ctx->doo.do5.do_time = item->valueint; // item = cJSON_GetObjectItem(data, "turnTime5"); // dtu_file_ctx->doo.do5.do_flip = item->valueint; if(DTU_DO_REPORT_INITIATIVE == dtu_file_ctx->doo.do1.do_type) { //開定時器 dtu_do1_report_timer_start(dtu_file_ctx->doo.do1.do_interval); } else if(DTU_DO_REPORT_NONE == dtu_file_ctx->doo.do1.do_type) { //關(guān)閉定時器 dtu_do1_report_timer_stop(); } if(DTU_DO_REPORT_INITIATIVE == dtu_file_ctx->doo.do2.do_type) { //開定時器 dtu_do2_report_timer_start(dtu_file_ctx->doo.do2.do_interval); } else if(DTU_DO_REPORT_NONE == dtu_file_ctx->doo.do2.do_type) { //關(guān)閉定時器 dtu_do2_report_timer_stop(); } if(DTU_DO_REPORT_INITIATIVE == dtu_file_ctx->doo.do3.do_type) { //開定時器 dtu_do3_report_timer_start(dtu_file_ctx->doo.do3.do_interval); } else if(DTU_DO_REPORT_NONE == dtu_file_ctx->doo.do3.do_type) { //關(guān)閉定時器 dtu_do3_report_timer_stop(); } if(DTU_DO_REPORT_INITIATIVE == dtu_file_ctx->doo.do4.do_type) { //開定時器 dtu_do4_report_timer_start(dtu_file_ctx->doo.do4.do_interval); } else if(DTU_DO_REPORT_NONE == dtu_file_ctx->doo.do4.do_type) { //關(guān)閉定時器 dtu_do4_report_timer_stop(); } if(DTU_DO_REPORT_INITIATIVE == dtu_file_ctx->doo.do5.do_type) { //開定時器 dtu_do5_report_timer_start(dtu_file_ctx->doo.do5.do_interval); } else if(DTU_DO_REPORT_NONE == dtu_file_ctx->doo.do5.do_type) { //關(guān)閉定時器 dtu_do5_report_timer_stop(); } //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("DO1:type %d, interval %d, status %drn" "DO2:type %d, interval %d, status %drn" "DO3:type %d, interval %d, status %drn" "DO4:type %d, interval %d, status %drn" "DO5:type %d, interval %d, status %drn", dtu_file_ctx->doo.do1.do_type, dtu_file_ctx->doo.do1.do_interval, dtu_file_ctx->doo.do1.do_status, // dtu_file_ctx->doo.do1.do_time, // dtu_file_ctx->doo.do1.do_flip, dtu_file_ctx->doo.do2.do_type, dtu_file_ctx->doo.do2.do_interval, dtu_file_ctx->doo.do2.do_status, // dtu_file_ctx->doo.do2.do_time, // dtu_file_ctx->doo.do2.do_flip, dtu_file_ctx->doo.do3.do_type, dtu_file_ctx->doo.do3.do_interval, dtu_file_ctx->doo.do3.do_status, // dtu_file_ctx->doo.do3.do_time, // dtu_file_ctx->doo.do3.do_flip, dtu_file_ctx->doo.do4.do_type, dtu_file_ctx->doo.do4.do_interval, dtu_file_ctx->doo.do4.do_status, // dtu_file_ctx->doo.do4.do_time, // dtu_file_ctx->doo.do4.do_flip, dtu_file_ctx->doo.do5.do_type, dtu_file_ctx->doo.do5.do_interval, dtu_file_ctx->doo.do5.do_status); // dtu_file_ctx->doo.do5.do_time, // dtu_file_ctx->doo.do5.do_flip); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
25 dtu_do_json_set_do_config_res
回復(fù)服務(wù)器設(shè)置do
/** * Function : dtu_do_json_set_do_config_res * Description : 回復(fù)服務(wù)器設(shè)置do * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_do_json_set_do_config_res(UINT8 res) { cJSON *gdocr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gdocr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gdocr, "msgType", cJSON_CreateString("setDoConfigRes")); cJSON_AddItemToObject(gdocr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gdocr))); if(NULL != gdocr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gdocr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gdocr); }
26 dtu_do_json_res
DO主動上報
/** * Function : dtu_do_json_res * Description : DO主動上報 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_ai_json_res(void) { cJSON *gaivr = NULL; cJSON *data = NULL; char* send = NULL; UINT16 ai_v = 0; float ai_i = 0.0; char ai_str[10] = {0}; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gaivr = cJSON_CreateObject(); data = cJSON_CreateObject(); //獲取adc值 ai_v = dtu_ai_read(); ai_i = (float)ai_v / DTU_AI_RES_VAL; sprintf(ai_str, "%.02f", ai_i); //根據(jù)模式?jīng)Q定是否上報 do { //排除不用上報的情況 if(DTU_AI_REPORT_TRIGGER == dtu_file_ctx->ai.ai_type) { // printf("AI Trigger rpt"); //在閾值外上報,當(dāng)電流位于閾值內(nèi),跳出 if(DTU_AI_REPORT_OUT == dtu_file_ctx->ai.ai_res_rule) { // printf("AI rpt out"); if(ai_i <= dtu_file_ctx-?>ai.ai_alarm_high && ai_i >= dtu_file_ctx->ai.ai_alarm_low) { // printf("AI rpt out break"); break; } } //在閾值內(nèi)上報,當(dāng)電流位于閾值外,跳出 else if(DTU_AI_REPORT_IN == dtu_file_ctx->ai.ai_res_rule) { // printf("AI rpt in"); if(ai_i > dtu_file_ctx->ai.ai_alarm_high || ai_i < dtu_file_ctx-?>ai.ai_alarm_low) { // printf("AI rpt in break"); break; } } } //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "AI1", cJSON_CreateString(ai_str)); cJSON_AddItemToObject(gaivr, "msgType", cJSON_CreateString("aiValueRpt")); cJSON_AddItemToObject(gaivr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gaivr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gaivr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } }while(0); //刪除json對象 cJSON_Delete(gaivr); }
dtu_ai_json_get_ai_value
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_ai_json_get_ai_value * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_ai_json_get_ai_value(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_AI_MSG_ID_GET_VALUE_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
27 dtu_ai_json_get_ai_value_res
回復(fù)服務(wù)器獲取di值
/** * Function : dtu_ai_json_get_ai_value_res * Description : 回復(fù)服務(wù)器獲取di值 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_ai_json_get_ai_value_res(void) { cJSON *gaivr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gaivr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "AI1", cJSON_CreateNumber(SDK_READ_ADC_VALUE_NEW(0,1))); cJSON_AddItemToObject(gaivr, "msgType", cJSON_CreateString("getAiValueRes")); cJSON_AddItemToObject(gaivr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gaivr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gaivr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gaivr); }
28 dtu_ai_json_get_ai_config
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_ai_json_get_ai_config * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_ai_json_get_ai_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_AI_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
29 dtu_ai_json_get_ai_config_res
回復(fù)服務(wù)器獲取di配置
/** * Function : dtu_ai_json_get_ai_config_res * Description : 回復(fù)服務(wù)器獲取di配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_ai_json_get_ai_config_res(void) { cJSON *gaicr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gaicr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "enRpt1", cJSON_CreateNumber(dtu_file_ctx->ai.ai_type)); cJSON_AddItemToObject(data, "cyc1", cJSON_CreateNumber(dtu_file_ctx->ai.ai_interval)); cJSON_AddItemToObject(data, "rptRule1", cJSON_CreateNumber(dtu_file_ctx->ai.ai_res_rule)); cJSON_AddItemToObject(data, "rptMin1", cJSON_CreateNumber(dtu_file_ctx->ai.ai_alarm_low)); cJSON_AddItemToObject(data, "rptMax1", cJSON_CreateNumber(dtu_file_ctx->ai.ai_alarm_high)); cJSON_AddItemToObject(gaicr, "msgType", cJSON_CreateString("getAiConfigRes")); cJSON_AddItemToObject(gaicr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gaicr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gaicr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gaicr); }
30 dtu_ai_json_set_ai_config
設(shè)置ai配置
/** * Function : dtu_ai_json_set_ai_config * Description : 設(shè)置ai配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_ai_json_set_ai_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gaicg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_AI_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gaicg = cJSON_Parse(rcvdata); if(NULL != gaicg) { data = cJSON_GetObjectItem(gaicg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "enRpt1"); dtu_file_ctx->ai.ai_type = item->valueint; item = cJSON_GetObjectItem(data, "cyc1"); dtu_file_ctx->ai.ai_interval = item->valueint; item = cJSON_GetObjectItem(data, "rptRule1"); dtu_file_ctx->ai.ai_res_rule = item->valueint; item = cJSON_GetObjectItem(data, "rptMin1"); dtu_file_ctx->ai.ai_alarm_low = item->valueint; item = cJSON_GetObjectItem(data, "rptMax1"); dtu_file_ctx->ai.ai_alarm_high = item->valueint; // if(DTU_AI_REPORT_INITIATIVE == dtu_file_ctx->ai.ai_type) // { // //開定時器 // dtu_ai1_report_timer_start(dtu_file_ctx->di.di1.di_interval); // } // else if(DTU_AI_REPORT_NONE == dtu_file_ctx->ai.ai_type) // { // dtu_ai1_report_timer_stop(); // } //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("AI1:type %d, interval %d, rull %d, min %d, max %drn", dtu_file_ctx->ai.ai_type, dtu_file_ctx->ai.ai_interval, dtu_file_ctx->ai.ai_res_rule, dtu_file_ctx->ai.ai_alarm_low, dtu_file_ctx->ai.ai_alarm_high); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
31 dtu_ai_json_set_ai_config_res
回復(fù)服務(wù)器設(shè)置di值
/** * Function : dtu_ai_json_set_ai_config_res * Description : 回復(fù)服務(wù)器設(shè)置di值 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_ai_json_set_ai_config_res(UINT8 res) { cJSON *gaivr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gaivr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gaivr, "msgType", cJSON_CreateString("setAiConfigRes")); cJSON_AddItemToObject(gaivr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gaivr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gaivr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gaivr); }
32 dtu_ai_json_res
DI主動上報
/** * Function : dtu_ai_json_res * Description : DI主動上報 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_ai_json_res(void) { cJSON *gaivr = NULL; cJSON *data = NULL; char* send = NULL; INT16 ul_adc_value = 0; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gaivr = cJSON_CreateObject(); data = cJSON_CreateObject(); //獲取adc值 ul_adc_value = SDK_READ_ADC_VALUE_NEW(0,1); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "AI1", cJSON_CreateNumber(ul_adc_value)); cJSON_AddItemToObject(gaivr, "msgType", cJSON_CreateString("aiValueRpt")); cJSON_AddItemToObject(gaivr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gaivr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gaivr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gaivr); }
33 dtu_flow_json_get_flow_config
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_flow_json_get_flow_config * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_flow_json_get_flow_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_FLOW_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
34 dtu_flow_json_get_flow_config_res
回復(fù)服務(wù)器獲取flow配置
/** * Function : dtu_flow_json_get_flow_config_res * Description : 回復(fù)服務(wù)器獲取flow配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_flow_json_get_flow_config_res(void) { cJSON *gfcr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gfcr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "enHb", cJSON_CreateNumber(dtu_file_ctx->hb.heartflag)); cJSON_AddItemToObject(data, "cycHb", cJSON_CreateNumber(dtu_file_ctx->hb.hearttime)); cJSON_AddItemToObject(data, "hbPkg", cJSON_CreateString(dtu_file_ctx->hb.heart)); cJSON_AddItemToObject(data, "enReg", cJSON_CreateNumber(dtu_file_ctx->reg.linkflag)); cJSON_AddItemToObject(data, "regpkg", cJSON_CreateString(dtu_file_ctx->reg.link)); cJSON_AddItemToObject(gfcr, "msgType", cJSON_CreateString("getSysConfigRes")); cJSON_AddItemToObject(gfcr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gfcr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gfcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gfcr); }
35 dtu_flow_json_set_flow_config
設(shè)置flow配置
/** * Function : dtu_flow_json_set_flow_config * Description : 設(shè)置flow配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_flow_json_set_flow_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gfcg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_FLOW_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gfcg = cJSON_Parse(rcvdata); if(NULL != gfcg) { data = cJSON_GetObjectItem(gfcg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "enHb"); dtu_file_ctx->hb.heartflag = item->valueint; item = cJSON_GetObjectItem(data, "cycHb"); dtu_file_ctx->hb.hearttime = item->valueint; item = cJSON_GetObjectItem(data, "hbPkg"); memset(dtu_file_ctx->hb.heart, 0, sizeof(dtu_file_ctx->hb.heart)); memcpy(dtu_file_ctx->hb.heart, item->valuestring, strlen(item->valuestring)); item = cJSON_GetObjectItem(data, "enReg"); dtu_file_ctx->reg.linkflag = item->valueint; item = cJSON_GetObjectItem(data, "regpkg"); memset(dtu_file_ctx->reg.link, 0, sizeof(dtu_file_ctx->reg.link)); memcpy(dtu_file_ctx->reg.link, item->valuestring, strlen(item->valuestring)); if(1 == dtu_file_ctx->hb.heartflag) { //開始心跳定時器 } else if(0 == dtu_file_ctx->hb.heartflag) { //關(guān)閉心跳定時器 } //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("enHb: %d, cycHb: %d, hbPkg: %s, enReg: %d, regpkg: %srn", dtu_file_ctx->hb.heartflag, dtu_file_ctx->hb.hearttime, dtu_file_ctx->hb.heart, dtu_file_ctx->reg.linkflag, dtu_file_ctx->reg.link); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
36 dtu_flow_json_set_flow_config_res
回復(fù)服務(wù)器設(shè)置flow
/** * Function : dtu_flow_json_set_flow_config_res * Description : 回復(fù)服務(wù)器設(shè)置flow * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_flow_json_set_flow_config_res(UINT8 res) { cJSON *gfcr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gfcr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gfcr, "msgType", cJSON_CreateString("setSysConfigRes")); cJSON_AddItemToObject(gfcr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gfcr))); if(NULL != gfcr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gfcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gfcr); }
37 dtu_clk_json_get_clk_config
發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容
/** * Function : dtu_clk_json_clk_net_config * Description : 發(fā)送消息給主任務(wù),按照協(xié)議回復(fù)相應(yīng)內(nèi)容 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_clk_json_get_clk_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_CLK_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
38 dtu_clk_json_get_clk_config_res
回復(fù)服務(wù)器獲clk配置
/** * Function : dtu_clk_json_get_clk_config_res * Description : 回復(fù)服務(wù)器獲clk配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_clk_json_get_clk_config_res(void) { cJSON *gclkcr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gclkcr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "IP", cJSON_CreateString(dtu_file_ctx->socket.ip)); cJSON_AddItemToObject(data, "port", cJSON_CreateNumber(dtu_file_ctx->socket.port)); cJSON_AddItemToObject(data, "type", cJSON_CreateNumber(dtu_file_ctx->socket.type)); cJSON_AddItemToObject(gclkcr, "msgType", cJSON_CreateString("getClockConfigRes")); cJSON_AddItemToObject(gclkcr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gclkcr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gclkcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gclkcr); }
39 dtu_clk_json_set_clk_config
設(shè)置網(wǎng)絡(luò)配置
/** * Function : dtu_clk_json_set_clk_config * Description : 設(shè)置網(wǎng)絡(luò)配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_clk_json_set_clk_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gclkcg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_CLK_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gclkcg = cJSON_Parse(rcvdata); if(NULL != gclkcg) { data = cJSON_GetObjectItem(gclkcg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "IP"); memset(dtu_file_ctx->socket.ip, 0, sizeof(dtu_file_ctx->socket.ip)); memcpy(dtu_file_ctx->socket.ip, item->valuestring, strlen(item->valuestring)); item = cJSON_GetObjectItem(data, "port"); dtu_file_ctx->socket.port = item->valueint; item = cJSON_GetObjectItem(data, "type"); dtu_file_ctx->socket.type = item->valueint; //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("IP %s, port %d, type %d", dtu_file_ctx->socket.ip, dtu_file_ctx->socket.port, dtu_file_ctx->socket.type); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
40 dtu_clk_json_set_clk_config_res
回復(fù)服務(wù)器設(shè)置clk
/** * Function : dtu_clk_json_set_clk_config_res * Description : 回復(fù)服務(wù)器設(shè)置clk * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_clk_json_set_clk_config_res(UINT8 res) { cJSON *gclkcr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gclkcr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gclkcr, "msgType", cJSON_CreateString("setClockConfigRes")); cJSON_AddItemToObject(gclkcr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gclkcr))); if(NULL != gclkcr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gclkcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gclkcr); }
41 dtu_fota_result_json_cbk
json ota 回調(diào)函數(shù)
/** * Function : dtu_fota_result_json_cbk * Description : json ota 回調(diào)函數(shù) * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_fota_result_json_cbk(UINT32 result) { // printf("%s: result = %ld",__FUNCTION__, result); int res = 0; cJSON *gota = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); if(result != FOTA_SUCCESS) { res = 1; printf("Fota Error,Please try again!"); } //創(chuàng)建json對象 gota = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gota, "msgType", cJSON_CreateString("setOTAConfigRes")); cJSON_AddItemToObject(gota, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gota))); if(NULL != gota) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gota); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); free(send); } //刪除json對象 cJSON_Delete(gota); if(result == FOTA_SUCCESS) { printf("Down Bin Ok! Moudle Rebooting For Update..."); sleep(1); PM812_SW_RESET();// restart will update } }
42 dtu_ota_json_set_ota_config
設(shè)置ota參數(shù)
/** * Function : dtu_ota_json_set_ota_config * Description : 設(shè)置ota參數(shù) * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_ota_json_set_ota_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * gclkcg = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_OTA_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) gclkcg = cJSON_Parse(rcvdata); if(NULL != gclkcg) { data = cJSON_GetObjectItem(gclkcg, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "url"); printf("url:%s",item->valuestring); SDK_MYFOTA_UPDATE(item->valuestring, "", "", dtu_fota_result_json_cbk, 20); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
43 dtu_modbus_json_get_modbus_config
服務(wù)器下發(fā)獲取modbus配置
/** * Function : dtu_modbus_json_get_modbus_config * Description : 服務(wù)器下發(fā)獲取modbus配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_modbus_json_get_modbus_config(void) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_MODBUS_MSG_ID_GET_CONFIG_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
44 dtu_modbus_json_get_modbus_config_res
回復(fù)服務(wù)器獲取modbus配置
/** * Function : dtu_modbus_json_get_modbus_config_res * Description : 回復(fù)服務(wù)器獲取modbus配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_modbus_json_get_modbus_config_res(void) { cJSON *gmdcr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gmdcr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "enMb", cJSON_CreateNumber(dtu_file_ctx->modbus.config.type)); cJSON_AddItemToObject(data, "wait", cJSON_CreateNumber(dtu_file_ctx->modbus.config.wait)); cJSON_AddItemToObject(data, "interval", cJSON_CreateNumber(dtu_file_ctx->modbus.config.interval)); cJSON_AddItemToObject(data, "delay", cJSON_CreateNumber(dtu_file_ctx->modbus.config.delay)); cJSON_AddItemToObject(gmdcr, "msgType", cJSON_CreateString("getMbConfig")); cJSON_AddItemToObject(gmdcr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gmdcr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gmdcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); //釋放內(nèi)存 free(send); } //刪除json對象 cJSON_Delete(gmdcr); }
45 dtu_modbus_json_set_modbus_config
服務(wù)器下發(fā)設(shè)置modbus配置
/** * Function : dtu_modbus_json_set_modbus_config * Description : 服務(wù)器下發(fā)設(shè)置modbus配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_modbus_json_set_modbus_config(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * smdcr = NULL; cJSON * data = NULL; cJSON * item = NULL; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_MODBUS_MSG_ID_SET_CONFIG_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) smdcr = cJSON_Parse(rcvdata); if(NULL != smdcr) { data = cJSON_GetObjectItem(smdcr, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "enMb"); dtu_file_ctx->modbus.config.type = item->valueint; item = cJSON_GetObjectItem(data, "wait"); dtu_file_ctx->modbus.config.wait = item->valueint; item = cJSON_GetObjectItem(data, "interval"); dtu_file_ctx->modbus.config.interval = item->valueint; item = cJSON_GetObjectItem(data, "delay"); dtu_file_ctx->modbus.config.delay = item->valueint; if(0 == dtu_file_ctx->modbus.config.type) { //打開心跳 dtu_file_ctx->hb.heartflag = 1; } else { //關(guān)閉心跳 dtu_file_ctx->hb.heartflag = 0; #ifdef DTU_TYPE_HTTP_INCLUDE //關(guān)閉http dtu_file_ctx->http.config.type = 0; #endif /* ifdef DTU_TYPE_HTTP_INCLUDE.2023-10-12 10:38:15 by: zhaoning */ } //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("enMb %d, wait %d, interval %d, delay %d", dtu_file_ctx->modbus.config.type, dtu_file_ctx->modbus.config.wait, dtu_file_ctx->modbus.config.interval, dtu_file_ctx->modbus.config.delay); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
46 dtu_modbus_json_set_modbus_config_res
回復(fù)服務(wù)器設(shè)置modbus配置
/** * Function : dtu_modbus_json_set_modbus_config_res * Description : 回復(fù)服務(wù)器設(shè)置modbus配置 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_modbus_json_set_modbus_config_res(UINT8 res) { cJSON *smdcr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 smdcr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(smdcr, "msgType", cJSON_CreateString("setMbConfigRes")); cJSON_AddItemToObject(smdcr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(smdcr))); if(NULL != smdcr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(smdcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); //釋放內(nèi)存 free(send); } //刪除json對象 cJSON_Delete(smdcr); }
47 dtu_modbus_json_get_modbus_cmd
服務(wù)器獲取modubs指令
/** * Function : dtu_modbus_json_get_modbus_cmd * Description : 服務(wù)器獲取modubs指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_modbus_json_get_modbus_cmd(int len , char *rcvdata) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_MODBUS_MSG_ID_GET_CMD_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
48 dtu_modbus_json_get_modbus_cmd_res
回復(fù)服務(wù)器獲取modubs指令
/** * Function : dtu_modbus_json_get_modbus_cmd_res * Description : 回復(fù)服務(wù)器獲取modubs指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_modbus_json_get_modbus_cmd_res(UINT8 id) { cJSON *gmdcr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gmdcr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "active", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd[id].active)); cJSON_AddItemToObject(data, "sAddr", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd[id].slave_addr)); cJSON_AddItemToObject(data, "cmdType", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd[id].fn)); cJSON_AddItemToObject(data, "regSaddr", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd[id].reg_addr)); cJSON_AddItemToObject(data, "regNorD", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd[id].reg_n_d)); cJSON_AddItemToObject(gmdcr, "msgType", cJSON_CreateString("gerMdCfgRes")); cJSON_AddItemToObject(gmdcr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gmdcr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gmdcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); //釋放內(nèi)存 free(send); } //刪除json對象 cJSON_Delete(gmdcr); }
49 dtu_modbus_json_get_modbus_cmdwn
服務(wù)器獲取modubs指令
/** * Function : dtu_modbus_json_get_modbus_cmdwn * Description : 服務(wù)器獲取modubs指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_modbus_json_get_modbus_cmdwn(int len , char *rcvdata) { DTU_JSON_MSG_T p_smsg = {0}; //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_MODBUS_MSG_ID_GET_CMD_REPORT; // printf("%s PIN4 status: %d n", __FUNCTION__, p_smsg.status); dtu_json_task_send_msgq(&p_smsg); }
50 dtu_modbus_json_get_modbus_cmdwn_res
回復(fù)服務(wù)器獲取modubs指令
/** * Function : dtu_modbus_json_get_modbus_cmdwn_res * Description : 回復(fù)服務(wù)器獲取modubs指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_modbus_json_get_modbus_cmdwn_res(UINT8 id) { cJSON *gmdcr = NULL; cJSON *data = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 gmdcr = cJSON_CreateObject(); data = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(data, "active", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd_wn[id].active)); cJSON_AddItemToObject(data, "sAddr", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd_wn[id].slave_addr)); cJSON_AddItemToObject(data, "cmdType", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd_wn[id].fn)); cJSON_AddItemToObject(data, "regSaddr", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd_wn[id].reg_addr)); cJSON_AddItemToObject(data, "regN", cJSON_CreateNumber(dtu_file_ctx->modbus.cmd_wn[id].reg_n)); // cJSON_AddItemToObject(data, "regData", cJSON_CreateString(dtu_file_ctx->modbus.cmd[id].reg_data)); cJSON_AddItemToObject(gmdcr, "msgType", cJSON_CreateString("getMdCmdWnRes")); cJSON_AddItemToObject(gmdcr, "data", data); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gmdcr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gmdcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); //釋放內(nèi)存 free(send); } //刪除json對象 cJSON_Delete(gmdcr); }
51 dtu_modbus_json_set_modbus_cmd
服務(wù)器下發(fā)設(shè)置modbus指令
/** * Function : dtu_modbus_json_set_modbus_cmd * Description : 服務(wù)器下發(fā)設(shè)置modbus指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_modbus_json_set_modbus_cmd(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * smdc = NULL; cJSON * data = NULL; cJSON * item = NULL; UINT8 id = 0; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_MODBUS_MSG_ID_SET_CMD_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) smdc = cJSON_Parse(rcvdata); if(NULL != smdc) { data = cJSON_GetObjectItem(smdc, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "active"); dtu_file_ctx->modbus.cmd[id].active = item->valueint; item = cJSON_GetObjectItem(data, "sAddr"); dtu_file_ctx->modbus.cmd[id].slave_addr = item->valueint; item = cJSON_GetObjectItem(data, "cmdType"); dtu_file_ctx->modbus.cmd[id].fn = item->valueint; item = cJSON_GetObjectItem(data, "regSaddr"); dtu_file_ctx->modbus.cmd[id].reg_addr = item->valueint; item = cJSON_GetObjectItem(data, "regNorD"); dtu_file_ctx->modbus.cmd[id].reg_n_d = item->valueint; item = cJSON_GetObjectItem(data, "regData"); //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("IP %s, port %d, type %d", dtu_file_ctx->socket.ip, dtu_file_ctx->socket.port, dtu_file_ctx->socket.type); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
52 dtu_modbus_json_set_modbus_cmd_res
回復(fù)服務(wù)器設(shè)置modbus指令
/** * Function : dtu_modbus_json_set_modbus_cmd_res * Description : 回復(fù)服務(wù)器設(shè)置modbus指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_modbus_json_set_modbus_cmd_res(UINT8 res) { cJSON *smdcr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 smdcr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(smdcr, "msgType", cJSON_CreateString("setMbCmdRes")); cJSON_AddItemToObject(smdcr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(smdcr))); if(NULL != smdcr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(smdcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); //釋放內(nèi)存 free(send); } //刪除json對象 cJSON_Delete(smdcr); }
53 dtu_modbus_json_set_modbus_cmdwn
服務(wù)器下發(fā)設(shè)置modbus指令
/** * Function : dtu_modbus_json_set_modbus_cmdwn * Description : 服務(wù)器下發(fā)設(shè)置modbus指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_modbus_json_set_modbus_cmdwn(int len , char *rcvdata) { UINT8 res = 0; DTU_JSON_MSG_T p_smsg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; cJSON * smdc = NULL; cJSON * data = NULL; cJSON * item = NULL; UINT8 id = 0; //獲取對應(yīng)模塊的上下文指針 dtu_file_ctx = dtu_get_file_ctx(); //消息ID設(shè)置為對應(yīng)ID p_smsg.msgId = DTU_MODBUS_MSG_ID_SET_CMD_REPORT; // printf("%s %sn", __FUNCTION__, rcvdata); //解析數(shù)據(jù) smdc = cJSON_Parse(rcvdata); if(NULL != smdc) { data = cJSON_GetObjectItem(smdc, "data"); if(NULL != data) { printf("data:%s",cJSON_Print(data)); item = cJSON_GetObjectItem(data, "active"); dtu_file_ctx->modbus.cmd_wn[id].active = item->valueint; item = cJSON_GetObjectItem(data, "sAddr"); dtu_file_ctx->modbus.cmd_wn[id].slave_addr = item->valueint; item = cJSON_GetObjectItem(data, "cmdType"); dtu_file_ctx->modbus.cmd_wn[id].fn = item->valueint; item = cJSON_GetObjectItem(data, "regSaddr"); dtu_file_ctx->modbus.cmd_wn[id].reg_addr = item->valueint; item = cJSON_GetObjectItem(data, "regN"); dtu_file_ctx->modbus.cmd_wn[id].reg_n = item->valueint; item = cJSON_GetObjectItem(data, "regData"); memset(dtu_file_ctx->modbus.cmd_wn[id].reg_data, 0, sizeof(dtu_file_ctx->modbus.cmd_wn[id].reg_data)); memcpy(dtu_file_ctx->modbus.cmd_wn[id].reg_data, item->valuestring, strlen(item->valuestring)); //寫入文件 dtu_trans_conf_file_write(dtu_file_ctx); printf("IP %s, port %d, type %d", dtu_file_ctx->socket.ip, dtu_file_ctx->socket.port, dtu_file_ctx->socket.type); } else { res = 1; } } else { res = 1; } p_smsg.status = res; dtu_json_task_send_msgq(&p_smsg); }
54 dtu_modbus_json_set_modbus_cmdwn_res
回復(fù)服務(wù)器設(shè)置modbus指令
/** * Function : dtu_modbus_json_set_modbus_cmdwn_res * Description : 回復(fù)服務(wù)器設(shè)置modbus指令 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_modbus_json_set_modbus_cmdwn_res(UINT8 res) { cJSON *gclkcr = NULL; char* send = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); //創(chuàng)建json對象 gclkcr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(gclkcr, "msgType", cJSON_CreateString("setMbCmdWnRes")); cJSON_AddItemToObject(gclkcr, "data", cJSON_CreateNumber(res)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(gclkcr))); if(NULL != gclkcr) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(gclkcr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); //釋放內(nèi)存 free(send); } //刪除json對象 cJSON_Delete(gclkcr); }
55 dtu_modbus_json_modbus_res
modbus模式下,配置為modbus上報后,調(diào)用此函數(shù)把hex轉(zhuǎn)json
/** * Function : dtu_modbus_json_modbus_res * Description : modbus模式下,配置為modbus上報后,調(diào)用此函數(shù)把hex轉(zhuǎn)json * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_modbus_json_modbus_res(UINT8* hex, UINT32 len) { cJSON *s01hr = NULL; cJSON *data = NULL; char* send = NULL; char* asciistr = NULL; DTU_SOCKET_PARAM_T* socket_ctx = NULL; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; //獲取對應(yīng)模塊的上下文指針 socket_ctx = dtu_get_socket_ctx(); dtu_file_ctx = dtu_get_file_ctx(); //創(chuàng)建json對象 s01hr = cJSON_CreateObject(); //按照協(xié)議,對象內(nèi)加入成員 cJSON_AddItemToObject(s01hr, "msgType", cJSON_CreateString("rs485Rpt")); if(len > DTU_MODBUS_RES_LEN / 2) { len = DTU_MODBUS_RES_LEN / 2; } //申請內(nèi)存 asciistr = malloc(len * 2 + 1); if(NULL != asciistr) { memset(asciistr, 0, len * 2 + 1); utils_hex2ascii_str(asciistr, hex, len); cJSON_AddItemToObject(s01hr, "data", cJSON_CreateString(asciistr)); //申請內(nèi)存 send = malloc(strlen(cJSON_Print(s01hr))); if(NULL != send) { memset(send, 0, sizeof(send)); send = cJSON_PrintUnformatted(s01hr); // 生成不帶空格的JSON字符串 printf("send:%s",send); //發(fā)送數(shù)據(jù)到服務(wù)器 dtu_socket_write(socket_ctx->fd, send, strlen(send)); //釋放內(nèi)存 free(send); } } //刪除json對象 cJSON_Delete(s01hr); }
56 dtu_json_task
json主任務(wù)
/** * Function : dtu_json_task * Description : json主任務(wù) * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ static void dtu_json_task(void *param) { OS_STATUS status; DTU_JSON_MSG_T json_rcv_msg = {0}; DTU_FILE_PARAM_T* dtu_file_ctx = NULL; dtu_file_ctx = dtu_get_file_ctx(); //獲取對應(yīng)模塊的上下文指針 dtu_di_times_init(); dtu_di_int_init_all(); dtu_do_times_init(); dtu_do_init(); dtu_ai_times_init(); // dtu_ai1_report_timer_start(dtu_file_ctx->ai.ai_interval); while(1) { status = OSAMsgQRecv(dtu_json_msgq, (void *)&json_rcv_msg, DTU_JSON_TASK_MSGQ_MSG_SIZE, OSA_SUSPEND); if (status == OS_SUCCESS) { printf("%s: json_rcv_msg id: %dn", __FUNCTION__, json_rcv_msg.msgId); printf("%s: json_rcv_msg status: %dn", __FUNCTION__, json_rcv_msg.status); printf("%s: json_rcv_msg channel: %dn", __FUNCTION__, json_rcv_msg.channel); printf("%s: json_rcv_msg result: %dn", __FUNCTION__, json_rcv_msg.result); printf("%s: json_rcv_msg current: %dn", __FUNCTION__, json_rcv_msg.current); // printf("%s: json_rcv_msg value: %dn", __FUNCTION__, json_rcv_msg.us_value); switch(json_rcv_msg.msgId) { case DTU_SYS_MSG_ID_GET_CONFIG_REPORT: dtu_sys_json_get_sys_config_res(); break; case DTU_SYS_MSG_ID_SET_CONFIG_REPORT: dtu_sys_json_set_sys_config_res(json_rcv_msg.status); break; case DTU_NET_MSG_ID_GET_CONFIG_REPORT: dtu_net_json_get_net_config_res(); break; case DTU_NET_MSG_ID_SET_CONFIG_REPORT: dtu_net_json_set_net_config_res(json_rcv_msg.status); break; case DTU_DI_MSG_ID_DI_PROACTIVE_REPORT: dtu_di_json_res(DTU_DI_REPORT_INTER, json_rcv_msg.channel, json_rcv_msg.status); break; case DTU_DI_MSG_ID_DI_TRIGGER_REPORT: dtu_di_json_res(DTU_DI_REPORT_TRIG, json_rcv_msg.channel, json_rcv_msg.status); break; case DTU_DI_MSG_ID_GET_VALUE_REPORT: dtu_di_json_get_di_value_res(); break; case DTU_DI_MSG_ID_GET_CONFIG_REPORT: dtu_di_json_get_di_config_res(); break; case DTU_DI_MSG_ID_SET_CONFIG_REPORT: dtu_di_json_set_di_config_res(json_rcv_msg.status); break; case DTU_DO_MSG_ID_DO_PROACTIVE_REPORT: dtu_do_json_res( json_rcv_msg.channel, json_rcv_msg.status); break; case DTU_DO_MSG_ID_GET_VALUE_REPORT: dtu_do_json_get_do_value_res(); break; case DTU_DO_MSG_ID_GET_CONFIG_REPORT: dtu_do_json_get_do_config_res(); break; case DTU_DO_MSG_ID_SET_CONFIG_REPORT: dtu_do_json_set_do_config_res(json_rcv_msg.status); break; case DTU_AI_MSG_ID_AI_PROACTIVE_REPORT: dtu_ai_json_res(); break; case DTU_AI_MSG_ID_GET_VALUE_REPORT: dtu_ai_json_get_ai_value_res(); break; case DTU_AI_MSG_ID_GET_CONFIG_REPORT: dtu_ai_json_get_ai_config_res(); break; case DTU_AI_MSG_ID_SET_CONFIG_REPORT: dtu_ai_json_set_ai_config_res(json_rcv_msg.result); break; case DTU_FLOW_MSG_ID_GET_CONFIG_REPORT: dtu_flow_json_get_flow_config_res(); break; case DTU_FLOW_MSG_ID_SET_CONFIG_REPORT: dtu_flow_json_set_flow_config_res(json_rcv_msg.status); break; case DTU_CLK_MSG_ID_GET_CONFIG_REPORT: dtu_clk_json_get_clk_config_res(); break; case DTU_CLK_MSG_ID_SET_CONFIG_REPORT: dtu_clk_json_set_clk_config_res(json_rcv_msg.status); break; #ifdef DTU_TYPE_MODBUS_INCLUDE case DTU_MODBUS_MSG_ID_GET_CONFIG_REPORT: dtu_modbus_json_get_modbus_config_res(); break; case DTU_MODBUS_MSG_ID_SET_CONFIG_REPORT: dtu_modbus_json_set_modbus_config_res(json_rcv_msg.status); break; case DTU_MODBUS_MSG_ID_GET_CMD_REPORT: dtu_modbus_json_get_modbus_cmd_res(json_rcv_msg.channel); break; case DTU_MODBUS_MSG_ID_SET_CMD_REPORT: dtu_modbus_json_set_modbus_cmd_res(json_rcv_msg.status); break; #endif /* ifdef DTU_TYPE_MODBUS_INCLUDE.2023-10-10 11:08:46 by: zhaoning */ #ifdef DTU_TYPE_HTTP_INCLUDE case DTU_HTTP_MSG_ID_GET_CONFIG_REPORT: dtu_http_json_get_http_config_res(); break; case DTU_HTTP_MSG_ID_SET_CONFIG_REPORT: dtu_http_json_set_http_config_res(json_rcv_msg.status); break; case DTU_HTTP_MSG_ID_GET_CMD_REPORT: dtu_http_json_get_http_cmd_res(); break; case DTU_HTTP_MSG_ID_SET_CMD_REPORT: dtu_http_json_set_http_cmd_res(json_rcv_msg.status); break; #endif /* ifdef DTU_TYPE_HTTP_INCLUDE.2023-10-10 11:09:21 by: zhaoning */ default: break; } } // if (json_rcv_msg.data) // { // free(json_rcv_msg.data); // json_rcv_msg.data = NULL; // } } }
57 dtu_di_task_init
di主任務(wù)和消息隊列創(chuàng)建
/** * Function : dtu_di_task_init * Description : di主任務(wù)和消息隊列創(chuàng)建 * Input : * * Output : * Return : * Auther : zhaoning * Others : **/ void dtu_json_task_init(void) { OSA_STATUS status = 0; /*creat message*/ status = OSAMsgQCreate(&dtu_json_msgq, "dtu_json_msgq", DTU_JSON_TASK_MSGQ_MSG_SIZE, DTU_JSON_TASK_MSGQ_QUEUE_SIZE, OS_FIFO); ASSERT(status == OS_SUCCESS); //創(chuàng)建DI任務(wù) status = OSATaskCreate(&dtu_json_task_ref, dtu_json_task_stack, DTU_JSON_TASK_STACK_SIZE, 161, "json_task", dtu_json_task, NULL); ASSERT(status == OS_SUCCESS); }
4 Demo實戰(zhàn)
4.1 創(chuàng)建一個Demo
復(fù)制20.9_di_xtu示例工程,到同一個文件夾下,修改文件名為20.12_json_xtu,如圖:
4.2 修改makefile
增加文件組件所在目錄頭文件路徑,和源文件路徑,以及一些宏定義,如圖:
-D是makefile中定義宏定義必要的前綴,可以搜索相關(guān)makefile學(xué)習(xí)文章學(xué)習(xí)相關(guān)知識。
DTU_BASED_ON_TCP 表示當(dāng)前是TCP模式,當(dāng)前組件使用需要am.h中包含一些對應(yīng)。
DTU_TYPE_5X6 表示使用SOM板貼片5x6卡,可以使用其它卡,修改為對應(yīng)宏定義就可以。
DTU_UART_115200_BAUD 表示使用115200波特率
DTU_TYPE_JSON_INCLUDE 表示把JSON功能包含進(jìn)來
4.3 增加頭文件
使用代碼編輯器,將新建的工程文件加入代碼編輯器中,打開main.c,修改main.c,加入am.h頭文件,如圖:
4.4 修改代碼
示例使用的是板載5x6卡,用戶的硬件可能是使用外置卡,或者是三合一全網(wǎng)通卡,因為硬件上三種卡使用的模組SIM卡接口不一樣(外置卡SIM1,5x6卡和三合一卡SIM2),所以,需要通過一個全局變量來制定SIM卡硬件接口。
extern外部變量SDK_INIT_SIM_SELECT_VALUE,這里判斷了是否使用外置卡,這個宏定義在Makefile里面定義。
在Phase1Inits_enter中,宏定義判斷是否要包含對SDK_INIT_SIM_SELECT_VALUE變量的修改。
在Phase2Inits_exit 調(diào)用文件組件提供的對外API,如圖:
4.5 編譯
在SDK根目錄打開命令行,輸入命令.build.bat -l .amaziot_bloom_os_sdksamplelibraries20.12_json_xtu
PS F:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08 λ .build.bat -l .amaziot_bloom_os_sdksamplelibraries20.12_json_xtu 子目錄或文件 outbin 已經(jīng)存在。 子目錄或文件 buildcJSON 已經(jīng)存在。 子目錄或文件 buildobj 已經(jīng)存在。 gnumake: Entering directory `F:/3.asr-b/cat.1-asr1606/1.software/BLOOM_OS_1606_OPENCPU_1191_A08/amaziot_bloom_os_sdk/sample/libraries/20.12_json_xtu' armcc.exe -c --cpu Cortex-R4 --no_unaligned_access -g -O2 --apcs /inter --diag_suppress 2084,1,2,177,188,223,550,1296,2795,6319,9931,9933 --diag_error=warning --gnu --thumb --loose_implicit_cast -DDATA_COLLECTOR_IMPL -DISPT_OVER_SSP -DDIAG_SSP_DOUBLE_BUFFER_USE_DYNAMIC_ALLOCATION -DENV_XSCALE -DL1_DCXO_ENABLED -DLTE_HIGH_MOBILITY_OPTIMIZATION -DRUN_XIP_MODE -DCRANE_Z2 -DCA_LONG_IPC_MSG -DNEZHA3 -DNEZHA3_1826 -DUPGRADE_PLMS -DUPGRADE_PLMS_SR -DLTE_GSMMULTIBCCH -DGPLC_LTE_RSSI_SCAN -DL1V_NEW_RSSI -DUPGRADE_PLMS_3G -DUPGRADE_PLMS_L1 -DUPGRADE_FG_PLMS -DFG_PLMS_URR -DUPGRADE_L1A_FG_PLMS -DUPGRADE_PLMS_STAGE_2 -DUPGRADE_MBCCH -DMULTI_BCCH_READY_IND -DURR_MRAT_ICS_SEARCH -DUPGRADE_ICS -DMRAT_NAS -DUPGRADE_PLMS_SEARCH_API -DICS_MBCCH -DICS_MBCCH_2G_RSSI -DDIAG_NEWPP -DPHS_SW_DEMO -DPHS_SW_DEMO_TTC -DPHS_SW_DEMO_TTC_PM -DFULL_SYSTEM -D_DDR_INIT_ -D_TAVOR_HARBELL_ -DUPGRADE_ARBEL_PLATFORM -D_TAVOR_B0_SILICON_ -DTDL1C_SPY_ENABLE -DDLM_TAVOR -DTAVOR -DFLAVOR_DUALCORE -DDEBUG_D2_MOR_REG_RESEREVED_ENABLE -D_DIAG_USE_COMMSTACK_ -D_TAVOR_DIAG_ -DPM_DEBUG_MODE_ENABLED -DPM_D2FULL_MODE -DPM_EXT_DBG_INT_ARR -DFEATURE_WB_AMR_PS -DMACRO_FOR_LWG -DHL_LWG -DOPTIMIZE_FOR_2G_BCCH -DPLAT_TEST -D_FDI_USE_OSA_ -DPLAT_USE_THREADX -DLWIP_IPNETBUF_SUPPORT -DCRANE_MCU_DONGLE -DAT_OVER_UART -DPHS_SW_DEMO_TTC_PM -DUPGRADE_LTE_ONLY -DEXT_AT_MODEM_SUPPORT -DLTEONLY_THIN_SINGLE_SIM -DLFS_FILE_SYS -DLFS_FILE_SYS_V2 -DPSM_ENABLE -DNO_PAHO_MQTT -DNO_XML -DNO_LWM2M -DREMOVE_MBEDTLS -DNO_AT_NET -DCRANE_SD_NOT_SUPPORT -DNTP -DYMODEM_EEH_DUMP -DENABLE_DM_LTEONLY -DLTEONLY_THIN -DNO_EXTEND_MY_Q_AT -DNOT_SUPPORT_HTTPS -DNOT_SUPPORT_PM813 -DCRANEL_4MRAM -DREMOVE_PB -DUART_NEW_VERSION -DREMOVE_MEP -DREMOVE_SMS -DREMOVE_ENVSIM -DAPN_INCODE -DLTEONLY_THIN_SINGLE_SIM_2MFLASH -DASR160X_OPENCPU_FEATURE -DENABLE_UART3_FEATRUE -DENABLE_UART4_FEATRUE -DYUGE_MBEDTLS_3_2_1 -DENABLE_MAC_TX_DATA_LOGGING -DDISABLE_NVRAM_ACCESS -DINTEL_UPGRADE_EE_HANDLER_SUPPORT -DLTE_W_PS -DL1_DUAL_MODE -DUPGRADE_HERMON_DUAL -DINTEL_UPGRADE_DUAL_RAT -DINTEL_UPGRADE_GPRS_CIPHER_FLUSH -DUPGRADE_ENHANCED_QUAD_BAND -DINTEL_2CHIP_PLAT -DI_2CHIP_PLAT -DUPGRDE_TAVOR_COMMUNICATION -DRUN_WIRELESS_MODEM -DFLAVOR_DDR12MB_GB1MB5 -DFEATURE_SHMEM -DACIPC_ENABLE_NEW_CALLBACK_MECHANISM -DRELIABLE_DATA -DMAP_NSS -DTV_FNAME=""SW_PLATFORM=PMD2NONE PHS_SW_DEMO PHS_SW_DEMO_PM SRCNUCLEUS FULL_SYSTEM NOACRTC PDFLT PLAT_TEST PV2 DIAGOSHMEM NVM WITHL1V"" -DTV_FDESC=""SW_DESCRIPTION="" -DENABLE_ACIPC -D_DATAOMSL_ENABLED_ -DUSB_CABLE_DETECTION_VIA_PMIC -DMIPS_TEST -DMIPS_TEST_RAM -DFLAVOR_DIET_RAM -DNVM_INCLUDE -DMSL_INCLUDE -DMSL_POOL_MEM -DNO_AUDIO -DOSA_QUEUE_NAMES -D_DIAG_DISABLE_USB_ -DOSA_NUCLEUS -DOSA_USED -DPM_D2NONE_MODE -DCRANE_SOC_TEMPERATURE_SENSOR -DL1_SW_UPDATE_FOR_DIGRF -DPHS_L1_SW_UPDATE_R7 -DUPGRADE_LTE -DFRBD_CALIB_NVM -DFRBD_AGC_CALIB -DFRBD_FDT_CALIB -DHSPA_MPR -DCAPT_PARAMS_OPTIMIZE -DL1_WB_R99_ONLY -DL1V_WB_R99_ONLY -DINTERGRATED_RF_SUPPORT -DL1_RX_DIV_SUPPORT -DENABLE_OOS_HANDLING -DTAVOR_D2_WB_L1_SUPPORT -DL1_DDR_HIGH_FREQ -DUPGRADE_DIGRF3G_SUPPORT -DW_PS_PLUS_G_PAGING -D"NO_APLP=0" -DINTEL_UPGRADE_UNIFIED_VOICE_TASK -DINTEL_UPGRADE_R99 -DAPLP_SPY_ENABLE -D__TARGET_FEATURE_DOUBLEWORD -DWHOLE_UMTS_STACK -DUSE_TTPCOM_CSR_BLUETOOTH_AUDIO_GAIN_CONTROL -DL1_UPGRADE_R5 -DUPGRADE_EDGE -DUPGRADE_R4_FS1 -DINTEL_UPGRADE_GSM_CRL_IF -DUPGRADE_EGPRS_M -DINTEL_UPGRADE_EGPRS_M -DINTEL_UPGRADE_RF_PARAMS_IN_CF_TDS -DINTEL_UPGRADE_2SAMPLES_PER_SYMBOL -D"GPRS_MULTISLOT_CLASS=12" -D"EGPRS_MULTISLOT_CLASS=12" -DMARVELL_UPGRADE_BSIC_REDESIGN -DMSL_INCLUDE -DINTEL_HERMON_SAC -DCRANE_CUST_BUILD -DL1_SW_UPDATE_FOR_DIGRF -DFLAVOR_COM -DSILICON_PV2 -DSILICON_SEAGULL -DSILICON_TTC_CORE_SEAGULL -DPCAC_INCLUDE -Otime -DBUILD_DATE=""11 22 2023"" -DBUILD_TIME=""10:48:29"" -Iatcmdsinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoptelephonyyugeinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalUARTinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalcoreinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalPMUinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalGPIOinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xosposixinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xdiagdiag_logicsrc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xcswSysCfginc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xcswplatforminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xenvwin32inc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xcswBSPinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xcswplatformdev_platbuild -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xososainc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xosthreadxinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xosnu_xscaleinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacpsminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcachttpclientsrc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xdiagdiag_logicinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoptimerinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopintcinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xcswPMinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoppminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilTickManagerinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopBSPinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoptelephonyatcmdsrvinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoptelephonyatparserinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoptelephonysdkinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcachttpclientinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacciinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcaclwipv4v6srcinclude -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcaclwipv4v6srcincludearch -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcaclwipv4v6srcincludeipv4 -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcaclwipv4v6srcincludeipv6 -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcaclwipv4v6srcincludelwip -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcaclwipv4v6srcincludenetif -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopmmi_matinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xtavorArbelinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xtavorenvinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoptelephonymodeminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacdusterinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacfotainc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalI2Cinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalACIPCinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilfatsysflash -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilFDIsrcINCLUDE -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalMMUinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilFDIsrcFDI_ADD -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilFDIsrcFM_INC -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilfatsysfshdr -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutillittlefsinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacttsinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacdialinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilcsw_memoryinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoputilitiesinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopcommpminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilnvminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilEEhandlerinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilEEhandlersrc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopRTCinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhoptelephonyci_clientinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalBT_deviceinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalUARTinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopmrdinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopdmainc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilsoftutilinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhalSPIinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacwebsocketinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacatnet_srvinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xsoftutilfotacomminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xaud_swAudioinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xaud_swACM_COMMinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xaud_swaudio_stubsrc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhopaaminc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xaud_swAudioHALinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xhaldbgshellinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08includeasr160xpcacopencpuinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08amaziot_bloom_os_sdkutils -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08CSDK_CODEcJSONinc -IF:/3.asr-b/cat.1-asr1606/1.software/BLOOM_OS_1606_OPENCPU_1191_A08/amaziot_bloom_os_sdk/sample/libraries/20.12_json_xtuaminc -IF:/3.asr-b/cat.1-asr1606/1.software/BLOOM_OS_1606_OPENCPU_1191_A08/amaziot_bloom_os_sdk/sample/libraries/20.12_json_xtuatcmdsinc -IF:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08/amaziot_bloom_os_sdk/librariesamxtu -DDTU_BASED_ON_TCP -DDTU_TYPE_5X6 -DDTU_UART_115200_BAUD -DDTU_TYPE_DODIAI_INCLUDE -DDTU_TYPE_JSON_INCLUDE -o buildobj/ext_at_cmds.o F:/3.asr-b/cat.1-asr1606/1.software/BLOOM_OS_1606_OPENCPU_1191_A08/amaziot_bloom_os_sdk/sample/libraries/20.12_json_xtu/atcmds/src/ext_at_cmds.c armlink.exe buildobj/main.o buildobj/ext_at_cmds.o buildobj/ext_at_controller.o buildobj/am_file.o buildobj/am_at.o buildobj/am_trans.o buildobj/am_hb.o buildobj/am_di.o buildobj/am_do.o buildobj/am_ai.o buildobj/am_clock.o buildobj/am_json.o buildobj/am_socket.o buildCSDK_CODE.lib -o F:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08outbinArbel_PMD2NONE_40M.axf --via F:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08prebuilt_1606lArbel_PMD2NONE_targ_objliblist.txt --elf --scatter F:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08prebuilt_1606lCrane_DS_4M_Ram_2M_Flash_XIP_CIPSRAM_Common_SingleSIM.sct --predefine="-DLTEONLY_THIN_SINGLE_SIM" --map --symbols --info sizes,totals --list F:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08outbinArbel_PMD2NONE_40M.map --keep init.o(Header) --keep init.o(Vectors) --diag_suppress 6312,6314,6319,6329 --feedback F:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08outfeedbackLinkOptLteonlyThin_SingleSim_NoSMS.txt F:3.asr-bcat.1-asr16061.softwareBLOOM_OS_1606_OPENCPU_1191_A08toolsbuildimage_1606l.bat SDK_PROD_TYPE : [DM] SDK_CUST_SKU : [THIN_SINGLE_SIM_NO_SMS] SDK_PS_MODE : [LTEONLY] SDK_CHIP_VER : [Z2A0] SDK_OS_TYPE : [TX] Platform Convertion Tools v4.01 with PS option extension Convertion done! |INPUT |outbincp_1606L.bin |MARK |NAME |EXEADDR .LOADADDR.LENGTH .CPZLADDR|COMPRESS STASTIC | |--------|--------|--------.--------.--------.--------|------------------------------| |This Is LteOnly 4M| |RW_CPZ_1|DDR_RW_ |7e11c000.8006cd70.0000d40c.8006d000|0000d40c->00003000 |This Is LteOnly 4M| |RW_CPZ_2|PS_NCAH |7e388000.8007a17c.00001300.80070000|00001300->00001000 |This Is LteOnly 4M| |RW_CPZ_3|ITCM |7e3dac00.8007b47c.0000f51c.80071000|0000f51c->0000a000 |This Is LteOnly 4M| |RW_CPZ_4|CODE_PS |7e1ad000.8008a998.0002fcdc.8007b000|0002fcdc->0001e000 |This Is LteOnly 4M| |RW_CPZ_5|CODEPSB |7e1df000.800ba674.000339c0.80099000|000339c0->0001b000 |This Is LteOnly 4M| |RW_CPZ_6|CODEPSC |7e216000.800ee034.000323ec.800b4000|000323ec->0001b000 |This Is LteOnly 4M| |RW_CPZ_7|CODEPSD |7e24c000.80120420.00028d88.800cf000|00028d88->0001a000 |This Is LteOnly 4M| |RW_CPZ_8|CODEPSE |7e27a000.801491a8.0002e310.800e9000|0002e310->0001a000 |This Is LteOnly 4M| |RW_CPZ_9|CODEPSF |7e2ac000.801774b8.0001c948.80103000|0001c948->00011000 |This Is LteOnly 4M| |RW_CPZ_A|CODE_PL |7e2cd000.80193e00.0002f914.80114000|0002f914->0001e000 |This Is LteOnly 4M| |RW_CPZ_B|CODEPLB |7e2fd000.801c3714.00038d38.80132000|00038d38->00021000 |This Is LteOnly 4M| |RW_CPZ_C|CODEPLC |7e337000.801fc44c.000268d4.80153000|000268d4->00012000 |--------|--------|--------.--------.--------.--------|------------------------------| | | 0x0020bd20 -> 0x0014e000| | | 2.046(MB) -> 1.305(MB)| |------------------------------------------------------------------------------------| cp_1606L.axf cp_1606L.bin cp_1606L.map gnumake: Leaving directory `F:/3.asr-b/cat.1-asr1606/1.software/BLOOM_OS_1606_OPENCPU_1191_A08/amaziot_bloom_os_sdk/sample/libraries/20.12_json_xtu' "copy NEZHAC_CP_CNR_MIFI_TX.bin to ./ " 已復(fù)制 1 個文件。
4.6 生成固件
參考入門中開發(fā)工具,生成工具。
4.7 查看現(xiàn)象
固件下載到模組后,配置服務(wù)器地址,之后按照J(rèn)son協(xié)議下發(fā)數(shù)據(jù)測試,
5 總結(jié)
根據(jù)實驗現(xiàn)象,用戶需要實現(xiàn)自己的AT指令,只需要參考組件中的例子,按照自己需求修改,
本文章源自奇跡物聯(lián)開源的物聯(lián)網(wǎng)應(yīng)用知識庫Cellular IoT Wiki,更多技術(shù)干貨歡迎關(guān)注收藏Wiki:Cellular IoT Wiki 知識庫(https://rckrv97mzx.feishu.cn/wiki/wikcnBvAC9WOkEYG5CLqGwm6PHf)
歡迎同學(xué)們走進(jìn)AmazIOT知識庫的世界!
這里是為物聯(lián)網(wǎng)人構(gòu)建的技術(shù)應(yīng)用百科,以便幫助你更快更簡單的開發(fā)物聯(lián)網(wǎng)產(chǎn)品。
Cellular IoT Wiki初心:
在我們長期投身于蜂窩物聯(lián)網(wǎng) ODM/OEM 解決方案的實踐過程中,一直被物聯(lián)網(wǎng)技術(shù)碎片化與產(chǎn)業(yè)資源碎片化的問題所困擾。從產(chǎn)品定義、芯片選型,到軟硬件研發(fā)和測試,物聯(lián)網(wǎng)技術(shù)的碎片化以及產(chǎn)業(yè)資源的碎片化,始終對團隊的產(chǎn)品開發(fā)交付質(zhì)量和效率形成制約。為了減少因物聯(lián)網(wǎng)碎片化而帶來的重復(fù)開發(fā)工作,我們著手對物聯(lián)網(wǎng)開發(fā)中高頻應(yīng)用的技術(shù)知識進(jìn)行沉淀管理,并基于 Bloom OS 搭建了不同平臺的 RTOS 應(yīng)用生態(tài)。后來我們發(fā)現(xiàn),很多物聯(lián)網(wǎng)產(chǎn)品開發(fā)團隊都面臨著相似的困擾,于是,我們決定向全體物聯(lián)網(wǎng)行業(yè)開發(fā)者開放奇跡物聯(lián)內(nèi)部沉淀的應(yīng)用技術(shù)知識庫 Wiki,期望能為更多物聯(lián)網(wǎng)產(chǎn)品開發(fā)者減輕一些重復(fù)造輪子的負(fù)擔(dān)。
Cellular IoT Wiki沉淀的技術(shù)內(nèi)容方向如下:
奇跡物聯(lián)的業(yè)務(wù)服務(wù)范圍:基于自研的NB-IoT、Cat1、Cat4等物聯(lián)網(wǎng)模組,為客戶物聯(lián)網(wǎng)ODM/OEM解決方案服務(wù)。我們的研發(fā)技術(shù)中心在石家莊,PCBA生產(chǎn)基地分布在深圳、石家莊、北京三個工廠,滿足不同區(qū)域&不同量產(chǎn)規(guī)模&不同產(chǎn)品開發(fā)階段的生產(chǎn)制造任務(wù)。跟傳統(tǒng)PCBA工廠最大的區(qū)別是我們只服務(wù)物聯(lián)網(wǎng)行業(yè)客戶。
連接我們,和10000+物聯(lián)網(wǎng)開發(fā)者一起 降低技術(shù)和成本門檻
讓蜂窩物聯(lián)網(wǎng)應(yīng)用更簡單~~
哈哈你終于滑到最重要的模塊了,
千萬不!要!劃!走!忍住沖動!~
歡迎加入飛書“開源技術(shù)交流群”,隨時找到我們哦~
點擊鏈接如何加入奇跡物聯(lián)技術(shù)話題群(https://rckrv97mzx.feishu.cn/docx/Xskpd1cFQo7hu9x5EuicbsjTnTf)可以獲取加入技術(shù)話題群攻略
Hey 物聯(lián)網(wǎng)從業(yè)者,
你是否有了解過奇跡物聯(lián)的官方公眾號“eSIM物聯(lián)工場”呢?
這里是奇跡物聯(lián)的物聯(lián)網(wǎng)應(yīng)用技術(shù)開源wiki主陣地,歡迎關(guān)注公眾號,不迷路~
及時獲得最新物聯(lián)網(wǎng)應(yīng)用技術(shù)沉淀發(fā)布
(如有侵權(quán),聯(lián)系刪除)
審核編輯 黃宇
-
物聯(lián)網(wǎng)
+關(guān)注
關(guān)注
2909文章
44635瀏覽量
373388 -
服務(wù)器
+關(guān)注
關(guān)注
12文章
9160瀏覽量
85425 -
RTU
+關(guān)注
關(guān)注
0文章
413瀏覽量
28680 -
JSON
+關(guān)注
關(guān)注
0文章
117瀏覽量
6968
發(fā)布評論請先 登錄
相關(guān)推薦
評論