提交SMOD ATSC IMX APP版本 V122

This commit is contained in:
2026-07-16 14:35:59 +08:00
commit 7601c270d5
485 changed files with 255032 additions and 0 deletions
+129
View File
@@ -0,0 +1,129 @@
/*
@STAY_FINAL_PROC:
*/
#include "lwip/ip_addr.h"
#include "sntp.h"
#include "type.h"
#include "sntp_task.h"
#include "lcd_task.h"
#include "os_task.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "dns.h"
extern void SNTP_REQ(void);
extern void delay_ms(uint32 nms);
int getNowTime(void)
{
//atsc_para.system_para.sntp_date
#if 0
time_t now = 0;
struct tm timeinfo = { 0 };
char strftime_buf[72];
time(&now); //获取网络时间, 64bit的秒计数
localtime_r(&now, &timeinfo); //转换成具体的时间参数
// strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
return timeinfo;
#endif
return 0;
}
void sntpService(uint8 *pAddr)
{
ip_addr_t sip;
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sip.addr = pAddr[0]<<24|pAddr[1]<<16|pAddr[2]<<8|pAddr[3]<<0;
sntp_setserver(0, &sip);
sntp_init();
}
void stopSNTP(void)
{
sntp_stop();
}
int sntp_enable(uint8 en, uint8 *pAddr)
{
if(en>1)
en = 0;
if(NULL ==pAddr)
return -1;
stopSNTP();
if(1 == en)
sntpService(pAddr);
return 0;
}
void dnsStart(uint8 *pdns)
{
ip_addr_t serverip;
serverip.addr =pdns[0]<<24|pdns[1]<<16|pdns[2]<<8|pdns[3]<<0;
dns_setserver(0, &serverip);
dns_init();
}
void sntp_restart(void)
{
static uint8 cnt = 0;
if(cnt++>10)
{
cnt = 0;
sntp_enable(1, atsc_para.system_para.sntp_sip);
}
}
void sntp_task(void * pvParameters)
{
MSG *pmsg = NULL;
config_time_msg(MSG_SEC);
sntpService(atsc_para.system_para.sntp_sip);
while((pmsg = get_msg(OS_WAIT_FOREVER))!=NULL)
{
switch(pmsg->type)
{
case MSG_SEC:
task_is_ok(); //任务正常工作
sntp_restart();
break;
default:
break;
}
if(MSG_NEED_TO_FREE(pmsg))
free_msg(pmsg);
}
}