Add Gps lib.

This commit is contained in:
xiaojiazhu 2023-07-28 17:57:27 +08:00
parent 7e554dbbe9
commit 3cfc69cbf7
10 changed files with 54 additions and 18 deletions

View File

@ -213,7 +213,7 @@
#define DEFAULT_PIR_DELAY_SWITCH SF_OFF #define DEFAULT_PIR_DELAY_SWITCH SF_OFF
#define DEFAULT_GPRS_MODE SF_REMOTE_CONTROL_OFF #define DEFAULT_GPRS_MODE SF_REMOTE_CONTROL_OFF
#define DEFAULT_DAILY_REPORT_SWITCH SF_ON #define DEFAULT_DAILY_REPORT_SWITCH SF_ON
#define DEFAULT_GPS_SWITCH SF_OFF #define DEFAULT_GPS_SWITCH SF_ON
//#if defined(_MODEL_565_HUNTING_EVB_LINUX_4G_68CS_) //#if defined(_MODEL_565_HUNTING_EVB_LINUX_4G_68CS_)
//#define DEFAULT_PIR_SENSITIVITY SF_PIR_SENSITIVITY_HIGH //#define DEFAULT_PIR_SENSITIVITY SF_PIR_SENSITIVITY_HIGH
//#elif defined(_MODEL_565_HUNTING_EVB_LINUX_4G_S530_) //#elif defined(_MODEL_565_HUNTING_EVB_LINUX_4G_S530_)

View File

@ -194,6 +194,10 @@ EXTRA_LIB += \
-l:libFtpManager.a \ -l:libFtpManager.a \
-l:libServers.a \ -l:libServers.a \
-l:libLog.a \ -l:libLog.a \
-l:libAtManager.a \
-l:libAtCommand.a \
-l:libReturnCode.a \
-l:libConfig.a \
$(APP_DIR)/sifarsdk/out/libs/libcurl.a \ $(APP_DIR)/sifarsdk/out/libs/libcurl.a \
$(APP_DIR)/sifarsdk/out/libs/libssl.a \ $(APP_DIR)/sifarsdk/out/libs/libssl.a \
$(APP_DIR)/sifarsdk/out/libs/libcrypto.a \ $(APP_DIR)/sifarsdk/out/libs/libcrypto.a \

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -281,7 +281,7 @@ UINT8 sf_get_netsearch_step(void);
SINT32 sf_get_utc(VOID); SINT32 sf_get_utc(VOID);
SINT32 sf_get_ntp(SINT32 value); SINT32 sf_get_ntp(SINT32 value, SF_PARA_TIME_S *current_time);
UINT8 sf_get_pdp_index(void); UINT8 sf_get_pdp_index(void);

View File

