增加注释,增加代码可读性
This commit is contained in:
parent
fcfcf0e108
commit
b1d61a880b
|
@ -145,7 +145,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver.506412204" name="GNU ARM Cross Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver"/>
|
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver.506412204" name="GNU ARM Cross Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver"/>
|
||||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash.1461589245" name="GNU ARM Cross Create Flash Image" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash">
|
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash.1461589245" name="GNU ARM Cross Create Flash Image" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash">
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.1937707052" name="Output file format (-O)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.ihex" valueType="enumerated"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.1937707052" name="Output file format (-O)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.binary" valueType="enumerated"/>
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting.82359725" name="GNU ARM Cross Create Listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting">
|
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting.82359725" name="GNU ARM Cross Create Listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting">
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source.601724476" name="Display source (--source|-S)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source" value="true" valueType="boolean"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source.601724476" name="Display source (--source|-S)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source" value="true" valueType="boolean"/>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.jlink.launchConfigurationType">
|
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.jlink.launchConfigurationType">
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.PERIPHERALS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <peripherals/> "/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.PERIPHERALS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <peripherals/> "/>
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.adapterName" value="J-Link"/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.adapterName" value="J-Link"/>
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.binFileStartAddress" value=""/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.binFileStartAddress" value="0x08000000"/>
|
||||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doConnectToRunning" value="false"/>
|
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doConnectToRunning" value="false"/>
|
||||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doContinue" value="true"/>
|
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doContinue" value="true"/>
|
||||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doDebugInRam" value="false"/>
|
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doDebugInRam" value="false"/>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetSpeed" value="4000"/>
|
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetSpeed" value="4000"/>
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetType" value=""/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetType" value=""/>
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDeviceName" value="STM32L071RB"/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDeviceName" value="STM32L071RB"/>
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDownloadHex" value="true"/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDownloadHex" value="false"/>
|
||||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.forceQuitGdbServer" value="false"/>
|
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.forceQuitGdbServer" value="false"/>
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
||||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherOptions" value=""/>
|
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherOptions" value=""/>
|
||||||
|
|
|
@ -51,7 +51,7 @@ uint32_t device_id_dec(void)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
//默认设备ID
|
//默认设备ID
|
||||||
uint32_t dev_id = 250400003;
|
uint32_t dev_id = 240400000;
|
||||||
|
|
||||||
dev_par.id_hex[0] = (dev_id>>24)&0xFF;
|
dev_par.id_hex[0] = (dev_id>>24)&0xFF;
|
||||||
dev_par.id_hex[1] = (dev_id>>16)&0xFF;
|
dev_par.id_hex[1] = (dev_id>>16)&0xFF;
|
||||||
|
|
|
@ -35,26 +35,26 @@
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t logo;
|
uint8_t logo; // 标识
|
||||||
uint8_t head;
|
uint8_t head; // 报头文
|
||||||
uint8_t length;
|
uint8_t length; // 上报字节长度
|
||||||
uint8_t packs_all;
|
uint8_t packs_all; // 数据包总数
|
||||||
uint8_t packs_num;
|
uint8_t packs_num; // 数据包序号
|
||||||
uint8_t dev_id[4];
|
uint8_t dev_id[4]; // 设备ID
|
||||||
uint8_t collect_time[4];
|
uint8_t collect_time[4]; // 采集时间
|
||||||
uint8_t csq;
|
uint8_t csq; // 接收信号强度RSSI
|
||||||
uint8_t voltage[2];
|
uint8_t voltage[2]; // 电池电压
|
||||||
uint8_t temperature[2];
|
uint8_t temperature[2]; // 测量温度
|
||||||
uint8_t methane[2];
|
uint8_t methane[2]; // 激光甲烷浓度
|
||||||
uint8_t methane_state[2];
|
uint8_t methane_state[2]; // 激光甲烷传感器状态码
|
||||||
uint8_t water[2];
|
uint8_t water[2]; // 水浸+井盖异动
|
||||||
uint8_t distance[2];
|
uint8_t distance[2]; // 超声波测距
|
||||||
uint8_t pci[2];
|
uint8_t pci[2]; // 物理小区标识PCI
|
||||||
uint8_t turn;
|
uint8_t turn; // 侧翻报警
|
||||||
uint8_t rsrp[2];
|
uint8_t rsrp[2]; // 参考信号接收功率
|
||||||
uint8_t snr[2];
|
uint8_t snr[2]; // 信噪比
|
||||||
uint8_t gps_latitude[4];
|
uint8_t gps_latitude[4]; // GPS维度
|
||||||
uint8_t gps_longitude[4];
|
uint8_t gps_longitude[4]; // GPS经度
|
||||||
}iot_device_message_t;
|
}iot_device_message_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -253,7 +253,7 @@ uint8_t i_csq_deal(char* data, uint8_t len)
|
||||||
#endif
|
#endif
|
||||||
LOG_OUT("csq=%d\r\n", csq_value);
|
LOG_OUT("csq=%d\r\n", csq_value);
|
||||||
|
|
||||||
i_dev_mess.csq = csq_value;
|
i_dev_mess.csq = csq_value; // 信号强度RSSI数值(0~0x31),上传十六进制数据到平台,平台换算成十进制数据
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
extern iot_control_t iot_ctl;
|
extern iot_control_t iot_ctl;
|
||||||
extern rt_timer_t iot_timer_3;
|
extern rt_timer_t iot_timer_3;
|
||||||
extern iot_device_message_t i_dev_mess;
|
extern iot_device_message_t i_dev_mess;
|
||||||
|
iot_device_message_t i_dev_mess_test;
|
||||||
|
|
||||||
extern iot_device_set_message_t i_set_mess;
|
extern iot_device_set_message_t i_set_mess;
|
||||||
|
|
||||||
extern rt_uint8_t iot_send_buff[IOT_SEND_BUFF_SIZE];
|
extern rt_uint8_t iot_send_buff[IOT_SEND_BUFF_SIZE];
|
||||||
|
@ -61,7 +63,6 @@ void app_iot_up_update(uint8_t cmd, uint16_t data)
|
||||||
iot_send_head_len = 17;
|
iot_send_head_len = 17;
|
||||||
memcpy(iot_send_buff, "AT+MIPSEND=0,41,\"", iot_send_head_len);
|
memcpy(iot_send_buff, "AT+MIPSEND=0,41,\"", iot_send_head_len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
user_num_tran_ascll_2(iot_send_buff+iot_send_head_len, &i_dev_mess, iot_send_len);
|
user_num_tran_ascll_2(iot_send_buff+iot_send_head_len, &i_dev_mess, iot_send_len);
|
||||||
}
|
}
|
||||||
else if(cmd == CMD_DOWN_ACK)
|
else if(cmd == CMD_DOWN_ACK)
|
||||||
|
|
|
@ -104,6 +104,34 @@ void user_num_tran_ascll_2(uint8_t *data1, uint8_t *data2, uint8_t data2_len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 数组转字符串(test)
|
||||||
|
*/
|
||||||
|
void user_num_tran_ascll_2_test(uint8_t *data1, uint8_t *data2, uint8_t data2_len)
|
||||||
|
{
|
||||||
|
// 检查输入指针是否有效
|
||||||
|
if (data1 == NULL || data2 == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char hex_digits[16] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
for (uint8_t t = 0; t < data2_len; t++)
|
||||||
|
{
|
||||||
|
uint8_t byte = *(data2 + t);
|
||||||
|
|
||||||
|
// 高4位转换
|
||||||
|
uint8_t high_nibble = (byte >> 4) & 0x0F;
|
||||||
|
*(data1 + (t * 2)) = hex_digits[high_nibble];
|
||||||
|
|
||||||
|
// 低4位转换
|
||||||
|
uint8_t low_nibble = byte & 0x0F;
|
||||||
|
*(data1 + (t * 2) + 1) = hex_digits[low_nibble];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 字符串转数组+合并
|
* 字符串转数组+合并
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,6 +7,7 @@ uint8_t user_num_tran_char(uint32_t number, uint8_t* addr, uint32_t end_flag);
|
||||||
void user_char_tran_numbuff(uint8_t *addr1, uint8_t *addr2, uint32_t max_len, uint32_t end_flag);
|
void user_char_tran_numbuff(uint8_t *addr1, uint8_t *addr2, uint32_t max_len, uint32_t end_flag);
|
||||||
uint32_t user_char_tran_num(uint8_t *addr1, uint32_t over_len);
|
uint32_t user_char_tran_num(uint8_t *addr1, uint32_t over_len);
|
||||||
void user_num_tran_ascll_2(uint8_t *data1, uint8_t *data2, uint8_t data2_len);
|
void user_num_tran_ascll_2(uint8_t *data1, uint8_t *data2, uint8_t data2_len);
|
||||||
|
void user_num_tran_ascll_2_test(uint8_t *data1, uint8_t *data2, uint8_t data2_len);
|
||||||
uint8_t user_char_tran_numbuff_2(uint8_t *p_original,uint8_t *p_tran,uint8_t p_len);
|
uint8_t user_char_tran_numbuff_2(uint8_t *p_original,uint8_t *p_tran,uint8_t p_len);
|
||||||
uint8_t user_char_tran_numbuff_3(uint8_t *addr1, uint16_t p_len);
|
uint8_t user_char_tran_numbuff_3(uint8_t *addr1, uint16_t p_len);
|
||||||
uint8_t user_check_sum(uint8_t *buff, uint8_t len);
|
uint8_t user_check_sum(uint8_t *buff, uint8_t len);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* EEPROM芯片 */
|
||||||
#include "bsp_at24c512.h"
|
#include "bsp_at24c512.h"
|
||||||
|
|
||||||
extern iic_control_t iic_ctl_at24c;
|
extern iic_control_t iic_ctl_at24c;
|
||||||
|
|
|
@ -19,7 +19,6 @@ void mcu_eeprom_save(void)
|
||||||
//LOG_OUT("sizeof 1=%d\r\n", sizeof(i_set_mess));
|
//LOG_OUT("sizeof 1=%d\r\n", sizeof(i_set_mess));
|
||||||
//LOG_OUT("sizeof 2=%d\r\n", sizeof(ccbuff));
|
//LOG_OUT("sizeof 2=%d\r\n", sizeof(ccbuff));
|
||||||
|
|
||||||
|
|
||||||
memset(eeprom_buffer, 0x00, sizeof(eeprom_buffer));
|
memset(eeprom_buffer, 0x00, sizeof(eeprom_buffer));
|
||||||
memset(eeprom_buffer2, 0x00, sizeof(eeprom_buffer2));
|
memset(eeprom_buffer2, 0x00, sizeof(eeprom_buffer2));
|
||||||
|
|
||||||
|
@ -37,7 +36,6 @@ void mcu_eeprom_save(void)
|
||||||
eeprom_buffer[90] = crc8_crc8(eeprom_buffer, 88);
|
eeprom_buffer[90] = crc8_crc8(eeprom_buffer, 88);
|
||||||
eeprom_buffer[91] = crc8_crc8(eeprom_buffer, 88);
|
eeprom_buffer[91] = crc8_crc8(eeprom_buffer, 88);
|
||||||
|
|
||||||
|
|
||||||
LOG_OUT("\r\n");
|
LOG_OUT("\r\n");
|
||||||
for (uint8_t i = 0; i < EEPROM_DATA_SIZE; i++)
|
for (uint8_t i = 0; i < EEPROM_DATA_SIZE; i++)
|
||||||
{
|
{
|
||||||
|
@ -64,11 +62,7 @@ void mcu_eeprom_save(void)
|
||||||
LOG_OUT("\r\n");
|
LOG_OUT("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,9 +92,7 @@ void mcu_eeprom_power(void)
|
||||||
}
|
}
|
||||||
LOG_OUT("\r\n");
|
LOG_OUT("\r\n");
|
||||||
|
|
||||||
|
if ((eeprom_buffer[90] == crc8_crc8(eeprom_buffer, 88)) && (eeprom_buffer[0] == 0xAA) && (eeprom_buffer[1] == 0xBB))
|
||||||
if( (eeprom_buffer[90] == crc8_crc8(eeprom_buffer, 88)) &&
|
|
||||||
(eeprom_buffer[0] == 0xAA) && (eeprom_buffer[1] == 0xBB) )
|
|
||||||
{
|
{
|
||||||
LOG_OUT("eeprom data recover\r\n");
|
LOG_OUT("eeprom data recover\r\n");
|
||||||
|
|
||||||
|
@ -119,8 +111,6 @@ void mcu_eeprom_power(void)
|
||||||
iot_ctl.i_w_packet = 0;
|
iot_ctl.i_w_packet = 0;
|
||||||
iot_ctl.i_w_packet_alarm = 0;
|
iot_ctl.i_w_packet_alarm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -259,7 +259,7 @@ rt_size_t gas_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if(pos == GAS_AIR)
|
else if(pos == GAS_AIR) // 压力传感器
|
||||||
{
|
{
|
||||||
uint32_t temp1_pressure = 0;
|
uint32_t temp1_pressure = 0;
|
||||||
float temp2_pressure = 0;
|
float temp2_pressure = 0;
|
||||||
|
|
|
@ -32,7 +32,7 @@ rt_size_t water_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size
|
||||||
|
|
||||||
LOG_OUT("water=%x\r\n", water_state);
|
LOG_OUT("water=%x\r\n", water_state);
|
||||||
|
|
||||||
if( STATE_LID_READ == GPIO_PIN_SET)
|
if( STATE_LID_READ == GPIO_PIN_SET) // 井盖异动触发限位开关
|
||||||
{
|
{
|
||||||
water_state |= 0x02;
|
water_state |= 0x02;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue