From 1ff43801a489ce8482dda3f7bf027082de33ccf2 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期一, 17 九月 2018 21:12:45 +0800 Subject: [PATCH] 增加多对多功能,尚未解决标签设ID问题(标签自动休眠,DMA无法收到串口数据) --- 源码/核心板/Src/application/serial_at_cmd_app.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" index 913b7c5..b3d7257 100644 --- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" +++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" @@ -1,19 +1,42 @@ #include "serial_at_cmd_app.h" #include "global_param.h" #include <string.h> +#include <stdio.h> uint8_t m_frame_data[MAX_FRAME_LEN] = {0}; uint8_t m_frame_data_len = 0; void ParseFrame(void) { - if(!memcmp(m_frame_data, "SET", 3)) + if(!memcmp(m_frame_data, "DIS", 3)) { g_com_map[ALARM_DISTANCE] = (m_frame_data[3]-'0')*1000 + (m_frame_data[4]-'0')*100 + (m_frame_data[5]-'0')*10 + (m_frame_data[6]-'0'); + printf("When distance < %d cm, alarm is on.\n", g_com_map[ALARM_DISTANCE]); + save_com_map_to_flash(); } else if(!memcmp(m_frame_data, "DEV", 3)) { g_com_map[ALARM_DEV] = m_frame_data[3]-'0'; + printf("Alarm device is %d. \n", g_com_map[ALARM_DEV]); + save_com_map_to_flash(); + } + else if(!memcmp(m_frame_data, "ID", 2)) + { + g_com_map[DEV_ID] = 0; + for(uint8_t i=2; i < m_frame_data_len; i++) + { + if(m_frame_data[i]<58 && m_frame_data[i]>47) + { + g_com_map[DEV_ID] = g_com_map[DEV_ID]*10 + m_frame_data[i]- '0'; + } + else + { + printf("Error: Wrong ID.\r\n"); + break; + } + } + printf("set dev id = %d. \r\n", g_com_map[DEV_ID]); + save_com_map_to_flash(); } } -- Gitblit v1.9.3