当前位置:网站首页>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;
}边栏推荐
- 2021-10-27
- openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
- How does the memory database give full play to the advantages of memory?
- Fundamentals of Electronic Technology (III)_ Chapter 2 principle of amplification circuit__ Crystal triode and field effect triode
- Qt QComboBox QSS样式设置
- 内存数据库究竟是如何发挥内存优势的?
- You need to use MySQL in the opening experiment. How can you forget the basic select statement? Remedy is coming~
- Uniapp realizes global sharing of wechat applet and custom sharing button style
- Schematic diagram and connection method of six pin self-locking switch
- Blue Bridge Cup for migrant workers majoring in electronic information engineering
猜你喜欢
![[CSDN] C1 training problem analysis_ Part II_ Web Foundation](/img/91/72cdea3eb3f61315595330d2c9016d.png)
[CSDN] C1 training problem analysis_ Part II_ Web Foundation

我想各位朋友都应该知道学习的基本规律就是:从易到难

开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~

How does the memory database give full play to the advantages of memory?
![[CSDN] C1 training problem analysis_ Part IV_ Advanced web](/img/ee/2e9756cc0e2e6eda83e1b2304c0bd6.png)
[CSDN] C1 training problem analysis_ Part IV_ Advanced web

Working mode of 80C51 Serial Port
![Successful graduation [2] - student health management system function development...](/img/91/72cdea3eb3f61315595330d2c9016d.png)
Successful graduation [2] - student health management system function development...

UCI and data multiplexing are transmitted on Pusch - Part I

For new students, if you have no contact with single-chip microcomputer, it is recommended to get started with 51 single-chip microcomputer

03 FastJson 解决循环引用
随机推荐
UCI and data multiplexing are transmitted on Pusch - placement of data and UCI positions (Part III)
內存數據庫究竟是如何發揮內存優勢的?
Application of 51 single chip microcomputer timer
干单片机这一行的时候根本没想过这么多,只想着先挣钱养活自己
Project cost management__ Cost management technology__ Article 8 performance review
Gif image analysis drawing RGB to YUV table lookup method to reduce CPU occupancy
STM32 serial communication principle
Chromium Embedded Framework (CEF) 介绍
万字手撕七大排序(代码+动图演示)
Oracle database SQL statement execution plan, statement tracking and optimization instance
A lottery like scissors, stone and cloth (C language)
[22 graduation season] I'm a graduate yo~
[untitled] proteus simulation of traffic lights based on 89C51 Single Chip Microcomputer
51 MCU tmod and timer configuration
Characteristics of PUCCH formats
Eight working modes of stm32gpio and chip naming rules
PIP references domestic sources
2020-08-23
Idea remote breakpoint debugging jar package project
STM32 interrupt switch