diff --git a/applications/main.c b/applications/main.c index a7baf77..3a3e867 100644 --- a/applications/main.c +++ b/applications/main.c @@ -293,7 +293,7 @@ int main(void) // 定义超时时间,单位为毫秒 #define TIMEOUT_MS (3 * 60 * 1000) #define WORK_TIMER_CNT (1000 * 60 * 60)//按照小时算 - + rt_thread_mdelay(200); if (Get_VIN_VoltageInt1000x() > 10000) { SYS_EventInit(); diff --git a/bsp/inc/bsp_vin_detection.h b/bsp/inc/bsp_vin_detection.h index ef3bb59..863eec7 100644 --- a/bsp/inc/bsp_vin_detection.h +++ b/bsp/inc/bsp_vin_detection.h @@ -25,7 +25,7 @@ // (4.7/19.7) * 13V = 3.1V, 3.1/3.3*4096 = 3723 #define VIN_ADC_HIGH_THRESHOLD (uint16_t)3847 // 13V // (4.7/19.7) * 10V = 2.39V, 2.39/3.3*4096 = 2966 -#define VIN_ADC_LOW_THRESHOLD (uint16_t)2665 // 9V +#define VIN_ADC_LOW_THRESHOLD (uint16_t)2369 // 8V float Get_VIN_Voltage(void); diff --git a/bsp/src/at_device_ml307.c b/bsp/src/at_device_ml307.c index 93f1116..c0eddbe 100644 --- a/bsp/src/at_device_ml307.c +++ b/bsp/src/at_device_ml307.c @@ -959,11 +959,6 @@ static void ml307_init_thread_entry (void *parameter) result = -RT_ERROR; goto __exit; } - if (at_obj_exec_cmd (device->client, resp, "AT+CEREG=1") != RT_EOK) - { - result = -RT_ERROR; - goto __exit; - } /* Define PDP Context */ for (i = 0; i < COMMON_RETRY; i++) { diff --git a/bsp/src/bsp_ml307.c b/bsp/src/bsp_ml307.c index 0f589e4..70df6b5 100644 --- a/bsp/src/bsp_ml307.c +++ b/bsp/src/bsp_ml307.c @@ -1977,7 +1977,7 @@ static void Ml307_Life_Thread_Entry (void *parameter) } if (device->class->device_ops->control (device, AT_DEVICE_CTRL_POWER_OFF, RT_NULL) == RT_EOK) { - rt_thread_mdelay (RT_TICK_PER_SECOND); + rt_thread_mdelay ((RT_TICK_PER_SECOND*2)); if (device->class->device_ops->control (device, AT_DEVICE_CTRL_POWER_ON, RT_NULL) == RT_EOK) { LOG_D ("AT device power on success"); @@ -2020,7 +2020,7 @@ static void Ml307_Life_Thread_Entry (void *parameter) result = -RT_ERROR; goto __exit; } - /* check SIM card */ + /* check SIM card */ for (i = 0; i < 60; i++) { if (at_obj_exec_cmd (device->client, resp, "AT+CPIN?") == RT_EOK) @@ -2049,47 +2049,7 @@ static void Ml307_Life_Thread_Entry (void *parameter) result = -RT_ERROR; goto __exit; } - /* Define PDP Context */ - for (i = 0; i < 60; i++) - { - if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=1") == RT_EOK) - { - LOG_D ("pdp激活成功"); - break; - } - else - { - // AT+CGACT=0,1 //去激活 PDP - if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=0") == RT_EOK) - { - LOG_D ("pdp去激活成功"); - } - } - rt_thread_mdelay (5000); - } - if (i == 60) - { - result = -RT_ERROR; - goto __exit; - } - - - for (i = 0; i < 5; i++) - { - if (at_obj_exec_cmd (device->client, resp, "AT+CGDCONT=1,\"IPV4V6\",\"cmnet\"") == RT_EOK) - { - LOG_D ("%s device Define PDP Context Success.", device->name); - break; - } - rt_thread_mdelay (1000); - } - if (i == 5) - { - LOG_E ("%s device Define PDP Context failed.", device->name); - result = -RT_ERROR; - goto __exit; - } - if (at_obj_exec_cmd (device->client, resp, "AT+CEREG=1") != RT_EOK) + if (at_obj_exec_cmd (device->client, resp, "AT+CEREG=1") != RT_EOK) { result = -RT_ERROR; goto __exit; @@ -2118,6 +2078,47 @@ static void Ml307_Life_Thread_Entry (void *parameter) result = -RT_ERROR; goto __exit; } + for (i = 0; i < 5; i++) + { + if (at_obj_exec_cmd (device->client, resp, "AT+CGDCONT=1,\"IPV4V6\",\"cmnet\"") == RT_EOK) + { + LOG_D ("%s device Define PDP Context Success.", device->name); + break; + } + rt_thread_mdelay (1000); + } + if (i == 5) + { + LOG_E ("%s device Define PDP Context failed.", device->name); + result = -RT_ERROR; + goto __exit; + } + + // /* Define PDP Context */ + // for (i = 0; i < 60; i++) + // { + // if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=1") == RT_EOK) + // { + // LOG_D ("pdp激活成功"); + // break; + // } + // else + // { + // // AT+CGACT=0,1 //去激活 PDP + // if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=0") == RT_EOK) + // { + // LOG_D ("pdp去激活成功"); + // } + // } + // rt_thread_mdelay (1000); + // } + // if (i == 60) + // { + // result = -RT_ERROR; + // goto __exit; + // } + + if (at_obj_exec_cmd (device->client, resp, "AT+MIPCALL=1,1") != RT_EOK) { result = -RT_ERROR;