@ -24,6 +24,7 @@ extern "C" {
#include "sf_service.h" #include "sf_service.h"
#include "sf_ftp.h" #include "sf_ftp.h"
#include "sf_module.h" #include "sf_module.h"
#include "at_manager.h"
#define APNGPRS_WUYUAN1 "America.bics" #define APNGPRS_WUYUAN1 "America.bics"
#define APNGPRS_WUYUAN2 "bicsapn" #define APNGPRS_WUYUAN2 "bicsapn"
@ -42,7 +43,7 @@ BOOL GprsNetWorkReady = FALSE;
UINT8 gprs_search_process = GPRS_SEARCH_STEP_IDLE; UINT8 gprs_search_process = GPRS_SEARCH_STEP_IDLE;
extern SF_PARA_TIME_S rtcTime; extern SF_PARA_TIME_S rtcTime;
SF_PARA_TIME_S nowDate = { 0, 0, 0, 0, 0, 0}; // SF_PARA_TIME_S nowDate = { 0, 0, 0, 0, 0, 0};
typedef struct sf_cimi_id typedef struct sf_cimi_id
{ {
@ -596,7 +597,7 @@ SINT32 eg91_usb_net_apn_cfg(SF_FN_PARAM_S *pfnParam)
} }
break; break;
case USBNET_APN_QICSGP2: case USBNET_APN_QICSGP2:
if(strstr(gsmPara, "OK")) if(strstr(gsmPara, "OK")) // TODO: ?? what happend.
{ {
count = 0; count = 0;
sts = 0; sts = 0;
@ -2446,6 +2447,12 @@ SINT32 sf_module_complete_init(void)
strcpy((char *)puiPara->ModuleVer, (const char *)strtmp[1]); strcpy((char *)puiPara->ModuleVer, (const char *)strtmp[1]);
SF_DEBUG("ModuleVer=%s", puiPara->ModuleVer); SF_DEBUG("ModuleVer=%s", puiPara->ModuleVer);
if(strstr(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q)){
at_manager_init(AT_MODULE_TYPE_EG915Q, sf_hal_ttyusb2_read, sf_hal_ttyusb2_write);
}
else{
at_manager_init(AT_MODULE_TYPE_EG91, sf_hal_ttyusb2_read, sf_hal_ttyusb2_write);
}
eNetRegLocation = QUECTEL_NETREG_QGMR; eNetRegLocation = QUECTEL_NETREG_QGMR;
strcpy((char *)gsmPara, "AT+QGMR\r"); strcpy((char *)gsmPara, "AT+QGMR\r");
@ -4549,7 +4556,7 @@ SINT32 sf_get_utc(VOID)
Return: 0 SUCCESS, 1 error Return: 0 SUCCESS, 1 error
Others: N/A Others: N/A
*************************************************/ *************************************************/
SINT32 sf_get_ntp(SINT32 value) SINT32 sf_get_ntp(SINT32 value, SF_PARA_TIME_S *current_time)
{ {
SINT32 ret = SF_SUCCESS; SINT32 ret = SF_SUCCESS;
//UINT8 errMsg[128] = {0}; //UINT8 errMsg[128] = {0};
@ -4577,6 +4584,7 @@ SINT32 sf_get_ntp(SINT32 value)
while(sf_app_while_flag()) while(sf_app_while_flag())
{ {
printf("================================================================== \n");
switch(eSmsLocation) switch(eSmsLocation)
{ {
case SMS_SIM_INIT_CNTP: case SMS_SIM_INIT_CNTP:
@ -4633,14 +4641,16 @@ SINT32 sf_get_ntp(SINT32 value)
calltime = 0; calltime = 0;
printf("[%s:%d]UTC: %04d/%02d/%02d %02d:%02d:%02d\n", __FUNCTION__, __LINE__, year, month, day, hour, minute, second); printf("[%s:%d]UTC: %04d/%02d/%02d %02d:%02d:%02d\n", __FUNCTION__, __LINE__, year, month, day, hour, minute, second);
if (current_time)
{
current_time->Year = year;
current_time->Mon = month;
current_time->Day = day;
nowDate.Year = year; current_time->Hour = hour;
nowDate.Mon = month; current_time->Min = minute;
nowDate.Day = day; current_time->Sec = second;
}
nowDate.Hour = hour;
nowDate.Min = minute;
nowDate.Sec = second;
//getUtcTimeFlag = 1; //getUtcTimeFlag = 1;
rtcTime.Year = year; rtcTime.Year = year;

View File

@ -52,6 +52,7 @@
#include "sf_wifi_svr.h" #include "sf_wifi_svr.h"
#include "sf_battery.h" #include "sf_battery.h"
#include "ftp_manager.h" #include "ftp_manager.h"
#include "Log.h"
//#include <libavcodec/avcodec.h> //#include <libavcodec/avcodec.h>
//#include <libavformat/avformat.h> //#include <libavformat/avformat.h>
//#include <libavutil/imgutils.h> //#include <libavutil/imgutils.h>
@ -119,12 +120,16 @@ int main(int argc, char *argv[])
sf_app_mcu_para_start(); sf_app_mcu_para_start();
InitLog(LOG_EASYLOGGING, NULL);
isUsb = sf_usb_IsInsert(); isUsb = sf_usb_IsInsert();
isCard = sf_in_card_exist(); isCard = sf_in_card_exist();
isUpdate = sf_in_update(); isUpdate = sf_in_update();
sf_set_fw_update(isUpdate); sf_set_fw_update(isUpdate);
printf("[%s:%d] isUsb = %d isCard = %d isUpdate:%d\n", __FUNCTION__, __LINE__, isUsb,isCard,isUpdate);
if(!isUsb) if(!isUsb)
{ {
sf_app_load_ko_start(); sf_app_load_ko_start();

View File

@ -53,6 +53,8 @@
#include "sf_service.h" #include "sf_service.h"
#include "sf_sms.h" #include "sf_sms.h"
#include "sf_system.h" #include "sf_system.h"
#include "at_manager.h"
#include "Log.h"
#ifdef __cplusplus #ifdef __cplusplus
@ -1293,10 +1295,23 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) {
break; break;
#endif #endif
s32ret = sf_get_utc(); s32ret = sf_get_utc();
if ((s32ret == SF_SIM_ERROR_UTC) || (SF_ON == pCustomerParam->GpsSwitch)) { if ((s32ret == SF_SIM_ERROR_UTC) || (SF_ON == pCustomerParam->GpsSwitch)) {
s32ret = sf_get_ntp(s32ret); SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
s32ret = sf_get_ntp(s32ret, &current_time);
#define NTP_TIME_LENGTH 32
char ntp_time[NTP_TIME_LENGTH] = {0};
snprintf(ntp_time, NTP_TIME_LENGTH, "%04d/%02d/%02d,%02d:%02d:%02d",
current_time.Year, current_time.Mon, current_time.Day,
current_time.Hour, current_time.Min, current_time.Sec);
gps_map_update(pCustomerParam->Sim4gApn, pCustomerParam->Sim4gUsr, pCustomerParam->Sim4gPwd, ntp_time);
gps_open(ntp_time);
//while(1)
//{
//GpsLocation location = gps_get_location();
//LogInfo("location.latitude = %s\n", location.latitude);
//LogInfo("location.longitude = %s\n", location.longitude);
//}
} }
sf_4G_usb_net_apn_cfg(pfnParam); sf_4G_usb_net_apn_cfg(pfnParam);
@ -1423,7 +1438,8 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) {
s32ret = sf_get_utc(); s32ret = sf_get_utc();
if ((s32ret == SF_SIM_ERROR_UTC) || (SF_ON == pCustomerParam->GpsSwitch)) { if ((s32ret == SF_SIM_ERROR_UTC) || (SF_ON == pCustomerParam->GpsSwitch)) {
s32ret = sf_get_ntp(s32ret); SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
s32ret = sf_get_ntp(s32ret, &current_time);
} }
if (1 == pCustomerParam->NeedTimeSyncStartUp) { if (1 == pCustomerParam->NeedTimeSyncStartUp) {
printf("[%s:%d]8 between A and B,no reg net again,no reset time sync.\n", printf("[%s:%d]8 between A and B,no reg net again,no reset time sync.\n",
@ -1466,7 +1482,8 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) {
s32ret = sf_get_utc(); s32ret = sf_get_utc();
if ((s32ret == SF_SIM_ERROR_UTC) || (SF_ON == pCustomerParam->GpsSwitch)) { if ((s32ret == SF_SIM_ERROR_UTC) || (SF_ON == pCustomerParam->GpsSwitch)) {
s32ret = sf_get_ntp(s32ret); SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
s32ret = sf_get_ntp(s32ret, &current_time);
} }
if (0 != sf_get_cq_signal()) { if (0 != sf_get_cq_signal()) {
pCustomerParam->GpsSendFlag = 1; pCustomerParam->GpsSendFlag = 1;