Files
banban/ql-kernel/threadx/common/include/quec_wifi_msg.h

230 lines
8.7 KiB
C

/**
@file
quec_wifi_msg.h
@brief
Quectel wifi msg api header.
*/
/*============================================================================
Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
Quectel Wireless Solution Proprietary and Confidential.
=============================================================================*/
/*===========================================================================
EDIT HISTORY FOR MODULE
This section contains comments describing changes made to the module.
Notice that changes are listed in reverse chronological order.
WHEN WHO WHAT, WHERE, WHY
---------- ------------ ----------------------------------------------------
=============================================================================*/
#ifndef QUEC_WIFI_MSG_H
#define QUEC_WIFI_MSG_H
#ifdef __cplusplus
extern "C" {
#endif
/*========================================================================
* Macro Definition
*========================================================================*/
#define QUEC_PROTOCOL_HEAD_MAX_SIZE 6
#define QUEC_PROTOCOL_MSG_DATA_MAX_LEN 1600
#define QUEC_PROTOCOL_MSG_MAX_LEN (QUEC_PROTOCOL_HEAD_MAX_SIZE + QUEC_PROTOCOL_MSG_DATA_MAX_LEN)
#define QUEC_MSG_CACHE_MAX_LEN (QUEC_PROTOCOL_MSG_MAX_LEN * 4)
/*========================================================================
* Enumeration Definition
*========================================================================*/
typedef enum
{
QUEC_WIFI_MSG_SUCCESS = 0,
QUEC_WIFI_MSG_EXECUTE_ERR = 1,
QUEC_WIFI_MSG_INVALID_PARAM_ERR,
QUEC_WIFI_MSG_TASK_CREATE_ERR,
QUEC_WIFI_MSG_MUTEX_CREATE_ERR,
} quec_wifi_msg_errcode_e;
typedef enum
{
QUEC_WIFI_NPTO_PARSE_RESULT_SUCC = 0,
QUEC_WIFI_NPTO_PARSE_RESULT_NOMAGIC = 101, // No protocol header
QUEC_WIFI_NPTO_PARSE_RESULT_TOOSMALL, // Data too small
QUEC_WIFI_NPTO_PARSE_RESULT_ERRCRC, // CRC error
QUEC_WIFI_NPTO_PARSE_RESULT_UNKNOWN,
}quec_wifi_npto_parse_result_e;
typedef enum
{
QUEC_WIFI_NPTO_802_3_STREAM = 0,
QUEC_WIFI_NPTO_STA_IP_START_CMD = 1, //开启wifi sta功能, 成功连接热点,接受到该事件
QUEC_WIFI_NPTO_STA_IP_DOWN_CMD = 2,
QUEC_WIFI_NPTO_UAP_IP_START_CMD = 3, //开启wifi ap功能,接受到该事件
QUEC_WIFI_NPTO_UAP_IP_DOWN_CMD = 4, //关闭wifi ap功能,接受到该事件
QUEC_WIFI_NPTO_IP_ADDR_SET_CMD = 5,
QUEC_WIFI_NPTO_WLAN_CREATE_CMD = 6, //开启wifi sta功能,会先接受到7,再接受到6
QUEC_WIFI_NPTO_WLAN_DESTROY_CMD = 7, //开启wifi sta功能,会先接受到7,再接受到6
QUEC_WIFI_NPTO_STATUS_UPDATE_CMD = 8,
QUEC_WIFI_NPTO_UAP_STA_CONNECT_CMD = 9,
QUEC_WIFI_NPTO_UAP_STA_DISCONNECT_CMD = 10,
QUEC_WIFI_APP_STA_ENABLE_CMD = 20,
QUEC_WIFI_APP_STA_DISABLE_CMD = 21,
QUEC_WIFI_APP_AP_ENABLE_CMD = 23,
QUEC_WIFI_APP_AP_DISABLE_CMD = 24,
QUEC_WIFI_APP_EVENT_NOTIFY = 25,
QUEC_WIFI_APP_SCAN_START_CMD = 26,
QUEC_WIFI_APP_STA_STATUS_CMD = 27,
QUEC_WIFI_APP_STA_LINK_STATUS_CMD = 28, //对应WiFi的cmd27
QUEC_WIFI_APP_STA_SET_GOT_IP = 29, //要进入低功耗模式,必须先设置该状态
QUEC_WIFI_APP_PSM_CMD = 30, //设置进入低功耗模式
QUEC_WIFI_APP_SET_BLACK_MAC = 31, //增加或者删减sta黑名单
QUEC_WIFI_APP_AP_SET_CHANNEL = 32, //设置AP信道
QUEC_WIFI_APP_WIFI_STATE_REPORT= 34, // wifi状态主动上报,参数为rw_evt_type枚举
QUEC_WIFI_APP_RESET_CMD = 40,
QUEC_WIFI_APP_RESET_DONE = 41,
QUEC_WIFI_APP_GET_VERSION = 42, //GET VERSION
QUEC_WIFI_APP_OTA_CMD = 50, // WIFI OTA CMD, 0x32
QUEC_WIFI_BOOT_UPGRADE_CMD = 51, // WIFI BOOT CMD, 0x33
QUEC_BLE_APP_INIT_CMD = 60, //0x3C, 用于初始化BLE,参数为 1 开启ble, 0 关闭 ble
QUEC_BLE_APP_GET_BLE_MAC_ADDR_CMD = 61, //0X3D, 查询设备BLE地址
QUEC_BLE_APP_SET_BLE_NAME_CMD = 62, //0X3E, 设置BLE名称,最大长度:25字节
QUEC_BLE_APP_SET_BLE_ADV_PARAM_CMD = 63, //0X3F, 设置BLE广播参数
QUEC_BLE_APP_ADV_DATA_CMD = 64, //0x40, 设置BLE广播数据,参数为ql_ble_adv_data_info结构
QUEC_BLE_APP_SET_SERICE_UUID_CMD = 65, //0x41, 创建BLE服务,参数为ql_ble_app_service_info结构
QUEC_BLE_APP_SET_CHARACT_UUID_CMD = 66, //0x42, 创建BLE特征,参数为ql_ble_app_service_info结构
QUEC_BLE_APP_ADV_START_CMD = 67, //0x43, 开启BLE广播, 01 开启, 00 关闭
QUEC_BLE_APP_DATA_SEND_CMD = 68, //0x44, 发送GATT数据,参数为ql_ble_send_data_info结构
QUEC_BLE_APP_DISCONNECT_CMD = 69, //0x45, 断开BLE连接,无参数
QUEC_BLE_APP_INFO_RPT = 70, //0x46, BLE信息上报
QUEC_WIFI_APP_CMD_MAX
} quec_wifi_npto_cmd_t;
typedef enum
{
/* for station mode */
RW_EVT_STA_IDLE = 0,
RW_EVT_STA_CONNECTING,
RW_EVT_STA_BEACON_LOSE,
RW_EVT_STA_PASSWORD_WRONG, // 3 密码错误
RW_EVT_STA_NO_AP_FOUND, // 4 扫描不到ap
RW_EVT_STA_ASSOC_FULL, // 5 ap接入点已满
RW_EVT_STA_DEAUTH, // 6 收到AP的deauth包
RW_EVT_STA_AUTH_FAILED, // 7 验证失败
RW_EVT_STA_DISASSOC, // 8 收到AP的disassoc包
RW_EVT_STA_ASSOC_FAILED, // 9 关联认证失败
RW_EVT_STA_ACTIVE_DISCONNECTED, // 10 sta主动断开连接
RW_EVT_STA_CONNECTED, // 11 连接成功
RW_EVT_STA_GOT_IP, // 12 获取ip成功
/* for softap mode */
RW_EVT_AP_CONNECTED, /* a client association success */
RW_EVT_AP_DISCONNECTED, /* a client disconnect */
RW_EVT_AP_CONNECT_FAILED, /* a client association failed */
RW_EVT_AP_GOT_IP,
RW_EVT_MAX
} rw_evt_type;
/*========================================================================
* Type Definition
*========================================================================*/
typedef void (*quec_wifi_msg_net_notify_cb)(void *ctx);
typedef void (*quec_wifi_msg_app_notify_cb)(void *ctx);
typedef struct
{
int msg_id;
void *msg_info;
} quec_wifi_msg_cmd_info_s;
typedef struct
{
unsigned int data_len;
unsigned int pos;
char *data;
} quec_wifi_msg_protocol_info_s;
typedef struct
{
unsigned char magic0; // Must be 0xAA
unsigned char magic1; // Must be 0x55
unsigned short cmdlen; // Command length
unsigned char command; // Command.Set bit 8 to 1 means command feedback.
unsigned char checksum;
unsigned char *data;
} quec_wifi_msg_protocol_head_info_s;
typedef struct{
uint8_t *or_addr;
uint8_t *data;
}quec_wifi_msg_align_s;
typedef struct
{
uint8_t *data;
int data_len;
int cmd;
} quec_wifi_msg_output_data_info_s;
/*========================================================================
* function Definition
*========================================================================*/
int quec_wifi_msg_recv(void *ctx);
/*****************************************************************
* Function: quec_wifi_msg_app_notify_cb_register
*
* Description: Register Wi-Fi APP engine notification from MSG engine callback.
*
* Parameters:
* cb [in] Wi-Fi APP engine notification from MSG engine callback.
* Once the MSG engine parses the corresponding command,the command will be passed to APP engine.
*
* Return:
* 0 success
* other error code
*
*****************************************************************/
quec_wifi_msg_errcode_e quec_wifi_msg_app_notify_cb_register(quec_wifi_msg_app_notify_cb cb);
/*****************************************************************
* Function: quec_wifi_msg_init
*
* Description: Initialize Wi-Fi msg engine.
*
* Parameters:
* argv [in] No defined yet.
*
* Return:
* 0 success
* other error code
*
*****************************************************************/
quec_wifi_msg_errcode_e quec_wifi_msg_init(void *argv);
/*****************************************************************
* Function: quec_wifi_msg_deinit
*
* Description: Deinitialize Wi-Fi msg engine.
*
* Parameters:
* argv [in] No defined yet.
*
* Return:
* 0 success
* other error code
*
*****************************************************************/
quec_wifi_msg_errcode_e quec_wifi_msg_deinit(void *argv);
#ifdef __cplusplus
} /*"C" */
#endif
#endif