当前位置:网站首页>4G module initialization of charge point design
4G module initialization of charge point design
2022-07-03 09:59:00 【Wukong is so timid】
int dx_lte_init_check(void)
{
//rx at command response from 4g module
//printf("uart2 rx at command *ext* response from 4g moduler\r\n");
//uart2_dma_send_data("uart2_dma_send test\r\n",strlen("uart2_dma_send test\r\n"));
uint32_t flags = 0;
flags = EVENT_FLAGS_UART2|EVENT_FLAGS_UART2_TX_COMPLETE;
printf("*****dx_lte_init_check\r\n");
flags = osEventFlagsWait(evt_id_uart, flags, osFlagsWaitAny, osWaitForever);
printf("*****dx_lte_init_check cb osEventFlagsWait flags =0x%08x\r\n",flags);
if(status_4g == -1)
{
uint8_t rcv_buf[30]= {0};
uint8_t rcv_len = 0;
int ret = 0;
uart2_rec_at_cmd_response(rcv_buf,&rcv_len);
printf("rcv_buf=%s rcv_len=%d\r\n",rcv_buf,rcv_len);
ret=strncmp(( const char *)rcv_buf,MODULE_4G_PDPDEACT,strlen(MODULE_4G_PDPDEACT));
if(ret==0)
{
printf("***MODULE_4G_PDPDEACT****\r\n");
}
ret=strncmp(( const char *)rcv_buf,MODULE_4G_POWER_OK,strlen(MODULE_4G_POWER_OK));
//+QIURC: "pdpdeact",1
if(ret==0)
{
app4g_reset_ok_time();
char buffer[22]= {0};
#if (TIME_VALID_JUDGE == 1)
myst *pt;
myst src_pt;
myst dst_pt;
#endif
char times =3;
status_4g =1;
printf("MODULE_4G_POWER_OK\r\n");
printf("dx_set_lte_ate0\r\n");
dx_set_lte_ate0();
while(1)
{
ret = dx_get_lte_pinState();
if(ret ==0)
break;
else
{
printf("please insert sim card %d\r\n",ret);
osDelay(2000);
}
}
dx_get_lte_network(buffer,sizeof(buffer));
printf("dx_get_lte_network=%d %s\r\n",ret,buffer);
times = 0;
while(1)
{
times ++;
osDelay(2000);
ret = dx_get_lte_network_resiger_status();
printf("dx_get_lte_network_resiger_status times=%d =%d\r\n",times,ret);
if(ret ==1)
break;
}
ret = dx_get_lte_signalQuality();
printf("dx_get_lte_signalQuality=%d\r\n",ret);
app4g_run_ok_time();
dx_get_lte_imei();
dx_get_lte_qiact();
//dx_set_lte_pdp();
dx_set_lte_ntp_server();
times =3;
while(times--)
{
osDelay(200);
ret = dx_get_lte_ntp_time(buffer,22);
if(ret == 0)
{
printf("dx_get_lte_ntp_time %d=%d %s\r\n",times,ret,buffer);
break;
}
}
if(ret != 0)
{
printf("ntp server synv fail\r\n");
// continue;
}
pt= &src_pt;
mytransfor(buffer,pt);
printf("src year:%d mon:%d day:%d hour:%d min:%d sec:%d tzone:%d\r\n", \
pt->year,pt->mon,pt->day,pt->hour,pt->min,pt->sec,pt->tzone);
#if (STM_RTC_ENABLE == 1)
rtc_set_cnt(time_hms2s(pt->hour+pt->tzone,pt->min,pt->sec));
SetDate(pt->day,pt->mon,pt->year);
#endif
time_t seconds = 0;
time_t src_seconds = 0;
struct tm dst_tm= {0};
struct tm *tm_now;
dst_tm.tm_sec =pt->sec;
dst_tm.tm_min =pt->min;
dst_tm.tm_hour =pt->hour;
dst_tm.tm_mday =pt->day;
dst_tm.tm_mon =pt->mon;
dst_tm.tm_year = pt->year+2000-1900;
src_seconds=mktime(&dst_tm);
printf("unix cur timestamp:%08x \r\n",src_seconds);
tm_now = localtime(&src_seconds);
printf("cur tm_now =%d-%d-%d %d:%d:%d \r\n", \
tm_now->tm_year+1900, tm_now->tm_mon, tm_now->tm_mday, \
tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec);
pt= &dst_pt;
mytransfor(DEAD_TIME,pt);
printf("dst year:%d mon:%d day:%d hour:%d min:%d sec:%d tzone:%d\r\n", \
pt->year,pt->mon,pt->day,pt->hour,pt->min,pt->sec,pt->tzone);
//seconds = time(NULL);
tm_now = localtime(&seconds);
printf("tm_now =%d-%d-%d %d:%d:%d \r\n", \
tm_now->tm_year, tm_now->tm_mon, tm_now->tm_mday, \
tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec);
//tm_now =70-0-1 0:0:0
// from 1970 year 1 month 1 Japan 0 when 0 branch 0 Seconds to this time .
#if 0
struct tm {
int tm_sec; /* second – The value range is [0,59] */
int tm_min; /* branch - The value range is [0,59] */
int tm_hour; /* when - The value range is [0,23] */
int tm_mday; /* The date of the month - The value range is [1,31] */
int tm_mon; /* month ( From January on ,0 For January ) - The value range is [0,11] */
int tm_year; /* year , Its value is equal to the actual year minus 1900 */
int tm_wday; /* week – The value range is [0,6], among 0 For Sunday ,1 On behalf of Monday */
int tm_yday; /* From every year 1 month 1 The number of days the day begins – Value range [0,365], among 0 representative 1 month 1 Japan */
int tm_isdst; /* Daylight saving time identifier , Daylight saving time tm_isdst Being positive ; No daylight saving time tm_isdst by 0 */
};
#endif
dst_tm.tm_sec =pt->sec;
dst_tm.tm_min =pt->min;
dst_tm.tm_hour =pt->hour;
dst_tm.tm_mday =pt->day;
dst_tm.tm_mon =pt->mon;
dst_tm.tm_year = pt->year+2000-1900;
seconds=mktime(&dst_tm);
printf("unix timestamp:%08x \r\n",seconds);
tm_now = localtime(&seconds);
printf("tm_now =%d-%d-%d %d:%d:%d \r\n", \
tm_now->tm_year+1900, tm_now->tm_mon, tm_now->tm_mday, \
tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec);
#if (TIME_VALID_JUDGE == 1)
if(src_seconds > seconds)
{
printf("mcu_sys_soft_reset,please Pay \r\n");
osDelay(20000);
mcu_sys_soft_reset();
while(1);
}
#endif
module4g_init =1;
//dx_get_lte_imei();
//mqtt_set(g_imei);
//app_mqtt_init();
}
}
//else
// uart2_rec_at_cmd_response(NULL,NULL);
return 0;
}
边栏推荐
- Oracle database SQL statement execution plan, statement tracking and optimization instance
- STM32 general timer output PWM control steering gear
- Eight working modes of stm32gpio and chip naming rules
- Oracle数据库 SQL语句执行计划、语句跟踪与优化实例
- PIP references domestic sources
- 开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
- 学习开发没有捷径,也几乎不存在带路会学的快一些的情况
- Not many people can finally bring their interests to college graduation
- Stm32f04 clock configuration
- Qt QComboBox QSS样式设置
猜你喜欢
UCI and data multiplexing are transmitted on Pusch - determine the bit number of harqack, csi1 and csi2 (Part II)
UCI and data multiplexing are transmitted on Pusch (Part VI) -- LDPC coding
JS基础-原型原型链和宏任务/微任务/事件机制
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
Eight working modes of stm32gpio and chip naming rules
单片机现在可谓是铺天盖地,种类繁多,让开发者们应接不暇
Stm32f407 key interrupt
Nr--- Pusch I: sorting out the agreement process
uniapp 实现微信小程序全局分享及自定义分享按钮样式
Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction
随机推荐
IDEA远程断点调试jar包项目
JS基础-原型原型链和宏任务/微任务/事件机制
一个可执行的二进制文件包含的不仅仅是机器指令
Project cost management__ Cost management technology__ Article 6 prediction
要選擇那種語言為單片機編寫程序呢
A lottery like scissors, stone and cloth (C language)
Fundamentals of Electronic Technology (III)__ Logic gate symbols in Chapter 5
[male nanny style] teach you to open the first wechat applet
Raspberry pie installation SciPy
01 business structure of imitation station B project
STM32 external interrupt experiment
我想各位朋友都应该知道学习的基本规律就是:从易到难
01仿B站项目业务架构
Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
CEF下载,编译工程
[CSDN] C1 training problem analysis_ Part IV_ Advanced web
应用最广泛的8位单片机当然也是初学者们最容易上手学习的单片机
Idea remote breakpoint debugging jar package project
2. Elment UI date selector formatting problem
Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction