build: W600-SDK importiert, Firmware-Build und Hello am EVK
Docker-Build mit gcc-arm-none-eabi 4.9-2014q4 (statt Homebrew-Cask) verwendet, Dockerfile/tools/docker.sh dafür aus Task 13 vorgezogen. cmake/sdk.cmake schont gcc 4.9 (kennt -fcommon/-Wno-error=... nicht). Zwei zusätzliche SDK-Stubs (EarlyInit, pre_gpio_config) in src/sys/sdk_stubs.c ergänzt, siehe sdk/PATCHES.md.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @file wm_at_ri_init.h
|
||||
*
|
||||
* @brief AT_RI task and interface resource initial Module
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef WM_AT_RI_H
|
||||
#define WM_AT_RI_H
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup AT_RI_APIs AT_RI APIs
|
||||
* @brief AT_RI command APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup AT_RI_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function is used to initialize hostif task
|
||||
used by AT&RI Command
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note Usually the system will call this api at power on.
|
||||
*/
|
||||
int tls_hostif_init(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to initialize high speed SPI
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note Users can decide to call this api or not according to his application.
|
||||
*/
|
||||
int tls_hspi_init(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to initialize UART
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note Usually the system will call this api at power on.
|
||||
*/
|
||||
void tls_uart_init(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* WM_AT_RI_H */
|
||||
|
||||
@@ -0,0 +1,481 @@
|
||||
/**
|
||||
* @file wm_cloud.h
|
||||
*
|
||||
* @brief Cloud Interface API
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
#ifndef __WM_CLOUD_H__
|
||||
#define __WM_CLOUD_H__
|
||||
|
||||
#include "wm_config.h"
|
||||
#if TLS_CONFIG_CLOUD
|
||||
#include "wm_sockets.h"
|
||||
#if TLS_CONFIG_HTTP_CLIENT_SECURE
|
||||
#include "matrixsslApi.h"
|
||||
#endif
|
||||
|
||||
#define SERVER_STATE_OFFLINE 0
|
||||
#define SERVER_STATE_ONLINE 1
|
||||
|
||||
#define SOCKET_TCP 1
|
||||
#define SOCKET_CLINET 2
|
||||
#define SOCKET_SSL 4
|
||||
|
||||
/**
|
||||
* 开发者自定义socket的信息,目前sock_type不支持Tcp server,
|
||||
* 可支持udp、tcp client以及ssl的tcp连接
|
||||
*/
|
||||
typedef struct _SOCKET{
|
||||
int socket_num; /**< socket号,socket建立成功后,系统填入,
|
||||
开发者初始化时不必填写 */
|
||||
struct sockaddr * sock_addr;/**< socket地址,udp时,表示本地地址,
|
||||
tcp时,表示对端地址 */
|
||||
u8 sock_type; /**< socket类型定义,目前仅低三个bit有效,
|
||||
具体查看SOCKET_xxx定义 */
|
||||
u8 connected; /**< socket连接标志,仅tcp client有效,
|
||||
为1表示连接成功 */
|
||||
void * user_param; /**< 开发者自定义信息,用来区分是否为开发者
|
||||
自定义socket */
|
||||
#if TLS_CONFIG_HTTP_CLIENT_SECURE
|
||||
ssl_t * ssl; /**< ssl连接信息,仅SOCKET_SSL时有效 */
|
||||
#endif
|
||||
}SOCKET;
|
||||
|
||||
/** 开发者自定义socket接收数据的格式 */
|
||||
typedef struct CReadData{
|
||||
SOCKET *socket; /**< socket相关信息 */
|
||||
char * read_data; /**< 接收的数据 */
|
||||
u32 data_len; /**< 接收数据长度 */
|
||||
struct sockaddr_in sin_recv;/**< 对端socket地址,仅udp时有效 */
|
||||
}CloudReadData;
|
||||
|
||||
#if TLS_CONFIG_CLOUD_KII
|
||||
/** 云端回调数据格式 */
|
||||
typedef struct _Cloud_Callback_data
|
||||
{
|
||||
char* bucketName;/**< bucket名称 */
|
||||
char* objectId; /**< 对象id */
|
||||
char* jsonObject;/**< 对象数据,通常用json格式表示 */
|
||||
} CloudCallbackData, *PCloudCallbackData;
|
||||
/** 设置上传云端回调,errcode为0表示上传成功,data为上传数据,
|
||||
如果上传成功,可以从data->objectId得到上传云的数据对象id */
|
||||
typedef void (*upload_callback)(PCloudCallbackData data, int errcode);
|
||||
/** 上传云端的数据格式 */
|
||||
typedef struct _CloudData
|
||||
{
|
||||
char* bucketName; /**< bucket名称 */
|
||||
char* jsonObject; /**< 对象数据,通常用json格式表示 */
|
||||
upload_callback cb; /**< 上传结果回调 */
|
||||
} CloudData,*PCloudData;
|
||||
|
||||
/** 初始化云参数定义 */
|
||||
typedef struct _Cloud_Init_arg
|
||||
{
|
||||
char* site; /**< 服务器地址,目前可传入"CN" "US" "JP" "SG" */
|
||||
char* appId; /**< 应用ID */
|
||||
char* appKey; /**< 应用Key */
|
||||
char* deviceType; /**< 设备类型 */
|
||||
char* venderId; /**< 设备ID,通常为设备的MAC地址 */
|
||||
char* modelName; /**< 模块名称,自定义字符串,OTA推送的bucketName格式为 */
|
||||
char* password; /**< 设备密码 */
|
||||
char* recvDataBucket; /**< 设备推送的bucketName */
|
||||
} CloudInitArg, *PCloudInitArg;
|
||||
#endif
|
||||
|
||||
#if TLS_CONFIG_CLOUD_JD
|
||||
/** 云操作类型枚举 */
|
||||
enum cloud_opt_type
|
||||
{
|
||||
UPLOAD_REQ, /**< 上传数据请求 */
|
||||
UPLOAD_RESP, /**< 上传数据响应 */
|
||||
CONTROL_REQ, /**< 云端控制命令请求 */
|
||||
CONTROL_RESP, /**< 控制命令响应 */
|
||||
SNAPSHOT_REQ, /**< 云端抓取快照(状态)请求 */
|
||||
SNAPSHOT_RESP /**< 快照(状态)响应 */
|
||||
};
|
||||
|
||||
/**
|
||||
* 云端通信数据结构,需要注意一下两点:
|
||||
* 1)作为tls_cloud_upload_data方法参数:
|
||||
* 上传数据请求、控制命令响应、快照(状态)响应接口,
|
||||
* 对于上传数据请求,如果此接口返回后,data->opt为UPLOAD_RESP,
|
||||
* 则实际上同步响应了上传命令,此时data->result即为上传数据后云端返回结果。
|
||||
* CloudData需要调用者自己分配内存,自己释放。
|
||||
* 2)作为cloud_callback回调参数:
|
||||
* 上传数据响应、云端控制命令下达、云端抓取快照(状态)请求时,
|
||||
* cloud_callback回调接口被调用。
|
||||
* 对于云端控制命令请求、云端抓取快照请求,如果在此回调接口返回后,
|
||||
* data->opt为CONTROL_RESP或SNAPSHOT_RESP,则实际上同步响应了此命令,
|
||||
* 此时data->result即为控制命令响应结果,data->values中包含了快照响应结果。
|
||||
* 同步响应SNAPSHOT_RESP时,names和values部分的内存以及同步响应CONTROL_RESP时,
|
||||
* data->control_resp部分的内存由开发者申请,在云实现中释放。
|
||||
*/
|
||||
typedef struct _CloudData
|
||||
{
|
||||
enum cloud_opt_type opt;/**< 操作类型枚举 */
|
||||
int result; /**< 云端响应上传数据或设备响应云端控制结果 */
|
||||
char* control_resp; /**< 云端控制命令失败原因 */
|
||||
char** names; /**< 上传数据请求、云端控制请求、
|
||||
云端快照请求或快照响应的字段名 */
|
||||
char** values; /**< 上传数据请求、云端控制请求、快照响应的值 */
|
||||
int cnt; /**< 字段个数 */
|
||||
void * arg; /**< 云端发送过来的参数,需要原封不动回传给云端 */
|
||||
} CloudData,*PCloudData, CloudCallbackData, *PCloudCallbackData;
|
||||
/** 初始化云参数定义,应该传入product_uuid */
|
||||
typedef struct _Cloud_Init_arg
|
||||
{
|
||||
char *product_uuid; /**< 产品UUID */
|
||||
} CloudInitArg, *PCloudInitArg;
|
||||
#endif
|
||||
#if TLS_CONFIG_CLOUD_GAGENT
|
||||
|
||||
/** 云端通信数据结构 */
|
||||
typedef struct _CloudData
|
||||
{
|
||||
int32 totalcap; /**< 全局缓存区的大小 4k+128byte */
|
||||
int32 remcap; /**< 数据包头的冗余长度 128byte */
|
||||
uint8 *allbuf; /**< 数据起始地址 */
|
||||
int32 bufcap; /**< 数据区域的大小 4K */
|
||||
|
||||
uint32 type; /**< 消息体类型 */
|
||||
uint8 *phead; /**< 数据包头起始地址 */
|
||||
uint8 *ppayload; /**< 业务逻辑头起始地址 */
|
||||
uint8 *pend; /**< 数据结束地址 */
|
||||
} CloudData,*PCloudData, CloudCallbackData, *PCloudCallbackData;
|
||||
|
||||
/** 初始化云参数定义 */
|
||||
typedef struct _Cloud_Init_arg
|
||||
{
|
||||
char* product_key; /**< 产品标识码 */
|
||||
char* wifi_soft_ver; /**< 软件版本号 */
|
||||
char* wifi_hard_ver; /**< 硬件版本号 */
|
||||
} CloudInitArg, *PCloudInitArg;
|
||||
#endif
|
||||
#if TLS_CONFIG_CLOUD_360
|
||||
/**
|
||||
* 设置上传云端回调,errcode为0表示上传成功,user_param为
|
||||
* 调用tls_cloud_upload_data时传入的CloudData中的user_param
|
||||
*/
|
||||
typedef void (*upload_callback)(void* user_param, int errcode);
|
||||
|
||||
/** 云端回调数据格式 */
|
||||
typedef struct _Cloud_Callback_data
|
||||
{
|
||||
const uint8_t* data; /**< 数据 */
|
||||
size_t datalen; /**< 数据长度 */
|
||||
}CloudCallbackData, *PCloudCallbackData;
|
||||
|
||||
/** 上传云端的数据格式 */
|
||||
typedef struct _CloudData
|
||||
{
|
||||
void* user_param; /**< 用户参数,在上传回调中传入此参数 */
|
||||
const uint8_t* data; /**< 数据 */
|
||||
size_t datalen; /**< 数据长度 */
|
||||
upload_callback cb; /**< 上传结果回调 */
|
||||
} CloudData,*PCloudData;
|
||||
|
||||
/** 初始化云参数定义 */
|
||||
typedef struct _Cloud_Init_arg
|
||||
{
|
||||
int product_id; /**< 产品ID */
|
||||
unsigned char product_aes[16]; /**< 产品AES密钥 */
|
||||
char *device_name; /**< 设备名称 */
|
||||
} CloudInitArg, *PCloudInitArg;
|
||||
#endif
|
||||
|
||||
#if TLS_CONFIG_CLOUD_QQ
|
||||
|
||||
/**
|
||||
* 设置上传云端回调,errcode为0表示上传成功,cookie为自增
|
||||
* 的序号,和在调用tls_cloud_upload_data时得到的CloudData中
|
||||
* 的pCookie相同
|
||||
*
|
||||
*/
|
||||
typedef void (*upload_callback)(int32_t err_code, uint32_t cookie);
|
||||
|
||||
/** 云端回调数据格式 */
|
||||
typedef struct _Cloud_Callback_data {
|
||||
uint32_t property_id; /**< 属性ID */
|
||||
uint8_t *property_value; /**< 属性value,类型为字节数组 */
|
||||
uint32_t property_value_len; /**< 属性value的长度 */
|
||||
uint32_t seq; /**< 操作序号 */
|
||||
int32_t ret_code; /**< 收到cc datapoint,回复ACK时设置此值供H5页面使用 */
|
||||
} CloudCallbackData, *PCloudCallbackData;
|
||||
|
||||
/** 上传云端的数据格式 */
|
||||
typedef struct _CloudData
|
||||
{
|
||||
CloudCallbackData *datapoints; /**< 数据结构 */
|
||||
uint32_t datapoints_count; /**< 个数 */
|
||||
upload_callback cb; /**< 上传结果回调 */
|
||||
uint32_t *pCookie; /**< 自增的序号 */
|
||||
}CloudData,*PCloudData;
|
||||
|
||||
/** 初始化云参数定义 */
|
||||
typedef struct _Cloud_Init_arg{
|
||||
/* 硬件信息 */
|
||||
char* device_name; /**< 设备名称,'\0'结尾字符串长度不超过32字节,
|
||||
nettype为1时必须与网站注册的devicename一致 */
|
||||
char* sn; /**< 设备序列号,'\0'结尾字符串长度必须是16字节 */
|
||||
char* license; /**< 设备LICENSE */
|
||||
int32_t product_id; /**< 每一个厂商的每一种类型的设备对应的一个id */
|
||||
int32_t product_version; /**< 产品的版本信息,用于OTA,默认填0 */
|
||||
/** 密钥信息 */
|
||||
uint8_t* client_pub_key; /**< client公钥,每台设备生成后烧录到设备 */
|
||||
int32_t client_pub_key_len;
|
||||
uint8_t* auth_key; /**< authkey,每台设备生成后烧录到设备 */
|
||||
int32_t auth_key_len;
|
||||
} CloudInitArg, *PCloudInitArg;
|
||||
#endif
|
||||
#if TLS_CONFIG_CLOUD_ABLECLOUD
|
||||
|
||||
/** ABLECLOUD云端通信数据结构 */
|
||||
typedef struct _CloudData
|
||||
{
|
||||
u8 msg_id; /**< 消息ID,响应消息同云端下发的消息邋ID,主动上传任意 */
|
||||
u8 msg_code; /**< 消息Code,响应消息同云端下发的消息code,
|
||||
主动上传需要大于200 */
|
||||
u8 *data; /**< 数据 */
|
||||
uint32 datalen; /**< 数据长度 */
|
||||
} CloudData,*PCloudData, CloudCallbackData, *PCloudCallbackData;
|
||||
|
||||
/** 初始化云参数定义 */
|
||||
typedef struct _Cloud_Init_arg
|
||||
{
|
||||
u32 major_domain; /**< 主域ID */
|
||||
u16 sub_domain; /**< 子域ID */
|
||||
u8 private_key[112]; /**< 产品私钥 */
|
||||
u32 product_version; /**< 产品的版本信息,用于OTA */
|
||||
} CloudInitArg, *PCloudInitArg;
|
||||
#endif
|
||||
#if TLS_CONFIG_CLOUD_ELIAN
|
||||
enum
|
||||
{
|
||||
DATA_TYPE_BINARY = 0, /**< 二进制 */
|
||||
DATA_TYPE_TEXT = 1, /**< 文本格式 */
|
||||
DATA_TYPE_NV = 2, /**< 以空格分离的命令加参数的格式,
|
||||
如:power 34。 */
|
||||
DATA_TYPE_EL_CMD = 3, /**< 为4字节整数命令Id+4字节整数的值,
|
||||
如:140 (电源状态上报,14为整数;
|
||||
0也为整数,表示状态)。 */
|
||||
DATA_TYPE_INFRA = 6, /**< 红外格式 */
|
||||
DATA_TYPE_STATUS_REQ = 7,/**< 设备状态请求 */
|
||||
DATA_TYPE_EL_CMD2 = 8 /**< 为4字节整数命令Id+字符串格式的值,
|
||||
如:140 (电源状态上报,14为整数;
|
||||
0为字符串,表示状态)。 */
|
||||
};
|
||||
|
||||
/** 云端通信数据结构 */
|
||||
typedef struct _CloudData
|
||||
{
|
||||
const uint8_t* data; /**< 数据 */
|
||||
size_t datalen; /**< 数据长度 */
|
||||
u8 datatype;
|
||||
} CloudData,*PCloudData, CloudCallbackData, *PCloudCallbackData;
|
||||
|
||||
/** 初始化云参数定义 */
|
||||
typedef struct _Cloud_Init_arg
|
||||
{
|
||||
char* sn; /**< 设备序列号,'\0'结尾字符串长度
|
||||
必须是13字节 */
|
||||
} CloudInitArg, *PCloudInitArg;
|
||||
#endif
|
||||
|
||||
/** 设备在云端注册后得到的关于设备的信息 */
|
||||
typedef struct _Cloud_Dev_info{
|
||||
u8* device_id; /**< 设备ID */
|
||||
u8* access_token; /**< 设备token,和设备ID一起构成设备访问云的凭证 */
|
||||
}CloudDeviceInfo, *PCloudDeviceInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 设置云的回调
|
||||
*
|
||||
* @param[in] data
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
typedef int (*cloud_callback)(PCloudCallbackData data);
|
||||
|
||||
/**
|
||||
* @brief 设置云状态的回调,status为1表示设备在线,status为0表示
|
||||
设备不在线
|
||||
*
|
||||
* @param[in] status
|
||||
*
|
||||
* @retval 0 表示设备不在线
|
||||
* @retval 1 表示设备在线
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
typedef void (*cloud_online_status_callback)(int status);
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup cloud_APIs cloud APIs
|
||||
* @brief cloud APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cloud_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief 初始化云,user task初始化时调用,
|
||||
对京东云,arg为product_uuid,
|
||||
对其它云arg请查看CloudInitArg结构定义
|
||||
*
|
||||
* @param[in] arg
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_cloud_init(PCloudInitArg arg);
|
||||
|
||||
/**
|
||||
* @brief 注销云,设备下线时调用,销毁资源。block为0时,此函数立
|
||||
即返回,注销云在后台执行,block为1时,云注销完成后此函数
|
||||
返回。
|
||||
*
|
||||
* @param[in] block 是否阻塞,为1表示,直到云注销完成返回,
|
||||
为0表示,立即返回,云注销在后台执行完成
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_cloud_finish(u8 block);
|
||||
|
||||
/**
|
||||
* @brief 设备向云上传数据,包括对控制命令的响应,上传状态以及设
|
||||
备快照等
|
||||
*
|
||||
* @param[in] data
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_cloud_upload_data(PCloudData data);
|
||||
|
||||
/**
|
||||
* @brief 设置云的回调接口,是设备接收云的控制命令,推送消息等的
|
||||
唯一接口
|
||||
*
|
||||
* @param[in] callback
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_cloud_set_callback(cloud_callback callback);
|
||||
|
||||
/**
|
||||
* @brief 设置云状态的回调接口,设备上线,下线时回调此接口
|
||||
*
|
||||
* @param[in] callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_cloud_set_online_status_callback(cloud_online_status_callback callback);
|
||||
|
||||
/**
|
||||
* @brief 获得设备在云端注册后的设备相关信息,
|
||||
具体查看CloudDeviceInfo结构定义
|
||||
*
|
||||
* @param[in] info
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_cloud_get_device_info(PCloudDeviceInfo info);
|
||||
|
||||
/*
|
||||
* 以下extern开头的函数,需要开发者实现,具体实现查看wm_lsd_device_found.c,此为我们写的一个局域网设备发现的简单实现,
|
||||
* 开发者可以根据需要,写自己的设备发现实现,或者是局域网通信控制等。
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief 获得开发自定义的socket信息,count为最大支持的socket数,
|
||||
根据不同的云此参数有所不同
|
||||
*
|
||||
* @param[in] sockets
|
||||
* @param[in] count
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
extern int tls_cloud_get_custom_sockets(SOCKET** sockets, int count);
|
||||
|
||||
/**
|
||||
* @brief 开发者自定义socket接收数据的处理函数,此函数在socket接
|
||||
收到数据时被调用,
|
||||
开发者可根据SOCKET中的user_param判断是否为自定义socket
|
||||
,然后做相应的处理
|
||||
*
|
||||
* @param[in] data
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
extern int tls_cloud_socket_data_handler(CloudReadData* data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 通过socket发送数据,其中to和tolen只有udp时有效并且必须
|
||||
,tcp时to参数传入NULL
|
||||
*
|
||||
* @param[in] *sock
|
||||
* @param[in] *data
|
||||
* @param[in] size
|
||||
* @param[in] flags
|
||||
* @param[in] *to
|
||||
* @param[in] tolen
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_cloud_socket_sendto(SOCKET *sock, const void *data, size_t size, int flags,
|
||||
const struct sockaddr *to, socklen_t tolen);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif //TLS_CONFIG_CLOUD
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file wm_crypto.h
|
||||
*
|
||||
* @brief crypto driver module
|
||||
*
|
||||
* @author dave
|
||||
*
|
||||
* Copyright (c) 2014 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
#ifndef WM_CRYPTO_H
|
||||
#define WM_CRYPTO_H
|
||||
|
||||
/**
|
||||
* @brief Encrypt plain data by 128 AES crypto
|
||||
* @param[in] key the key for encryption
|
||||
* @param[in] iv the IV value for encryption
|
||||
* @param[in] data where the plain data stored
|
||||
* @param[in] data_len length of the plain data to be encrypted
|
||||
* @retval 0 finish Encryption successfully
|
||||
* @retval -1 Error
|
||||
* @note Encrypted data will be placed into the plain @data area
|
||||
*
|
||||
*/
|
||||
int aes_128_cbc_encrypt (const u8 *key, const u8 *iv, u8 *data, size_t data_len) ;
|
||||
|
||||
/**
|
||||
* @brief Decrypt data by 128 AES crypto
|
||||
* @param[in] key the key for encryption
|
||||
* @param[in] iv the IV value for encryption
|
||||
* @param[in] data where the plain data stored
|
||||
* @param[in] data_len length of the plain data to be decrypted
|
||||
* @retval 0 finish Decryption successfully
|
||||
* @retval -1 Error
|
||||
* @note plain data will be placed into the encrypted @data area
|
||||
*
|
||||
*/
|
||||
int aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data,
|
||||
size_t data_len);
|
||||
|
||||
/**
|
||||
* @brief XOR RC4 stream to given data with skip-stream-start
|
||||
* @param[in] key RC4 key
|
||||
* @param[in] keylen RC4 key length
|
||||
* @param[in] data data to be XOR'ed with RC4 stream
|
||||
* @param[in] data_len length of the plain data to be encrypted
|
||||
* @retval 0 finish Encryption/Decryption successfully
|
||||
* @retval -1 Error
|
||||
* @note this function should be used for Encryption & Decryption both For the Encryption, the plain @data
|
||||
* will be replaced by the encrypted output, and vice versa;
|
||||
*/
|
||||
int rc4(const u8 *key, size_t keylen, u8 *data, size_t data_len);
|
||||
|
||||
|
||||
/**
|
||||
* @brief MD5 hash for data vector
|
||||
* @param[in] addr Pointers to the data area
|
||||
* @param[in] len Lengths of the data block
|
||||
* @param[in] mac Buffer for the hash (16 bytes)
|
||||
* @retval 0 finish caculation successfully
|
||||
* @retval -1 Error
|
||||
* @note
|
||||
*/
|
||||
int md5(const u8 *addr, int len, u8 *mac);
|
||||
|
||||
/**
|
||||
* @brief HMAC-MD5 over data buffer (RFC 2104)
|
||||
* @param[in] key Key for HMAC operations
|
||||
* @param[in] keylen Length of the key in bytes
|
||||
* @param[in] data data to be caculated
|
||||
* @param[in] data_len Lengths of the data block
|
||||
* @param[in] mac Buffer for the hash (16 bytes)
|
||||
* @retval 0 finish caculation successfully
|
||||
* @retval -1 Error
|
||||
* @note
|
||||
*/
|
||||
int hmac_md5(const u8 *key, size_t key_len, const u8 *data, size_t data_len, u8 *mac);
|
||||
|
||||
/**
|
||||
* @brief SHA1 hash for data vector
|
||||
* @param[in] addr Pointers to the data area
|
||||
* @param[in] len Lengths of the data block
|
||||
* @param[in] mac Buffer for the hash (16 bytes)
|
||||
* @retval 0 finish caculation successfully
|
||||
* @retval -1 Error
|
||||
* @note
|
||||
*/
|
||||
|
||||
int sha1(const u8 *addr, int len, u8 *mac);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file wm_dhcp_server.h
|
||||
*
|
||||
* @brief DHCP SERVER
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef WM_DHCP_SERVER_H
|
||||
#define WM_DHCP_SERVER_H
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup DHCPS_APIs DHCPS APIs
|
||||
* @brief DHCP server APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup DHCPS_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function is used to start DHCP Server for a network
|
||||
interface
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @retval WM_SUCCESS success
|
||||
* @retval WM_FAILED failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
s8 tls_dhcps_start(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to stop DHCP server
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dhcps_stop(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to get station's IP address by
|
||||
MAC address
|
||||
*
|
||||
* @param[in] *mac STA's MAC address
|
||||
*
|
||||
* @retval ip_addr STA's IP address
|
||||
* @retval NULL Not found match IP with MAC address
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
ip_addr_t *tls_dhcps_getip(const u8 *mac);
|
||||
|
||||
/**
|
||||
* @brief This function is used to set DHCP server's DNS address
|
||||
*
|
||||
* @param[in] numdns the index of the DNS server to set must be 0 or 1
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dhcps_setdns(u8 numdns);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* WM_DHCP_SERVER_H */
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/**
|
||||
* @file wm_dlna_dmr.h
|
||||
*
|
||||
* @brief DLNA DMR API
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
#ifndef __WM__DLNA_DMR_H_
|
||||
#define __WM__DLNA_DMR_H_
|
||||
|
||||
enum dmr_control_type
|
||||
{
|
||||
CONTROL_GET = 0,
|
||||
CONTROL_SET
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for action callback functions
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
typedef void (*dmr_action_callback)(void);
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for control callback functions
|
||||
*
|
||||
* @param[in] type to get or set control
|
||||
* @param[in] channel the channel to control
|
||||
* @param[in] value the value of getting or wanting to set
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
typedef void (*dmr_control_callback)(enum dmr_control_type type, const char* channel, int* value);
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for getting the playing progress
|
||||
*
|
||||
* @param[in] totlen The total length of the playing media
|
||||
*
|
||||
* @returns the progress(0.0 ~ 1.0) of having been played
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
typedef float (*dmr_play_progress_callback)(int totlen);
|
||||
|
||||
/**
|
||||
* @brief This Function prototype for downloading media data finis-
|
||||
hed
|
||||
*
|
||||
* @param[in] buf The downloaded data this time
|
||||
* @param[in] datalen The length of buffer data
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
typedef void (*dmr_download_finish_callback)(char * buf, int datalen);
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup DLNA_APIs DLNA APIs
|
||||
* @brief DLNA DMR APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup DLNA_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function is used to register play callback which would
|
||||
be called while starting to play
|
||||
*
|
||||
* @param[in] callback the play callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_play_callback(dmr_action_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register stop callback which would
|
||||
be called while to stop
|
||||
*
|
||||
* @param[in] callback the stop callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_stop_callback(dmr_action_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register seek callback which would
|
||||
be called while to seek
|
||||
*
|
||||
* @param[in] callback the seek callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_seek_callback(dmr_action_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register pause callback which
|
||||
would be called while to pause
|
||||
*
|
||||
* @param[in] callback the pause callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_pause_callback(dmr_action_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register play progress callback
|
||||
which would be called while to get play progress
|
||||
*
|
||||
* @param[in] callback the play progress callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_play_progress_callback(dmr_play_progress_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register mute control callback
|
||||
which would be called while to get or set mute control
|
||||
*
|
||||
* @param[in] callback the mute control callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_mute_callback(dmr_control_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register volume control callback
|
||||
which would be called while to get or set volume control
|
||||
*
|
||||
* @param[in] callback the volume control callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_volume_callback(dmr_control_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register volumedb control callback
|
||||
which would be called while to get or set volumedb
|
||||
control
|
||||
*
|
||||
* @param[in] callback the volumedb control callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_volumedb_callback(dmr_control_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to register loudness control callback
|
||||
which would be called while to get or set loudness
|
||||
control
|
||||
*
|
||||
* @param[in] callback the loudness control callback
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dmr_set_loudness_callback(dmr_control_callback callback);
|
||||
|
||||
/**
|
||||
* @brief This function is used to initialize the media render
|
||||
*
|
||||
* @param[in] *friendly_name friendly name of the media render
|
||||
* @param[in] *uuid uuid of the media render
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_dmr_init(const char *friendly_name, const char *uuid);
|
||||
|
||||
/**
|
||||
* @brief This function is uesd to destroy the media render
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_dmr_destroy(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to trigger to download data from media
|
||||
server, the download_callback would be called when
|
||||
downloading finished
|
||||
*
|
||||
* @param[in] dest Destination address to download data
|
||||
* @param[in] downsize download size of this time
|
||||
* @param[in] download_callback download finished callback
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_dmr_download_data(char * dest, int downsize, dmr_download_finish_callback download_callback);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __WM__DLNA_DMR_H_ */
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file wm_dns_server.h
|
||||
*
|
||||
* @brief DNS SERVER
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef WM_DNS_SERVER_H
|
||||
#define WM_DNS_SERVER_H
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup DNSS_APIs DNSS APIs
|
||||
* @brief DNS server APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup DNSS_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function is used to start DNS service
|
||||
*
|
||||
* @param[in] *dnsname Specify the server's dns name
|
||||
*
|
||||
* @retval WM_SUCCESS success
|
||||
* @retval WM_FAILED failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
s8 tls_dnss_start(u8 *dnsname);
|
||||
|
||||
/**
|
||||
* @brief This function is used to stop DNS service
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dnss_stop(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* WM_DNS_SERVER_H */
|
||||
|
||||
@@ -0,0 +1,486 @@
|
||||
/**
|
||||
* @file wm_http_client.h
|
||||
*
|
||||
* @brief Http client APIs
|
||||
*
|
||||
* @author wanghf
|
||||
*
|
||||
* Copyright (c) 2014 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
#ifndef WM_HTTP_CLIENT_H
|
||||
#define WM_HTTP_CLIENT_H
|
||||
|
||||
#include "wm_config.h"
|
||||
#include "wm_type_def.h"
|
||||
#ifdef BOOL
|
||||
#undef BOOL
|
||||
#endif
|
||||
#ifdef UCHAR
|
||||
#undef UCHAR
|
||||
#endif
|
||||
#ifdef CHAR
|
||||
#undef CHAR
|
||||
#endif
|
||||
#ifdef UINT16
|
||||
#undef UINT16
|
||||
#endif
|
||||
#ifdef INT16
|
||||
#undef INT16
|
||||
#endif
|
||||
#ifdef UINT32
|
||||
#undef UINT32
|
||||
#endif
|
||||
#ifdef INT32
|
||||
#undef INT32
|
||||
#endif
|
||||
#ifdef UINT64
|
||||
#undef UINT64
|
||||
#endif
|
||||
#ifdef INT64
|
||||
#undef INT64
|
||||
#endif
|
||||
#ifdef ULONG
|
||||
#undef ULONG
|
||||
#endif
|
||||
#ifdef LONG
|
||||
#undef LONG
|
||||
#endif
|
||||
#define VOID void
|
||||
typedef int BOOL;
|
||||
typedef unsigned char UCHAR;
|
||||
//typedef signed char CHAR;
|
||||
typedef char CHAR;
|
||||
typedef unsigned short UINT16;
|
||||
typedef signed short INT16;
|
||||
typedef unsigned int UINT32;
|
||||
typedef signed int INT32;
|
||||
typedef unsigned long long UINT64;
|
||||
typedef long long INT64;
|
||||
typedef unsigned long ULONG;
|
||||
typedef signed long LONG;
|
||||
|
||||
|
||||
/* HTTP Status, API Return codes */
|
||||
/** HTTP Success status */
|
||||
#define HTTP_CLIENT_SUCCESS 0
|
||||
/** Unknown error */
|
||||
#define HTTP_CLIENT_UNKNOWN_ERROR 1
|
||||
/** an Invalid handle or possible bad pointer was passed to a function */
|
||||
#define HTTP_CLIENT_ERROR_INVALID_HANDLE 2
|
||||
/** Buffer too small or a failure while in memory allocation */
|
||||
#define HTTP_CLIENT_ERROR_NO_MEMORY 3
|
||||
/** an attempt to use an invalid socket handle was made */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_INVALID 4
|
||||
/** Can't send socket parameters */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_CANT_SET 5
|
||||
/** Error while resolving host name */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_RESOLVE 6
|
||||
/** Error while connecting to the remote server */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_CONNECT 7
|
||||
/** socket time out error */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_TIME_OUT 8
|
||||
/** Error while receiving data */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_RECV 9
|
||||
/** Error while sending data */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_SEND 10
|
||||
/** Error while receiving the remote HTTP headers */
|
||||
#define HTTP_CLIENT_ERROR_HEADER_RECV 11
|
||||
/** Could not find element within header */
|
||||
#define HTTP_CLIENT_ERROR_HEADER_NOT_FOUND 12
|
||||
/** The headers search clue was too large for the internal API buffer */
|
||||
#define HTTP_CLIENT_ERROR_HEADER_BIG_CLUE 13
|
||||
/** No content length was specified for the outgoing data. the caller should
|
||||
specify chunking mode in the session creation */
|
||||
#define HTTP_CLIENT_ERROR_HEADER_NO_LENGTH 14
|
||||
/** The HTTP chunk token that was received from the server was too big and possibly wrong */
|
||||
#define HTTP_CLIENT_ERROR_CHUNK_TOO_BIG 15
|
||||
/** Could not authenticate with the remote host */
|
||||
#define HTTP_CLIENT_ERROR_AUTH_HOST 16
|
||||
/** Could not authenticate with the remote proxy */
|
||||
#define HTTP_CLIENT_ERROR_AUTH_PROXY 17
|
||||
/** Bad or not supported HTTP verb was passed to a function */
|
||||
#define HTTP_CLIENT_ERROR_BAD_VERB 18
|
||||
/** a function received a parameter that was too large */
|
||||
#define HTTP_CLIENT_ERROR_LONG_INPUT 19
|
||||
/** The session state prevents the current function from proceeding */
|
||||
#define HTTP_CLIENT_ERROR_BAD_STATE 20
|
||||
/** Could not parse the chunk length while in chunked transfer */
|
||||
#define HTTP_CLIENT_ERROR_CHUNK 21
|
||||
/** Could not parse curtail elements from the URL (such as the host name, HTTP prefix act') */
|
||||
#define HTTP_CLIENT_ERROR_BAD_URL 22
|
||||
/** Could not detect key elements in the received headers */
|
||||
#define HTTP_CLIENT_ERROR_BAD_HEADER 23
|
||||
/** Error while attempting to resize a buffer */
|
||||
#define HTTP_CLIENT_ERROR_BUFFER_RSIZE 24
|
||||
/** Authentication schema is not supported */
|
||||
#define HTTP_CLIENT_ERROR_BAD_AUTH 25
|
||||
/** The selected authentication schema does not match the server response */
|
||||
#define HTTP_CLIENT_ERROR_AUTH_MISMATCH 26
|
||||
/** an element was missing while parsing the digest authentication challenge */
|
||||
#define HTTP_CLIENT_ERROR_NO_DIGEST_TOKEN 27
|
||||
/** Digest algorithem could be MD5 or MD5-sess other types are not supported */
|
||||
#define HTTP_CLIENT_ERROR_NO_DIGEST_ALG 28
|
||||
/** Binding error */
|
||||
#define HTTP_CLIENT_ERROR_SOCKET_BIND 29
|
||||
/** Tls negotiation error */
|
||||
#define HTTP_CLIENT_ERROR_TLS_NEGO 30
|
||||
/** Feature is not (yet) implemented */
|
||||
#define HTTP_CLIENT_ERROR_NOT_IMPLEMENTED 64
|
||||
/** HTTP end of stream message */
|
||||
#define HTTP_CLIENT_EOS 1000
|
||||
|
||||
// HTTP Session flags (Public flags)
|
||||
#define HTTP_CLIENT_FLAG_KEEP_ALIVE 0x00000001 // Set the keep alive header
|
||||
#define HTTP_CLIENT_FLAG_SEND_CHUNKED 0x00000002 // The outgoing should chunked
|
||||
#define HTTP_CLIENT_FLAG_NO_CACHE 0x00000004 // Set the no cache header
|
||||
#define HTTP_CLIENT_FLAG_ASYNC 0x00000008 // Currently not implemented
|
||||
#define HTTP_CLIENT_FLAG_MULTIPART_FORM 0x00000010 // The outgoing should multipart/form-data
|
||||
|
||||
// HTTP Type Definitions
|
||||
typedef UINT32 HTTP_SESSION_HANDLE;
|
||||
typedef UINT32 HTTP_CLIENT_SESSION_FLAGS;
|
||||
/******************************************************************************
|
||||
*
|
||||
* Section : HTTP API structures
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* HTTP Type Definitions */
|
||||
/** http seesion handle */
|
||||
typedef u32 tls_http_session_handle_t;
|
||||
/** http seesion flags */
|
||||
typedef u32 tls_http_session_flags_t;
|
||||
|
||||
/** HTTP Supported authentication methods */
|
||||
typedef enum _HTTP_AUTH_SCHEMA
|
||||
{
|
||||
AuthSchemaNone = 0,
|
||||
AuthSchemaBasic,
|
||||
AuthSchemaDigest,
|
||||
AuthSchemaKerberos,
|
||||
AuthNotSupported
|
||||
|
||||
} HTTP_AUTH_SCHEMA;
|
||||
/** HTTP supported verbs */
|
||||
typedef enum _HTTP_VERB
|
||||
{
|
||||
VerbGet = 0,
|
||||
VerbHead,
|
||||
VerbPost,
|
||||
VerbPut,
|
||||
VerbFwup,
|
||||
VerbNotSupported
|
||||
// Note: others verb such as connect and put are currently not supported
|
||||
|
||||
} HTTP_VERB;
|
||||
/** Data structure that the caller can request at any time that will include
|
||||
some information regarding the session */
|
||||
typedef struct _HTTP_CLIENT
|
||||
{
|
||||
UINT32 HTTPStatusCode; // HTTP Status code (200 OK)
|
||||
UINT32 RequestBodyLengthSent; // Total bytes sent (body only)
|
||||
UINT32 ResponseBodyLengthReceived; // Total bytes received (body only)
|
||||
UINT32 TotalResponseBodyLength; // as extracted from the “content-length" header
|
||||
UINT32 HttpState;
|
||||
} HTTP_CLIENT;
|
||||
|
||||
/** HTTP parameters */
|
||||
typedef struct _HTTPParameters
|
||||
{
|
||||
CHAR* Uri;
|
||||
CHAR* ProxyHost;
|
||||
UINT32 UseProxy ;
|
||||
UINT32 ProxyPort;
|
||||
UINT32 Verbose;
|
||||
CHAR* UserName;
|
||||
CHAR* Password;
|
||||
HTTP_AUTH_SCHEMA AuthType;
|
||||
|
||||
} HTTPParameters;
|
||||
|
||||
#if TLS_CONFIG_HTTP_CLIENT_TASK
|
||||
/** the callback function of http clent for received */
|
||||
typedef void (*http_client_recv_callback_fn)(HTTP_SESSION_HANDLE pSession, CHAR * data, UINT32 totallen, UINT32 datalen);
|
||||
/** the callback function of http clent for err */
|
||||
typedef void (*http_client_err_callback_fn)(HTTP_SESSION_HANDLE pSession, int err);
|
||||
|
||||
/** message of the http client */
|
||||
typedef struct _http_client_msg
|
||||
{
|
||||
HTTP_SESSION_HANDLE pSession;
|
||||
HTTPParameters param;
|
||||
HTTP_VERB method;
|
||||
CHAR* sendData;
|
||||
UINT32 dataLen;
|
||||
http_client_recv_callback_fn recv_fn;
|
||||
http_client_err_callback_fn err_fn;
|
||||
} http_client_msg;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup HTTPC_APIs HTTPC APIs
|
||||
* @brief HTTP client APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup HTTPC_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Section : HTTP API public interface
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Allocate memory for a new HTTP Session
|
||||
*
|
||||
* @param[in] Flags HTTP Session internal API flags, 0 should be passed here
|
||||
*
|
||||
* @retval 0 failed
|
||||
* @retval other HTTP Session handle
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
HTTP_SESSION_HANDLE HTTPClientOpenRequest (HTTP_CLIENT_SESSION_FLAGS Flags);
|
||||
/**
|
||||
* @brief Closes the active connection and free the corresponding memory
|
||||
*
|
||||
* @param[in] *pSession HTTP Session handle
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientCloseRequest (HTTP_SESSION_HANDLE *pSession);
|
||||
/**
|
||||
* @brief Sets the HTTP authentication schema
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] AuthSchema HTTP Supported authentication methods
|
||||
* @param[in] *pReserved Reserved parameter
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientSetAuth (HTTP_SESSION_HANDLE pSession, HTTP_AUTH_SCHEMA AuthSchema, void *pReserved);
|
||||
/**
|
||||
* @brief Sets credentials for the target host
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] *pUserName User name
|
||||
* @param[in] *pPassword Password
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientSetCredentials (HTTP_SESSION_HANDLE pSession, CHAR *pUserName, CHAR *pPassword);
|
||||
/**
|
||||
* @brief Sets all the proxy related parameters
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] *pProxyName The host name
|
||||
* @param[in] nPort The proxy port number
|
||||
* @param[in] *pUserName User name for proxy authentication (can be null)
|
||||
* @param[in] *pPassword User password for proxy authentication (can be null)
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientSetProxy (HTTP_SESSION_HANDLE pSession, CHAR *pProxyName, UINT16 nPort, CHAR *pUserName, CHAR *pPassword);
|
||||
/**
|
||||
* @brief Sets the HTTP verb for the outgoing request
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] HttpVerb HTTP supported verbs
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientSetVerb (HTTP_SESSION_HANDLE pSession, HTTP_VERB HttpVerb);
|
||||
/**
|
||||
* @brief Add headers into the outgoing request
|
||||
*
|
||||
* @param[in] pSession HTTP Session
|
||||
* @param[in] *pHeaderName The Header name
|
||||
* @param[in] *pHeaderData The header data
|
||||
* @param[in] nInsert Reserved, could be any
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientAddRequestHeaders (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderName, CHAR *pHeaderData, BOOL nInsert);
|
||||
/**
|
||||
* @brief This function builds the request headers, performs a DNS resolution,
|
||||
* opens the connection (if it was not opened yet by a previous request
|
||||
* or if it has closed) and sends the request headers
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] *pUrl The requested URL
|
||||
* @param[in] *pData Data to post to the server
|
||||
* @param[in] nDataLength Length of posted data
|
||||
* @param[in] TotalLength Valid only when http method is post
|
||||
* TRUE: Post data to http server.
|
||||
* FALSE: In a post request without knowing the total
|
||||
* length in advance so return error or use chunking.
|
||||
* @param[in] nTimeout Operation timeout
|
||||
* @param[in] nClientPort Client side port 0 for none
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientSendRequest (HTTP_SESSION_HANDLE pSession, CHAR *pUrl, VOID *pData, UINT32 nDataLength, BOOL TotalLength, UINT32 nTimeout,UINT32 nClientPort);
|
||||
/**
|
||||
* @brief Write data to the remote server
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] *pBuffer Data to write to the server
|
||||
* @param[in] nBufferLength Length of wtitten data
|
||||
* @param[in] nTimeout Timeout for the operation
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientWriteData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, UINT32 nBufferLength, UINT32 nTimeout);
|
||||
/**
|
||||
* @brief Receives the response header on the connection and parses it.
|
||||
* Performs any required authentication.
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] nTimeout Timeout for the operation
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientRecvResponse (HTTP_SESSION_HANDLE pSession, UINT32 nTimeout);
|
||||
/**
|
||||
* @brief Read data from the server. Parse out the chunks data
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[out] *pBuffer A pointer to a buffer that will be filled with the servers response
|
||||
* @param[in] nBytesToRead The size of the buffer (numbers of bytes to read)
|
||||
* @param[in] nTimeout Operation timeout in seconds
|
||||
* @param[out] *nBytesRecived Count of the bytes that were received in this operation
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientReadData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, UINT32 nBytesToRead, UINT32 nTimeout, UINT32 *nBytesRecived);
|
||||
/**
|
||||
* @brief Fill the users structure with the session information
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[out] *HTTPClient The session information
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientGetInfo (HTTP_SESSION_HANDLE pSession, HTTP_CLIENT *HTTPClient);
|
||||
/**
|
||||
* @brief Initiate the headr searching functions and find the first header
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[in] *pSearchClue Search clue
|
||||
* @param[out] *pHeaderBuffer A pointer to a buffer that will be filled with the header name and value
|
||||
* @param[out] *nLength Count of the bytes that were received in this operation
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientFindFirstHeader (HTTP_SESSION_HANDLE pSession, CHAR *pSearchClue,CHAR *pHeaderBuffer, UINT32 *nLength);
|
||||
/**
|
||||
* @brief Find the next header.
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
* @param[out] *pHeaderBuffer A pointer to a buffer that will be filled with the header name and value
|
||||
* @param[out] *nLength Count of the bytes that were received in this operation
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientGetNextHeader (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderBuffer, UINT32 *nLength);
|
||||
/**
|
||||
* @brief Terminate a headers search session
|
||||
*
|
||||
* @param[in] pSession HTTP Session handle
|
||||
*
|
||||
* @retval HTTP_CLIENT_SUCCESS success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
UINT32 HTTPClientFindCloseHeader (HTTP_SESSION_HANDLE pSession);
|
||||
|
||||
#if TLS_CONFIG_HTTP_CLIENT_TASK
|
||||
/**
|
||||
* @brief initialize task of the http client
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @retval WM_SUCCESS success
|
||||
* @retval WM_FAILED failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int http_client_task_init(void);
|
||||
|
||||
/**
|
||||
* @brief post message to the task of http client
|
||||
*
|
||||
* @param[in] msg pointer to the message
|
||||
*
|
||||
* @retval ERR_OK success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int http_client_post(http_client_msg * msg);
|
||||
#endif /* TLS_CONFIG_HTTP_CLIENT_TASK */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* WM_HTTP_CLIENT_H */
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @file wm_netif.h
|
||||
*
|
||||
* @brief ETHERNET INIT Interface
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
#ifndef WM_NETIF_H
|
||||
#define WM_NETIF_H
|
||||
#include "wm_config.h"
|
||||
#include "wm_netif2.0.3.h"
|
||||
#endif /* WM_NETIF_H */
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
/**
|
||||
* @file wm_netif2.0.3.h
|
||||
*
|
||||
* @brief netif203 module
|
||||
*
|
||||
* @author dave
|
||||
*
|
||||
* Copyright (c) 2014 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef WM_NETIF2_0_3_H
|
||||
#define WM_NETIF2_0_3_H
|
||||
|
||||
#include "wm_config.h"
|
||||
#include "wm_type_def.h"
|
||||
#include "wm_sockets.h"
|
||||
#include "wm_wifi.h"
|
||||
#include "wm_params.h"
|
||||
|
||||
/** MACRO for callback EVENT to join AP or create soft-AP successfully */
|
||||
#define NETIF_WIFI_JOIN_SUCCESS 0x1
|
||||
/** MACRO for callback EVENT to fail to join AP */
|
||||
#define NETIF_WIFI_JOIN_FAILED 0x2
|
||||
/** MACRO for callback EVENT to disconnect from AP or destroy soft-AP */
|
||||
#define NETIF_WIFI_DISCONNECTED 0x3
|
||||
/** MACRO for callbck EVENT to get IP address */
|
||||
#define NETIF_IP_NET_UP 0x4
|
||||
/** MACRO for callback EVNET to create AP successfully */
|
||||
#define NETIF_WIFI_SOFTAP_SUCCESS 0x5
|
||||
/** MACRO for callback EVNET to create soft-AP failed */
|
||||
#define NETIF_WIFI_SOFTAP_FAILED 0x6
|
||||
/** MACRO for callback EVNET to close soft-AP */
|
||||
#define NETIF_WIFI_SOFTAP_CLOSED 0x7
|
||||
/** MACRO for callback EVNET to inform soft ap's net */
|
||||
#define NETIF_IP_NET2_UP 0x8
|
||||
|
||||
#define NETIF_IPV6_NET_UP 0x9
|
||||
|
||||
/** These are the values for ip_addr_t.type */
|
||||
#define IPADDR_TYPE_V4 0U
|
||||
#define IPADDR_TYPE_V6 6U
|
||||
#define IPADDR_TYPE_ANY 46U
|
||||
|
||||
#define IPV6_ADDR_MAX_NUM 3
|
||||
|
||||
#if 0
|
||||
struct ip_addr {
|
||||
u32_t addr;
|
||||
};
|
||||
|
||||
typedef struct ip_addr ip_addr_t;
|
||||
#endif
|
||||
#if 0
|
||||
struct ip4_addr {
|
||||
u32_t addr;
|
||||
};
|
||||
typedef struct ip4_addr ip4_addr_t;
|
||||
|
||||
struct ip6_addr {
|
||||
u32_t addr[4];
|
||||
};
|
||||
typedef struct ip6_addr ip6_addr_t;
|
||||
|
||||
#if (TLS_CONFIG_IPV4 && TLS_CONFIG_IPV6)
|
||||
typedef struct _ip_addr {
|
||||
union {
|
||||
ip6_addr_t ip6;
|
||||
ip4_addr_t ip4;
|
||||
} u_addr;
|
||||
u8_t type;
|
||||
} ip_addr_t;
|
||||
#else
|
||||
#if TLS_CONFIG_IPV4
|
||||
typedef ip4_addr_t ip_addr_t;
|
||||
#else
|
||||
typedef ip6_addr_t ip_addr_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
struct tls_ethif {
|
||||
ip_addr_t ip_addr;
|
||||
ip_addr_t netmask;
|
||||
ip_addr_t gw;
|
||||
#if TLS_CONFIG_IPV6
|
||||
ip_addr_t ip6_addr[IPV6_ADDR_MAX_NUM];
|
||||
#endif
|
||||
ip_addr_t dns1;
|
||||
ip_addr_t dns2;
|
||||
u8 status; //0:net down; 1:net up
|
||||
#if TLS_CONFIG_IPV6
|
||||
u8 ipv6_status[IPV6_ADDR_MAX_NUM]; //0:net down; 1:net up
|
||||
#endif
|
||||
};
|
||||
|
||||
//type defination of netif status changed callback.
|
||||
typedef void (*tls_netif_status_event_fn)(u8 status);
|
||||
|
||||
/**
|
||||
* @brief This function is used to initialize TCP/IP Stack
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval other failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_ethernet_init(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to get IP information stored in
|
||||
tls_ethif struct
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval tls_ethif * Pointer to struct tls_ethif
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
struct tls_ethif * tls_netif_get_ethif(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to set tls_ethif status
|
||||
*
|
||||
* @param[in] status net status, 0-up, 1-down
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_netif_set_status(u8 status);
|
||||
|
||||
/**
|
||||
* @brief This function is used to start DHCP Client
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
err_t tls_dhcp_start(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to stop DHCP client
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
err_t tls_dhcp_stop(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to change IP information
|
||||
*
|
||||
* @param[in] *ipaddr IP address
|
||||
* @param[in] *netmask netmask
|
||||
* @param[in] *gw default gateway
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
err_t tls_netif_set_addr(ip_addr_t *ipaddr,
|
||||
ip_addr_t *netmask,
|
||||
ip_addr_t *gw);
|
||||
|
||||
/**
|
||||
* @brief This function is used to set dns servers
|
||||
*
|
||||
* @param[in] numdns index of the DNS server to set
|
||||
must be < DNS_MAX_SERVERS
|
||||
* @param[in] *dnsserver IP address of the DNS server to set
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_netif_dns_setserver(u8 numdns, ip_addr_t *dnsserver);
|
||||
|
||||
/**
|
||||
* @brief This function is used to bring up an interface,available
|
||||
for processing traffic
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
err_t tls_netif_set_up(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to bring down an interface,disabling
|
||||
any traffic processing
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
err_t tls_netif_set_down(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to add netif status changed callback
|
||||
to event list,if exists, do nothing
|
||||
*
|
||||
* @param[in] event_fn pointer to tls_netif_status_event_fn
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
err_t tls_netif_add_status_event(tls_netif_status_event_fn event_fn);
|
||||
|
||||
/**
|
||||
* @brief This function is used to remove netif status changed
|
||||
callback function from event list,if not exists, do nothing
|
||||
*
|
||||
* @param[in] event_fn pointer to tls_netif_status_event_fn
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
err_t tls_netif_remove_status_event(tls_netif_status_event_fn event_fn);
|
||||
|
||||
struct netif *tls_get_netif(void);
|
||||
|
||||
#if TLS_CONFIG_AP
|
||||
/**
|
||||
* @brief Start DHCP Server for a network interface
|
||||
* *
|
||||
* @retval DHCPS_ERR_SUCCESS - No error
|
||||
* @retval DHCPS_ERR_MEM - Out of memory
|
||||
* @retval DHCPS_ERR_LINKDOWN - The NI is inactive
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
INT8S tls_dhcps_start(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to stop DHCP Server
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dhcps_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Start the dns server's service
|
||||
* *
|
||||
* @retval DHCPS_ERR_SUCCESS - No error
|
||||
* @retval DHCPS_ERR_MEM - Out of memory
|
||||
* @retval DHCPS_ERR_LINKDOWN - The NI is inactive
|
||||
* @retval DNSS_ERR_PARAM - Input parameter error
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
INT8S tls_dnss_start(INT8U * DnsName);
|
||||
|
||||
/**
|
||||
* @brief Stop the dns server's service
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_dnss_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Get station's ip address by mac address
|
||||
*
|
||||
* @param[in] mac station's mac address
|
||||
*
|
||||
* @retval ip_addr station's ip address
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
ip_addr_t *tls_dhcps_getip(const u8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Get station's mac address by ip address
|
||||
*
|
||||
* @param[in] ip station's ip address
|
||||
*
|
||||
* @retval u8* station's mac address
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
u8 *tls_dhcps_getmac(const ip_addr_t *ip);
|
||||
#endif //TLS_CONFIG_AP
|
||||
|
||||
#if TLS_CONFIG_RMMS
|
||||
/**
|
||||
* @brief Start remote manager server.
|
||||
* *
|
||||
* @retval DHCPS_ERR_SUCCESS - No error
|
||||
* @retval DHCPS_ERR_MEM - Out of memory
|
||||
* @retval DHCPS_ERR_LINKDOWN - The NIF is inactive
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
INT8S tls_rmms_start(void);
|
||||
|
||||
/**
|
||||
* @brief Disable remote manager server
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_rmms_stop(void);
|
||||
#endif
|
||||
|
||||
#if TLS_CONFIG_AP
|
||||
/**
|
||||
* @brief This is used to bring up an interface for APSTA,available
|
||||
for processing traffic
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note Can only be used at APSTA mode
|
||||
*/
|
||||
err_t tls_netif2_set_up(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to bring down an interface for APSTA, disabling
|
||||
any traffic processing
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note Can only be used at APSTA mode
|
||||
*/
|
||||
err_t tls_netif2_set_down(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to change IP information for
|
||||
a network interface for APSTA
|
||||
*
|
||||
* @param[in] *ipaddr IP address
|
||||
* @param[in] *netmask netmask
|
||||
* @param[in] *gw default gateway
|
||||
*
|
||||
* @retval 0 success
|
||||
* @retval Minus failed
|
||||
*
|
||||
* @note Can only be used at APSTA mode
|
||||
*/
|
||||
err_t tls_netif2_set_addr(ip_addr_t *ipaddr,
|
||||
ip_addr_t *netmask,
|
||||
ip_addr_t *gw);
|
||||
/***************************************************************************
|
||||
* Function: tls_dhcps_setdns
|
||||
* Description: Set dhcp server's dns address.
|
||||
*
|
||||
* Input: numdns: the index of the DNS server to set must be less than DNS_MAX_SERVERS
|
||||
*
|
||||
* Output: None
|
||||
*
|
||||
* Return: None
|
||||
*
|
||||
* Date : 2015-3-10
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @brief Set dhcp server's dns address
|
||||
*
|
||||
* @param[in] numdns the index of the DNS server to set must be less than DNS_MAX_SERVERS
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note Can only be used at APSTA mode
|
||||
*/
|
||||
void tls_dhcps_setdns(u8_t numdns);
|
||||
#endif
|
||||
|
||||
#endif //WM_NETIF_H
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @file wm_ntp.h
|
||||
*
|
||||
* @brief ntp module
|
||||
*
|
||||
* @author dave
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef WM_NTP_H
|
||||
#define WM_NTP_H
|
||||
|
||||
#include "wm_type_def.h"
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup NTP_APIs NTP APIs
|
||||
* @brief NTP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup NTP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function is used to get network time.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @retval time value
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
u32 tls_ntp_client(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to set ntp servers.
|
||||
*
|
||||
* @param[in] *ipaddr xxx.xxx.xxx.xxx
|
||||
* @param[in] server_no max num is three
|
||||
*
|
||||
* @retval WM_SUCCESS success
|
||||
* @retval WM_FAILED failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_ntp_set_server(char *ipaddr, int server_no);
|
||||
|
||||
/**
|
||||
* @brief This function is used to query params of the ntp servers
|
||||
*
|
||||
*
|
||||
* @retval WM_SUCCESS success
|
||||
* @retval WM_FAILED failed
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_ntp_query_sntpcfg(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* WM_NTP_H */
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @file wm_webserver.h
|
||||
*
|
||||
* @brief WEB SERVER
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef __WEBSERVER_H__
|
||||
#define __WEBSERVER_H__
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup WEB_APIs WEB APIs
|
||||
* @brief WEB server APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup WEB_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function is used to start WEB SERVER service
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_webserver_init(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to deinit WEB SERVER service
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void httpd_deinit(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /*__WEBSERVER_H__*/
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
/**
|
||||
* @file wm_wifi_oneshot.h
|
||||
*
|
||||
* @brief Wi-Fi OneShot
|
||||
*
|
||||
* @author winnermicro
|
||||
*
|
||||
* Copyright (c) 2015 Winner Microelectronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef WM_WIFI_ONESHOT_H
|
||||
#define WM_WIFI_ONESHOT_H
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wm_type_def.h>
|
||||
#if (GCC_COMPILE==1)
|
||||
#include "wm_ieee80211_gcc.h"
|
||||
#else
|
||||
#include <wm_ieee80211.h>
|
||||
#endif
|
||||
#include "wm_config.h"
|
||||
|
||||
/** DEBUG USE MAC FILTER START */
|
||||
#define CONFIG_ONESHOT_MAC_FILTER 0
|
||||
extern int tls_filter_module_srcmac(u8 *mac);
|
||||
|
||||
|
||||
/** after onshot configuration, add random time to connect Wi-Fi */
|
||||
#define CONFIG_CONNECT_RANDOMTIME_AFTER_ONESHOT 0
|
||||
|
||||
|
||||
|
||||
#define ONESHOT_ON 1
|
||||
#define ONESHOT_OFF 0
|
||||
|
||||
/* ONE SHOT */
|
||||
/** UDP MULTICAST ONE SHOT */
|
||||
#define TLS_CONFIG_UDP_ONE_SHOT ONESHOT_OFF
|
||||
/** JD ONESHOT */
|
||||
#define TLS_CONFIG_UDP_JD_ONESHOT (ONESHOT_OFF&& TLS_CONFIG_UDP_ONE_SHOT)
|
||||
/** WinnerMicro ONSHOT */
|
||||
#define TLS_CONFIG_UDP_LSD_ONESHOT (ONESHOT_OFF&& TLS_CONFIG_UDP_ONE_SHOT)
|
||||
|
||||
#define TLS_CONFIG_UDP_LSD_SPECIAL (ONESHOT_OFF&& TLS_CONFIG_UDP_ONE_SHOT)
|
||||
|
||||
#define TLS_CONFIG_ONESHOT_DELAY_SPECIAL ONESHOT_OFF
|
||||
|
||||
/** AP ONESHOT */
|
||||
#define TLS_CONFIG_AP_MODE_ONESHOT (ONESHOT_OFF&&TLS_CONFIG_AP)
|
||||
#define TLS_CONFIG_WEB_SERVER_MODE (CFG_OFF&&TLS_CONFIG_AP_MODE_ONESHOT)
|
||||
#define TLS_CONFIG_SOCKET_MODE (CFG_OFF &&TLS_CONFIG_AP_MODE_ONESHOT && TLS_CONFIG_SOCKET_RAW)
|
||||
|
||||
|
||||
/** AIRKISS ONESHOT */
|
||||
#define TLS_CONFIG_AIRKISS_MODE_ONESHOT (ONESHOT_OFF && TLS_CONFIG_UDP_ONE_SHOT)
|
||||
#define AIRKISS_USE_SELF_WRITE 0
|
||||
|
||||
typedef enum{
|
||||
ONESHOT_SCAN_START,
|
||||
ONESHOT_SCAN_FINISHED,
|
||||
ONESHOT_SWITCH_CHANNEL,
|
||||
ONESHOT_STOP_TMP_CHAN_SWITCH,
|
||||
ONESHOT_STOP_CHAN_SWITCH,
|
||||
ONESHOT_HANDSHAKE_TIMEOUT,
|
||||
ONESHOT_RECV_TIMEOUT,
|
||||
ONESHOT_RECV_ERR,
|
||||
ONESHOT_STOP_DATA_CLEAR,
|
||||
ONESHOT_NET_UP,
|
||||
AP_SOCK_S_MSG_SOCKET_RECEIVE_DATA,
|
||||
AP_WEB_S_MSG_RECEIVE_DATA,
|
||||
AP_SOCK_S_MSG_SOCKET_CREATE,
|
||||
AP_SOCK_S_MSG_WJOIN_FAILD,
|
||||
}ONESHOT_MSG_ENUM;
|
||||
|
||||
/**
|
||||
* @defgroup APP_APIs APP APIs
|
||||
* @brief APP APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup APP_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Oneshot_APIs Oneshot APIs
|
||||
* @brief Wi-Fi oneshot APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Oneshot_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Handle wild packets coming from the air.
|
||||
*
|
||||
* @param[in] *hdr point to ieee80211 data header
|
||||
* @param[in] data_len data len of ieee80211 data
|
||||
*
|
||||
* @retval no mean
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
u8 tls_wifi_dataframe_recv(struct ieee80211_hdr *hdr, u32 data_len);
|
||||
|
||||
#if TLS_CONFIG_AIRKISS_MODE_ONESHOT
|
||||
/**
|
||||
* @brief This function is used to acknowledge app when airkiss process is done.
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void oneshot_airkiss_send_reply(void);
|
||||
/**
|
||||
* @brief This function is used to deal with airkiss's
|
||||
wild packet
|
||||
*
|
||||
* @param[in] *data ieee80211 packet
|
||||
* @param[in] data_len packet length
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_airkiss_recv(u8 *data, u16 data_len);
|
||||
/**
|
||||
* @brief This function is used to start airkiss
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_airkiss_start(void);
|
||||
/**
|
||||
* @brief This function is used to stop airkiss
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_airkiss_stop(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to change channel for airkiss
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_oneshot_airkiss_change_channel(void);
|
||||
#endif /*TLS_CONFIG_AIRKISS_MODE_ONESHOT*/
|
||||
|
||||
/**
|
||||
* @brief This function is used to init oneshot task
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note Not in use now
|
||||
*/
|
||||
int wm_oneshot_task_init(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to stop oneshot timer
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_oneshot_switch_channel_tim_stop(struct ieee80211_hdr *hdr);
|
||||
|
||||
/**
|
||||
* @brief This function is used to stop oneshot temp timer
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_oneshot_switch_channel_tim_temp_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Judge bssid&ssid if match
|
||||
*
|
||||
* @param[in] *ssid ssid to be compared
|
||||
* @param[in] ssid_len ssid length
|
||||
* @param[in] bssid bssid to be compared
|
||||
*
|
||||
* @retval 1: bssid&ssid match
|
||||
* @retval 0: bssid&ssid not match
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
int tls_oneshot_is_ssid_bssid_match(u8 *ssid, u8 ssid_len, u8 *bssid);
|
||||
|
||||
/**
|
||||
* @brief Find channel according to ssid
|
||||
*
|
||||
* @param[in] *ssid ssid to be compared
|
||||
* @param[in] ssid_len ssid length
|
||||
* @param[out] chlist chlist to be add according to ssid info
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_oneshot_find_chlist(u8 *ssid, u8 ssid_len, u16 *chlist);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
void wm_oneshot_netif_status_event(u8 status );
|
||||
|
||||
/**
|
||||
* @brief This function is used to set oneshot config mode.
|
||||
*
|
||||
* @param[in] flag, 0:one shot config
|
||||
* 1:softap socket config
|
||||
* 2:softap webserver config
|
||||
* @param[out] None
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_wifi_set_oneshot_config_mode(u8 flag);
|
||||
|
||||
/**
|
||||
* @brief This function is used to get oneshot config mode.
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @param[out] None
|
||||
*
|
||||
* @retval 0: one shot config
|
||||
* 1: softap socket config
|
||||
* 2: softap webserver config
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
u8 tls_wifi_get_oneshot_config_mode(void);
|
||||
|
||||
#if TLS_CONFIG_WEB_SERVER_MODE
|
||||
/**
|
||||
* @brief This function is used to send web config msg to oneshot task.
|
||||
*
|
||||
* @param[in] None
|
||||
*
|
||||
* @param[out] None
|
||||
*
|
||||
* @retval None
|
||||
*
|
||||
* @note None
|
||||
*/
|
||||
void tls_oneshot_send_web_connect_msg(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /*WM_WIFI_ONESHOT_H*/
|
||||
|
||||
Reference in New Issue
Block a user