加了关闭射频指令等操作
This commit is contained in:
parent
ded3695626
commit
07805ed850
|
@ -60,5 +60,6 @@
|
|||
"completion.h": "c",
|
||||
"bsp_vin_detection.h": "c",
|
||||
"ulog_def.h": "c"
|
||||
}
|
||||
},
|
||||
"commentTranslate.multiLineMerge": true
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#define MAX_EXPIRATION_YEARS (10U)
|
||||
#define MAX_EXPIRATION_DAYS (365 * MAX_EXPIRATION_YEARS + 30 * 3U)
|
||||
|
||||
#define SYS_HW_VERSION (0X10U)
|
||||
#define SYS_SW_VERSION (0X13U)
|
||||
#define SYS_HW_VERSION (0X22U)
|
||||
#define SYS_SW_VERSION (0X14U)
|
||||
#define SYS_IOT_UPLOAD_CYCLE_MIN (0X3C00U) // 高位在前,低位在后
|
||||
#define SYS_IOT_RETRY (0X03U)
|
||||
#define SYS_TEMP_ALARM_THRESHOLD (0X30U)
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* @Author: mbw
|
||||
* @Date: 2024-10-09 08:42:14
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2024-12-23 09:43:40
|
||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-4G\bsp\inc\bsp_beep.h
|
||||
* @LastEditTime: 2025-01-17 10:38:49
|
||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\inc\bsp_beep.h
|
||||
* @Description:
|
||||
* @
|
||||
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||
|
@ -54,19 +54,19 @@ extern agile_led_t *beep;
|
|||
BEEP_START; \
|
||||
} while (0U)
|
||||
|
||||
// #define BEEP_ALARM \
|
||||
// do \
|
||||
// { \
|
||||
// BEEP_STOP; \
|
||||
// BEEP_CTRL("200,200", -1); \
|
||||
// BEEP_START; \
|
||||
// } while (0U)
|
||||
#define BEEP_ALARM \
|
||||
do \
|
||||
{ \
|
||||
BEEP_STOP; \
|
||||
BEEP_ON; \
|
||||
BEEP_CTRL("200,200", -1); \
|
||||
BEEP_START; \
|
||||
} while (0U)
|
||||
// #define BEEP_ALARM \
|
||||
// do \
|
||||
// { \
|
||||
// BEEP_STOP; \
|
||||
// BEEP_ON; \
|
||||
// } while (0U)
|
||||
// 3s
|
||||
#define BEEP_SELF_CHECK \
|
||||
do \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author : stark1898y 1658608470@qq.com
|
||||
* @Date : 2024-09-04 13:33:49
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2025-01-15 09:27:15
|
||||
* @LastEditTime: 2025-01-17 10:22:34
|
||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\at_device_nt26k.c
|
||||
* @Description :
|
||||
*
|
||||
|
@ -84,34 +84,43 @@ static int nt26k_power_on (struct at_device *device)
|
|||
struct at_device_nt26k *nt26k = RT_NULL;
|
||||
|
||||
nt26k = (struct at_device_nt26k *)device->user_data;
|
||||
nt26k->power_status = RT_TRUE;
|
||||
|
||||
/* not nead to set pin configuration for nt26k device power on */
|
||||
if (nt26k->pwr_en_pin == -1)
|
||||
{
|
||||
return (RT_EOK);
|
||||
}
|
||||
|
||||
rt_pin_write (nt26k->pwr_en_pin, PIN_LOW);
|
||||
rt_thread_mdelay (10);
|
||||
rt_pin_write (nt26k->pwr_en_pin, PIN_HIGH);
|
||||
return (RT_EOK);
|
||||
|
||||
return device->class->device_ops->control (device, AT_DEVICE_CTRL_WAKEUP, RT_NULL);
|
||||
}
|
||||
|
||||
static rt_err_t nt26k_power_off (struct at_device *device)
|
||||
{
|
||||
struct at_device_nt26k *nt26k = RT_NULL;
|
||||
|
||||
nt26k = (struct at_device_nt26k *)device->user_data;
|
||||
if (nt26k->power_status != RT_FALSE)
|
||||
{
|
||||
rt_pin_mode (nt26k->pwr_en_pin, PIN_MODE_OUTPUT);
|
||||
rt_pin_write (nt26k->pwr_en_pin, PIN_LOW);
|
||||
}
|
||||
|
||||
device->class->device_ops->control (device, AT_DEVICE_RF_CLOSE, RT_NULL);
|
||||
|
||||
rt_pin_write (nt26k->pwr_en_pin, PIN_LOW);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t nt26k_Close_Rf (struct at_device *device)
|
||||
{
|
||||
at_response_t resp = at_create_resp (64, 0, rt_tick_from_millisecond (60000));
|
||||
if (resp == RT_NULL)
|
||||
{
|
||||
LOG_D ("no memory for resp create.");
|
||||
at_delete_resp (resp);
|
||||
return (-RT_ERROR);
|
||||
}
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QPOWD=1") == RT_EOK)
|
||||
{
|
||||
at_delete_resp (resp);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
return (-RT_ERROR);
|
||||
}
|
||||
#ifdef TEST_ENABLE
|
||||
void TEST_Nt26k_Reset()
|
||||
{
|
||||
|
@ -405,10 +414,7 @@ int nt26k_check_link_status (struct at_device *device)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,600,100,6") != RT_EOK) // 保活期为最大30min,故30min重设一下
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
}
|
||||
|
||||
at_delete_resp (resp);
|
||||
|
||||
return (result);
|
||||
|
@ -528,6 +534,7 @@ static int nt26k_netdev_set_up (struct netdev *netdev)
|
|||
struct at_device *device = RT_NULL;
|
||||
|
||||
device = at_device_get_by_name (AT_DEVICE_NAMETYPE_NETDEV, netdev->name);
|
||||
LOG_D("netdev->name:%s",netdev->name);
|
||||
if (device == RT_NULL)
|
||||
{
|
||||
LOG_E ("get device(%s) failed.", netdev->name);
|
||||
|
@ -760,9 +767,9 @@ static struct netdev *nt26k_netdev_add (const char *netdev_name)
|
|||
static void nt26k_init_thread_entry (void *parameter)
|
||||
{
|
||||
#define INIT_RETRY 5
|
||||
#define CPIN_RETRY 10
|
||||
#define CSQ_RETRY 20
|
||||
#define CEREG_RETRY 50
|
||||
#define CPIN_RETRY 20
|
||||
#define CSQ_RETRY 30
|
||||
#define CEREG_RETRY 60
|
||||
#define IPADDR_RETRY 10
|
||||
|
||||
int i;
|
||||
|
@ -784,11 +791,10 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
while (1)
|
||||
{
|
||||
/* power on the nt26k device */
|
||||
nt26k_power_off (device);
|
||||
device->class->device_ops->control (device, AT_DEVICE_CTRL_POWER_ON, RT_NULL);
|
||||
rt_thread_mdelay (100);
|
||||
nt26k_power_on (device);
|
||||
rt_thread_mdelay (100);
|
||||
/* wait nt26k startup finish, send AT every 500ms, if receive OK, SYNC success*/
|
||||
/* wait nt26k startup finish, send AT every 500ms, if recei
|
||||
ve OK, SYNC success*/
|
||||
if (at_client_obj_wait_connect (client, NT26K_WAIT_CONNECT_TIME))
|
||||
{
|
||||
result = -RT_ETIMEOUT;
|
||||
|
@ -810,19 +816,6 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
{
|
||||
LOG_D ("%s", at_resp_get_line (resp, i + 1));
|
||||
}
|
||||
|
||||
/* disable sleep mode */
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+ECPMUCFG=1,0") != RT_EOK)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
/* disable PSM mode */
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+CPSMS=0") != RT_EOK)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
/*AT+QICFG="dataformat" 设置收发模式*/
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QICFG=\"dataformat\",%d,%d", AT_NSONMI_MODE_DEFAULT, AT_NSONMI_MODE_DEFAULT) != RT_EOK)
|
||||
{
|
||||
|
@ -836,7 +829,7 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
goto __exit;
|
||||
}
|
||||
/*设置保活信息*/
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,1800,50,5") != RT_EOK)
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,10000,100,10") != RT_EOK)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
|
@ -862,8 +855,7 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
/* set network interface device hardware address(IMEI) */
|
||||
/* set etwork interface device hardware address(IMEI) */
|
||||
if ((*(rt_uint16_t *)FLASH_IOT_IMEI_ADDR == 0xE339) || (*(rt_uint16_t *)FLASH_IOT_IMEI_ADDR == 0x39E3)) // 未写入
|
||||
{
|
||||
#define NT26K_NETDEV_HWADDR_LEN 8
|
||||
|
@ -882,7 +874,6 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
LOG_D ("%s device IMEI number: %s", device->name, imei);
|
||||
|
||||
rt_memcpy (nt26k.imei, imei, NT26K_IMEI_LEN);
|
||||
|
@ -890,9 +881,10 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
}
|
||||
else
|
||||
{
|
||||
Get_IotImei((char *)nt26k.imei, NT26K_IMEI_LEN);
|
||||
rt_memset((char *)nt26k.imei, 0, NT26K_IMEI_LEN);
|
||||
Get_IotImei((char *)&nt26k.imei[0], NT26K_IMEI_LEN);
|
||||
}
|
||||
rt_thread_mdelay (1);
|
||||
rt_thread_mdelay (10);
|
||||
/* set network interface device hardware iccid */
|
||||
if ((*(rt_uint16_t *)FLASH_IOT_ICCID_ADDR == 0xE339) || (*(rt_uint16_t *)FLASH_IOT_ICCID_ADDR == 0x39E3)) // 未写入
|
||||
{
|
||||
|
@ -919,10 +911,12 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
rt_memcpy (nt26k.iccid, iccid, NT26K_ICCID_LEN);
|
||||
Flash_Sys_Cfg (kIotIccidId, nt26k.iccid, NT26K_ICCID_LEN);
|
||||
}
|
||||
else {
|
||||
Get_IotIccid((char *)nt26k.iccid, NT26K_ICCID_LEN);
|
||||
else
|
||||
{
|
||||
rt_memset((char *)nt26k.iccid, 0, NT26K_ICCID_LEN);
|
||||
Get_IotIccid((char *)&nt26k.iccid[0], NT26K_ICCID_LEN);
|
||||
}
|
||||
rt_thread_mdelay (1);
|
||||
rt_thread_mdelay (10);
|
||||
/* set network interface device hardware imsi */
|
||||
if ((*(rt_uint16_t *)FLASH_IOT_IMSI_ADDR == 0xE339) || (*(rt_uint16_t *)FLASH_IOT_IMSI_ADDR == 0x39E3)) // 未写入
|
||||
{
|
||||
|
@ -949,65 +943,47 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
rt_memcpy (nt26k.imsi, imsi, NT26K_IMSI_LEN);
|
||||
Flash_Sys_Cfg (kIotImsiId, nt26k.imsi, NT26K_IMSI_LEN);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
//已经写入了,将其赋值给结构体
|
||||
Get_IotImei((char *)nt26k.imsi, FLASH_IOT_IMEI_LEN);
|
||||
rt_memset((char *)nt26k.imsi, 0, NT26K_IMSI_LEN);
|
||||
Get_IotImei((char *)&nt26k.imsi[0], NT26K_IMSI_LEN);
|
||||
|
||||
}
|
||||
rt_thread_mdelay (1);
|
||||
/*网络注册 */
|
||||
rt_thread_mdelay (10);
|
||||
/* check signal strength */
|
||||
for (i = 0; i < CSQ_RETRY; i++)
|
||||
{
|
||||
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+CREG=2") == RT_EOK)
|
||||
{
|
||||
if (at_resp_get_line_by_kw (resp, "OK") > 0)
|
||||
{
|
||||
LOG_D ("%s device network registration success.", device->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
rt_thread_mdelay (1000);
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+CSQ") == RT_EOK)
|
||||
{
|
||||
int signal_strength = 0, err_rate = 0;
|
||||
|
||||
if (at_resp_parse_line_args_by_kw(resp, "+CSQ:", "+CSQ: %d,%d", &signal_strength, &err_rate) > 0)
|
||||
{
|
||||
if ((signal_strength != 99) && (signal_strength != 0))
|
||||
{
|
||||
LOG_D("%s device signal strength: %d, channel bit err_rate: %d",
|
||||
device->name, signal_strength, err_rate);
|
||||
nt26k.rssi = signal_strength;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rt_thread_mdelay(1000);
|
||||
}
|
||||
if (i == CSQ_RETRY)
|
||||
{
|
||||
LOG_D ("%s device network registration failed.", device->name);
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
LOG_E("%s device signal strength check failed", device->name);
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
// /* check signal strength */
|
||||
// for (i = 0; i < CSQ_RETRY; i++)
|
||||
// {
|
||||
|
||||
// if (at_obj_exec_cmd(device->client, resp, "AT+CSQ") == RT_EOK)
|
||||
// {
|
||||
// int signal_strength = 0, err_rate = 0;
|
||||
|
||||
// if (at_resp_parse_line_args_by_kw(resp, "+CSQ:", "+CSQ: %d,%d", &signal_strength, &err_rate) > 0)
|
||||
// {
|
||||
// if ((signal_strength != 99) && (signal_strength != 0))
|
||||
// {
|
||||
// LOG_D("%s device signal strength: %d, channel bit err_rate: %d",
|
||||
// device->name, signal_strength, err_rate);
|
||||
// nt26k.rssi = signal_strength;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// rt_thread_mdelay(1000);
|
||||
// }
|
||||
// if (i == CSQ_RETRY)
|
||||
// {
|
||||
// LOG_E("%s device signal strength check failed", device->name);
|
||||
// result = -RT_ERROR;
|
||||
// goto __exit;
|
||||
// }
|
||||
|
||||
/* check the GPRS network is registered */
|
||||
for (i = 0; i < CEREG_RETRY; i++)
|
||||
{
|
||||
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+CEREG?") == RT_EOK)
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+CEREG?") == RT_EOK)//60s内注册CS业务
|
||||
{
|
||||
int link_stat = 0;
|
||||
|
||||
|
@ -1019,23 +995,29 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
rt_thread_mdelay (1000);
|
||||
}
|
||||
for (i = 0; i < CEREG_RETRY; i++)
|
||||
{
|
||||
if (i == CEREG_RETRY)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
// for (i = 0; i < CEREG_RETRY; i++)
|
||||
// {
|
||||
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QICSGP=1,1,\"cmnet\",\"\",\"\",1") == RT_EOK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
rt_thread_mdelay (20000);
|
||||
}
|
||||
if (i == CEREG_RETRY)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
// if (at_obj_exec_cmd (device->client, resp, "AT+QICSGP=1,1,\"cmnet\",\"\",\"\",1") == RT_EOK)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// rt_thread_mdelay (20000);
|
||||
// }
|
||||
// if (i == CEREG_RETRY)
|
||||
// {
|
||||
// result = -RT_ERROR;
|
||||
// goto __exit;
|
||||
// }
|
||||
for (i = 0; i < CEREG_RETRY; i++)
|
||||
{
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=1,1") == RT_EOK)
|
||||
|
@ -1043,7 +1025,15 @@ static void nt26k_init_thread_entry (void *parameter)
|
|||
LOG_D ("pdp激活成功");
|
||||
break;
|
||||
}
|
||||
rt_thread_mdelay (20000);
|
||||
else {
|
||||
// AT+CGACT=0,1 //去激活 PDP
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=0,1") == RT_EOK)
|
||||
{
|
||||
LOG_D ("pdp去激活成功");
|
||||
|
||||
}
|
||||
}
|
||||
rt_thread_mdelay (5000);
|
||||
}
|
||||
if (i == CEREG_RETRY)
|
||||
{
|
||||
|
@ -1080,9 +1070,8 @@ __exit:
|
|||
if (result != RT_EOK)
|
||||
{
|
||||
/* power off the nt26k device */
|
||||
// nt26k_power_off(device);
|
||||
nt26k_power_off(device);
|
||||
rt_thread_mdelay (1000);
|
||||
|
||||
LOG_I ("%s device initialize retry...", device->name);
|
||||
}
|
||||
}
|
||||
|
@ -1105,6 +1094,7 @@ __exit:
|
|||
{
|
||||
LOG_E ("%s device network initialize failed(%d).", device->name, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* nt26k device network initialize */
|
||||
|
@ -1371,6 +1361,9 @@ static int nt26k_control (struct at_device *device, int cmd, void *arg)
|
|||
case AT_DEVICE_CTRL_POWER_OFF:
|
||||
result = nt26k_power_off (device);
|
||||
break;
|
||||
case AT_DEVICE_RF_CLOSE:
|
||||
result = nt26k_Close_Rf(device);
|
||||
break;
|
||||
case AT_DEVICE_CTRL_LOW_POWER:
|
||||
case AT_DEVICE_CTRL_SET_WIFI_INFO:
|
||||
case AT_DEVICE_CTRL_GET_GPS:
|
||||
|
|
|
@ -140,11 +140,13 @@ static rt_size_t Flash_Read (rt_uint32_t addr, rt_uint8_t *buf, rt_size_t len)
|
|||
|
||||
int Get_IotImei (char *buf, rt_size_t len)
|
||||
{
|
||||
|
||||
if ((*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0x39))
|
||||
{
|
||||
rt_memcpy (buf, (char *)FLASH_IOT_IMEI_ADDR, len);
|
||||
|
||||
LOG_D ("IOT IMEI: %s", buf);
|
||||
char imei_buf[FLASH_IOT_IMEI_LEN]={0};
|
||||
Flash_Read(FLASH_IOT_IMEI_ADDR, imei_buf, len);
|
||||
LOG_D ("read imei: %s", imei_buf);
|
||||
rt_memcpy(buf, imei_buf, len);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -163,9 +165,11 @@ int Get_IotImsi (char *buf, rt_size_t len)
|
|||
{
|
||||
if ((*(rt_uint8_t *)FLASH_IOT_IMSI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMSI_ADDR != 0x39))
|
||||
{
|
||||
rt_memcpy (buf, (char *)FLASH_IOT_IMSI_ADDR, len);
|
||||
char imsi_buf[FLASH_IOT_IMSI_LEN]={0};
|
||||
Flash_Read(FLASH_IOT_IMSI_ADDR, imsi_buf, len);
|
||||
LOG_D ("read imsi: %s", imsi_buf);
|
||||
rt_memcpy(buf, imsi_buf, len);
|
||||
|
||||
LOG_D ("IOT IMSI: %s", buf);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -184,9 +188,10 @@ int Get_IotIccid (char *buf, rt_size_t len)
|
|||
{
|
||||
if ((*(rt_uint8_t *)FLASH_IOT_ICCID_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_ICCID_ADDR != 0x39))
|
||||
{
|
||||
rt_memcpy (buf, (char *)FLASH_IOT_ICCID_ADDR, len);
|
||||
|
||||
LOG_D ("IOT ICCID: %s", buf);
|
||||
char iccid_buf[FLASH_IOT_ICCID_LEN]={0};
|
||||
Flash_Read(FLASH_IOT_ICCID_ADDR, iccid_buf, len);
|
||||
LOG_D ("read iccid: %s", iccid_buf);
|
||||
rt_memcpy(buf, iccid_buf, len);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -792,7 +797,7 @@ int BSP_Flash_Init (void)
|
|||
LOG_D ("Flash_Set_Sever_Data error!");
|
||||
}
|
||||
|
||||
Flash_SetProductTimeLimit (2025, 1, 10, 13, 50, 20, kFactoryTimeId);
|
||||
Flash_SetProductTimeLimit (2025, 1, 15, 13, 50, 20, kFactoryTimeId);
|
||||
Set_ExpirationTime (MAX_EXPIRATION_DAYS);
|
||||
|
||||
sci.hw_ver = SYS_HW_VERSION;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: mbw
|
||||
* @Date: 2024-10-09 08:42:14
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2025-01-10 13:09:30
|
||||
* @LastEditTime: 2025-01-17 10:37:54
|
||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_nt26k.c
|
||||
* @Description:
|
||||
*
|
||||
|
@ -815,6 +815,13 @@ int Nt26k_Process_Events (Nt26kEvent nt26k_recv_event, struct at_device *device,
|
|||
continue;
|
||||
}
|
||||
}
|
||||
else if (rt_strcmp (event->event_name, "掉电事件") == RT_EOK)//定时心跳是有回应的
|
||||
{
|
||||
if (device->class->device_ops->control (device, AT_DEVICE_RF_CLOSE, RT_NULL) == RT_EOK)
|
||||
{
|
||||
LOG_D("关闭模组");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return RT_EOK; // 函数执行完毕,返回0
|
||||
|
@ -1415,6 +1422,8 @@ static void Nt26k_Life_Thread_Entry (void *parameter)
|
|||
struct at_device *device = at_device_get_by_name (AT_DEVICE_NAMETYPE_NETDEV, nt26k->device_name);
|
||||
RT_ASSERT (device);
|
||||
rt_err_t ret;
|
||||
rt_uint32_t delay_n = 1;
|
||||
rt_uint32_t delay_t = 80000;
|
||||
|
||||
LOG_D ("nt26k_life_thread entry\n");
|
||||
|
||||
|
@ -1439,7 +1448,6 @@ static void Nt26k_Life_Thread_Entry (void *parameter)
|
|||
if (device->class->device_ops->control (device, AT_DEVICE_CTRL_POWER_ON, RT_NULL) == RT_EOK)
|
||||
{
|
||||
LOG_D("AT device power on success");
|
||||
rt_thread_mdelay(1000);
|
||||
/* disable echo */
|
||||
at_obj_exec_cmd(device->client, resp, "ATE0");
|
||||
/*AT+QICFG="dataformat" 设置收发模式*/
|
||||
|
@ -1453,7 +1461,7 @@ static void Nt26k_Life_Thread_Entry (void *parameter)
|
|||
LOG_E ("AT+QICFG=\"viewmode\" error\n");
|
||||
}
|
||||
/*设置保活信息*/
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,1800,100,3") != RT_EOK)
|
||||
if (at_obj_exec_cmd (device->client, resp, "AT+QICFG=\"tcp/keepalive\",1,10000,100,10") != RT_EOK)
|
||||
{
|
||||
LOG_E ("AT+QICFG=\"tcp/keepalive\" error\n");
|
||||
}
|
||||
|
@ -1469,21 +1477,29 @@ static void Nt26k_Life_Thread_Entry (void *parameter)
|
|||
{
|
||||
LOG_D ("重连网络成功\n");
|
||||
nt26k_conncet_tcp_flag = RT_TRUE;
|
||||
delay_n =0;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_D ("重连网络失败,等待 10s 后重连\n");
|
||||
rt_thread_mdelay (10000);
|
||||
delay_t = (rt_uint32_t)(2^(delay_n - 1) * delay_t);
|
||||
LOG_D ("重连网络失败,等待%d s后重连\n", delay_t);
|
||||
rt_thread_mdelay (delay_t);
|
||||
delay_n++;
|
||||
rt_sem_release (nt26k_disconnect_sem);
|
||||
}
|
||||
at_delete_resp (resp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delay_n = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 定时器回调函数,当1分钟内没有数据交互时,关闭tcp连接
|
||||
static void Nt26k_Upload_Timer_Cb (void *parameter)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#define LOG_LVL LOG_LVL_DBG // 该模块对应的日志输出级别。不定义时,默认:调试级别
|
||||
#include <ulog.h>
|
||||
|
||||
#define RTC_FIRST_INIT_VALUE (0x1314)
|
||||
#define RTC_FIRST_INIT_VALUE (0x1319)
|
||||
|
||||
TsRtcDateTime RtcDateTime;
|
||||
|
||||
|
@ -287,31 +287,12 @@ static uint8_t RTC_FirstInit(void)
|
|||
RTC_SetPrescaler(32767);
|
||||
RTC_WaitForLastTask();
|
||||
|
||||
RTC_SetTime(2025, 1, 8, 12, 0, 0); //设置出厂日期
|
||||
RTC_SetTime(2025, 1, 17, 14, 31, 21);
|
||||
RTC_WaitForLastTask();
|
||||
//
|
||||
// RTC_SetAlarm(20 + RTC_GetCounter()); //闹钟值设定为当前时间的10秒后
|
||||
// RTC_WaitForLastTask();
|
||||
//
|
||||
// RTC_ExitConfigMode(); //退出配置模式
|
||||
|
||||
// RTC_ITConfig(RTC_IT_ALR, ENABLE);
|
||||
// RTC_ITConfig(RTC_IT_SEC, ENABLE);
|
||||
// RTC_WaitForLastTask();
|
||||
|
||||
/* Is it the first configuration */
|
||||
BKP_WriteBackupRegister(BKP_DR1, RTC_FIRST_INIT_VALUE);
|
||||
|
||||
TuFlashProductTimeLimitFrame LimitTime;
|
||||
if (Flash_GetProductTimeLimit(&LimitTime, kFactoryTimeId) == READY)
|
||||
{
|
||||
RTC_SetTime(LimitTime.Struct.year, LimitTime.Struct.month, LimitTime.Struct.day,
|
||||
LimitTime.Struct.hour, LimitTime.Struct.minute, 0); /* Setup Time */
|
||||
LOG_D("RTC_SetTime:%04d-%02d-%02d,%02d:%02d",
|
||||
LimitTime.Struct.year, LimitTime.Struct.month, LimitTime.Struct.day,
|
||||
LimitTime.Struct.hour, LimitTime.Struct.minute);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -360,8 +341,6 @@ int BSP_RTC_Init(void)
|
|||
RTC_WaitForLastTask();
|
||||
RTC_WaitForSynchro(); // 等待RTC时钟与APB1时钟同步
|
||||
|
||||
// RTC_ITConfig(RTC_IT_ALR, ENABLE);
|
||||
// RTC_ITConfig(RTC_IT_SEC, ENABLE);
|
||||
RTC_WaitForLastTask();
|
||||
}
|
||||
RTC_NVIC_Config();
|
||||
|
@ -385,18 +364,11 @@ void RTC_IRQHandler(void)
|
|||
if (RTC_GetITStatus(RTC_IT_SEC) != RESET) // 秒钟中断
|
||||
{
|
||||
RTC_ClearITPendingBit(RTC_IT_SEC | RTC_IT_OW); // 清秒中断
|
||||
RTC_GetTime(); // 更新时间
|
||||
LOG_D("%4d-%02d-%02d, %02d:%02d:%02d", RtcDateTime.year, RtcDateTime.month, RtcDateTime.day,
|
||||
RtcDateTime.hour, RtcDateTime.minute, RtcDateTime.second);
|
||||
// RTC_GetTime(); // 更新时间
|
||||
// LOG_D("%4d-%02d-%02d, %02d:%02d:%02d", RtcDateTime.year, RtcDateTime.month, RtcDateTime.day,
|
||||
// RtcDateTime.hour, RtcDateTime.minute, RtcDateTime.second);
|
||||
}
|
||||
|
||||
// if (RTC_GetITStatus(RTC_IT_ALR) != RESET) // 闹钟中断
|
||||
// {
|
||||
// RTC_ClearITPendingBit(RTC_IT_ALR); // 清闹钟中断
|
||||
// RTC_GetTime(); // 更新时间
|
||||
// RTC_WaitForLastTask();
|
||||
// }
|
||||
|
||||
rt_interrupt_leave();
|
||||
FREE_INT_SP();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ extern "C" {
|
|||
#define AT_DEVICE_CTRL_GET_SIGNAL 0x0AL//获取信号
|
||||
#define AT_DEVICE_CTRL_GET_GPS 0x0BL
|
||||
#define AT_DEVICE_CTRL_GET_VER 0x0CL
|
||||
#define AT_DEVICE_RF_CLOSE 0X0DL
|
||||
|
||||
/* Name type */
|
||||
#define AT_DEVICE_NAMETYPE_DEVICE 0x01
|
||||
|
|
Loading…
Reference in New Issue