本文主要是介绍Phicomm DC1斐讯插座固件编译NONOS SDK MQTT实现远程控制电量采集,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、芯海 CSE7766 单相多功能计量芯片 波特率4800bps 8 1 none none
u8 over=0;
u16 over_counter=0;
u8 data20=0;
void dc1_uart_data_handler(u8* data,u16 data_len){u8 i = 0;u32 coefficient = 0;u32 period = 0;u16 checkpack = 0;if (data[1] == 0x5A){for(i=2;i<23;i++)checkpack += data[i];checkpack &= 0xFF;if (checkpack == data[23]){for (i = 0; i < 3; i++){coefficient = data[2+6*i];coefficient <<= 8;coefficient |= data[3+6*i];coefficient <<= 8;coefficient |= data[4+6*i];period = data[5+6*i];period <<= 8;period |= data[6]+6*i;period <<= 8;period |= data[7+6*i];electric_data[i] = (coefficient*10)/period;}data20=data[20];data20>>=7;if(data20==over){}else{over=data20;over_counter++;}power_data[0]=over_counter;power_data[1]=data[21]<<8;power_data[1]=power_data[1]|data[22];}}
}void ICACHE_FLASH_ATTR get_electric_data(uint16_t *recv_data){uint8_t i = 0;for(i = 0; i < 3; i++)*(recv_data+i) = electric_data[i];
}
void ICACHE_FLASH_ATTR get_power_data(uint16_t *recv_data){uint8_t i = 0;for(i = 0; i < 3; i++)*(recv_data+i) = power_data[i];
}
2、OTA
ota_upgrade(char *url, upgrade_states_check_callback ota_check_cb)
3、make
BOOT?=new
APP?=2
SPI_SPEED?=40
SPI_MODE?=QIO
SPI_SIZE_MAP?=4
4、Flash
(1)、4MB
(2)、2MB
Enjoy
这篇关于Phicomm DC1斐讯插座固件编译NONOS SDK MQTT实现远程控制电量采集的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!