blob: 11f027c0902687eb4ada4e284a259a1985e7db01 [file] [log] [blame]
/*
* MBTK AT Header.
*
* Author : lb
* Date : 2021/11/5 10:41:24
*
*/
#ifndef MBTK_AT_H
#define MBTK_AT_H
#include "ml_utils.h"
#include "teldef.h"
#include "telutl.h"
#include "utlTypes.h"
#include "utlAtParser.h"
#include "mbtk/mbtk_type.h"
void mbtk_log(int level, const char *format, ...);
#define LOG_DEBUG_LEVEL 5
#define LOG(fmt, args...) mbtk_log(LOG_DEBUG_LEVEL, fmt, ##args)
#define MBTK_AT_RESP_LEN_MAX 2048
#define MBTK_AT_FTP_NAME_LEN_MAX 21
#define MBTK_AT_FTP_PASS_LEN_MAX 21
#define MBTK_AT_FTP_ADDR_LEN_MAX 64
#define MBTK_AT_FTP_DIR_LEN_MAX 90
#ifdef MBTK_DATA_MODE_SUPPORT
typedef void (*mbtk_data_mode_callback_func)(const char *data, int data_len);
#endif
typedef enum {
MBTK_AT_FUNC_TYPE_BASIC = 0, // No change , refer to lib_list
MBTK_AT_FUNC_TYPE_FACTORY,
MBTK_AT_FUNC_TYPE_AUDIO,
MBTK_AT_FUNC_TYPE_GNSS,
MBTK_AT_FUNC_TYPE_ECALL,
MBTK_AT_FUNC_TYPE_SOCKET,
MBTK_AT_FUNC_TYPE_TCPIP,
MBTK_AT_FUNC_TYPE_HTTP,
MBTK_AT_FUNC_TYPE_FTP,
/* Arrry number. */
MBTK_AT_FUNC_TYPE_NUM
} mbtk_at_func_type_enum;
typedef struct mbtk_at_func{
mbtk_at_func_type_enum type;
char name[50];
void *func;
struct mbtk_at_func *next;
} mbtk_at_func_t;
typedef enum
{
MBTK_PORT_TYPE_UART1, // /dev/ttyS1
MBTK_PORT_TYPE_USB1, // /dev/ttyGS0
MBTK_PORT_TYPE_USB2 // /dev/ttymodem0
} mbtk_port_type_enum;
typedef enum
{
MBTK_PORT_MODE_AT, // AT mode(default)
MBTK_PORT_MODE_ADB, // mbtk_adb mode
MBTK_PORT_MODE_CUSTOM // Custom mode
} mbtk_port_mode_enum;
//void func_add(char *name);
mbtk_at_func_t *func_get(char *name);
//#define mbtk_cmd_line_ex_f (bool (*)(const char*, void (*)(char*int)))
#define MBTK_FUNC_TYPEDEF
#include "mbtk_at_func.h"
#undef MBTK_FUNC_TYPEDEF
#define MBTK_FUNC(name) (*((name)(func_get(#name)->func)))
/*#define MBTK_FUNC(name) \
do{ \
if(name) \
(*((name)(func_get(#name)->func))); \
} while(0)
*/
//#define MBTK_FUNC(name) (name?(*((name)(func_get(#name)->func))):-1)
#define MBTK_FUNC_ADD(type, name) func_add(type, #name)
//typedef void (*mbtk_cmd_cb_func)(char *buf,int buf_size);
//typedef bool (*mbtk_cmd_line_ex_f)(const char *cmd, void (*cb)(char *buf,int buf_size));
//extern void* mbtk_cmd_line_ex;
#if 0
typedef int (*mbtk_audio_exec_f)(const char *args);
extern mbtk_audio_exec_f mbtk_at_play;
extern mbtk_audio_exec_f mbtk_at_rec;
#endif
#if 0
typedef enum {
MBTK_AT_PARAM_TYPE_INT,
MBTK_AT_PARAM_TYPE_STR
} mbtk_at_param_type_enum;
typedef struct {
int min;
int max;
int int_def;
} mbtk_at_param_int_range_t;
typedef struct {
int max_len;
char *str_def;
} mbtk_at_param_str_range_t;
typedef struct {
mbtk_at_param_type_enum type;
union {
mbtk_at_param_int_range_t param_int;
mbtk_at_param_str_range_t param_str;
} param;
} mbtk_at_param_range_t;
#endif
BOOL getExtValue( const utlAtParameterValue_P2c param_value_p,
int index,
int *value_p,
int minValue,
int maxValue,
int DefaultValue);
BOOL getExtUValue(const utlAtParameterValue_P2c param_value_p,
int index,
unsigned int *value_p,
unsigned int minValue,
unsigned int maxValue,
unsigned int DefaultValue);
BOOL getExtString( const utlAtParameterValue_P2c param_value_p,
int index,
CHAR *outString,
INT16 maxStringLength,
INT16 *outStringLength,
CHAR *defaultString);
char *op2str(utlAtParameterOp_T op);
#ifdef MBTK_DATA_MODE_SUPPORT
utlReturnCode_T mbtk_data_mode_enter(TelAtParserID atp_index, mbtk_data_mode_callback_func cb);
#endif
#if 1//MBTK_RGMII_TEST
int mbtk_rgmii_loopback(void);
int mbtk_mdio(char* net_name,int mode, uint16_t reg_addr, uint16_t value);
#endif
#endif /* MBTK_AT_H */