blob: 58282188ffcc1d8de8ac51e257db7c796b44a512 [file] [log] [blame]
#ifndef _FOTA_COMM_H_
#define _FOTA_COMM_H_
#include "dmgr_api.h"
#include "fota_protocol_util.h"
#include "fota_http_util.h"
#include "curl_adapter.h"
#include "assert.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
//#define MEM_DEBUG
void dump_mem_info(void);
#define fota_sleep sleep
#define fota_assert assert
#define fota_ftruncate ftruncate
#ifdef MEM_DEBUG
void* realloc_debug(void *ptr, size_t size, const char*func, long line);
void* malloc_debug(size_t bytes, const char* func, long line);
void free_debug(void*p, const char* func, long line);
char* strdup_debug(const char* str, const char* func, long line);
#define fota_malloc(size) malloc_debug(size, __FUNCTION__, __LINE__)
#define fota_free(ptr) do{if(ptr) free_debug(ptr, __FUNCTION__, __LINE__); ptr=NULL;}while(0)
#define fota_strdup(str) strdup_debug(str, __FUNCTION__, __LINE__)
#define fota_realloc(ptr, size) realloc_debug(ptr, size, __FUNCTION__, __LINE__)
#else
#define fota_malloc(size) malloc(size)
#define fota_free(ptr) do{if(ptr) free(ptr); ptr=NULL;}while(0)
#define fota_strdup(str) strdup(str)
#define fota_realloc(ptr, size) realloc(ptr, size)
#endif
#define FOTA_FAIL -1
#define FOTA_SUCCESS 0
#define FOTA_ERROR -1
#define LOGD(fmt, args ...) \
do { printf("[DMGR][%s-%d]:"fmt, __FUNCTION__, __LINE__, ##args); } while (0)
#define FOTA_DEFAULT_URL "http://fotazxic.zte.com.cn/Fota/Download.do"
#define DEFAULT_DL_URL "http://47.96.134.20/Fota/"
#define FOTA_SERVER_DOMAIN_NAME "fotazxic.zte.com.cn"
#define VERSION_FILE "version_file"
#define REG_POLICY_INFO "policy_info"
#define HTTP_LINE_ENDING "\r\n"
/* fota版本号 */
#define FOTA_VERSION 1
#define ZX_FOTA_DM_LIB_VERSION "zte dmgr lib version 1.0.0"
/* #define NB_7100 */
#ifdef NB_7100
#define PROTOCOL_VERSION "2.0"
#else
#define PROTOCOL_VERSION "2.1"
#endif
/* action code */
#define SESSION_OPEN 0x8000
#define REGISTER_DEVICE_INFO 0x8001
#define REGISTER_POLICY_INFO 0x8002
#define CHECK_VRESION 0x8003
#define DOWNLOAD_VRESION 0x8004
#define UPDATE_RESULT 0x8005
#define SESSION_CLOSE 0x8006
typedef enum {
UPGRADE_OK = 0,
UPGRADE_FAIL
} UPGRADE_RESULT;
typedef struct {
char *IMEI;
char *download_url;
char *version_path;
unsigned int devNum;
char *dev_info;
policy_info_t *policy_info;
} config_info_t;
typedef struct {
long resp_code;
int result_code;
int action_code;
} post_result_t;
typedef struct {
config_info_t config_info;
notifier_block_t *notifier_list[MAX_USER_NOTIFIERS];
post_result_t post_result;
download_info_t download_info;
} dmgr_info_t;
extern dmgr_t g_dmgr;
#endif /* _FOTA_COMM_H_ */