add P4 & P5
This commit is contained in:
372
P5_SETR2/LibWIFI/Inc/es_wifi.h
Normal file
372
P5_SETR2/LibWIFI/Inc/es_wifi.h
Normal file
@@ -0,0 +1,372 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file es-wifi.h
|
||||
* @author MCD Application Team
|
||||
* @brief header file for the es-wifi module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __ES_WIFI_H
|
||||
#define __ES_WIFI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdbool.h"
|
||||
#include "stdio.h"
|
||||
#include "es_wifi_conf.h"
|
||||
|
||||
/* Exported Constants --------------------------------------------------------*/
|
||||
#define ES_WIFI_PAYLOAD_SIZE 1200
|
||||
/* Exported macro-------------------------------------------------------------*/
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
typedef int8_t (*IO_Init_Func)(uint16_t );
|
||||
typedef int8_t (*IO_DeInit_Func)( void);
|
||||
typedef void (*IO_Delay_Func)(uint32_t);
|
||||
typedef int16_t (*IO_Send_Func)( uint8_t *, uint16_t len, uint32_t);
|
||||
typedef int16_t (*IO_Receive_Func)(uint8_t *, uint16_t len, uint32_t);
|
||||
|
||||
|
||||
/* Exported typedef ----------------------------------------------------------*/
|
||||
typedef enum {
|
||||
ES_WIFI_INIT = 0,
|
||||
ES_WIFI_RESET = 1
|
||||
}
|
||||
ES_WIFI_InitMode_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ES_WIFI_STATUS_OK = 0,
|
||||
ES_WIFI_STATUS_REQ_DATA_STAGE = 1,
|
||||
ES_WIFI_STATUS_ERROR = 2,
|
||||
ES_WIFI_STATUS_TIMEOUT = 3,
|
||||
ES_WIFI_STATUS_IO_ERROR = 4,
|
||||
ES_WIFI_STATUS_UNEXPECTED_CLOSED_SOCKET = 5,
|
||||
ES_WIFI_STATUS_MODULE_CRASH = 6
|
||||
} ES_WIFI_Status_t;
|
||||
|
||||
#define ES_WIFI_ERROR_SPI_FAILED -1
|
||||
#define ES_WIFI_ERROR_WAITING_DRDY_RISING -2
|
||||
#define ES_WIFI_ERROR_WAITING_DRDY_FALLING -3
|
||||
#define ES_WIFI_ERROR_STUFFING_FOREVER -4
|
||||
#define ES_WIFI_ERROR_SPI_INIT -5
|
||||
|
||||
typedef enum {
|
||||
ES_WIFI_MODE_SINGLE = 0,
|
||||
ES_WIFI_MODE_MULTI = 1,
|
||||
} ES_WIFI_ConnMode_t;
|
||||
|
||||
typedef enum {
|
||||
ES_WIFI_TCP_CONNECTION = 0,
|
||||
ES_WIFI_UDP_CONNECTION = 1,
|
||||
ES_WIFI_UDP_LITE_CONNECTION = 2,
|
||||
ES_WIFI_TCP_SSL_CONNECTION = 3,
|
||||
ES_WIFI_MQTT_CONNECTION = 4,
|
||||
} ES_WIFI_ConnType_t;
|
||||
|
||||
/* Security settings for wifi network */
|
||||
typedef enum {
|
||||
ES_WIFI_SEC_OPEN = 0x00, /*!< Wifi is open */
|
||||
ES_WIFI_SEC_WEP = 0x01, /*!< Wired Equivalent Privacy option for wifi security. \note This mode can't be used when setting up ES_WIFI wifi */
|
||||
ES_WIFI_SEC_WPA = 0x02, /*!< Wi-Fi Protected Access */
|
||||
ES_WIFI_SEC_WPA2 = 0x03, /*!< Wi-Fi Protected Access 2 */
|
||||
ES_WIFI_SEC_WPA_WPA2= 0x04, /*!< Wi-Fi Protected Access with both modes */
|
||||
ES_WIFI_SEC_WPA2_TKIP= 0x05, /*!< Wi-Fi Protected Access with both modes */
|
||||
ES_WIFI_SEC_UNKNOWN = 0xFF, /*!< Wi-Fi Unknown Security mode */
|
||||
} ES_WIFI_SecurityType_t;
|
||||
|
||||
typedef enum {
|
||||
ES_WIFI_IPV4 = 0x00,
|
||||
ES_WIFI_IPV6 = 0x01,
|
||||
} ES_WIFI_IPVer_t;
|
||||
|
||||
typedef enum {
|
||||
ES_WIFI_AP_NONE = 0x00,
|
||||
ES_WIFI_AP_ASSIGNED = 0x01,
|
||||
ES_WIFI_AP_JOINED = 0x02,
|
||||
ES_WIFI_AP_ERROR = 0xFF,
|
||||
} ES_WIFI_APState_t;
|
||||
|
||||
typedef enum {
|
||||
ES_WIFI_FUNCTION_TLS = 0x00,
|
||||
ES_WIFI_FUNCTION_AWS = 0x01,
|
||||
} ES_WIFI_CredsFunction_t;
|
||||
|
||||
//FIXME should be the multiple read/write slot ??
|
||||
#define ES_WIFI_TLS_MULTIPLE_WRITE_SLOT 0
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Port;
|
||||
uint32_t BaudRate;
|
||||
uint32_t DataWidth;
|
||||
uint32_t Parity;
|
||||
uint32_t StopBits;
|
||||
uint32_t Mode;
|
||||
} ES_WIFI_UARTConfig_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Configuration;
|
||||
uint32_t WPSPin;
|
||||
uint32_t VID;
|
||||
uint32_t PID;
|
||||
uint8_t MAC[6];
|
||||
uint8_t AP_IPAddress[4];
|
||||
uint32_t PS_Mode;
|
||||
uint32_t RadioMode;
|
||||
uint32_t CurrentBeacon;
|
||||
uint32_t PrevBeacon;
|
||||
uint32_t ProductName;
|
||||
} ES_WIFI_SystemConfig_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t* Address; /*!< Pointer to domain or IP to ping */
|
||||
uint32_t Time; /*!< Time in milliseconds needed for pinging */
|
||||
uint8_t Success; /*!< Status indicates if ping was successful */
|
||||
} ES_WIFI_Ping_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1]; /*!< Service Set Identifier value.Wi-Fi spot name */
|
||||
ES_WIFI_SecurityType_t Security; /*!< Security of Wi-Fi spot. */
|
||||
int16_t RSSI; /*!< Signal strength of Wi-Fi spot */
|
||||
uint8_t MAC[6]; /*!< MAC address of spot */
|
||||
uint8_t Channel; /*!< Wi-Fi channel */
|
||||
} ES_WIFI_AP_t;
|
||||
|
||||
/* Access point configuration */
|
||||
typedef struct {
|
||||
uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1]; /*!< Network public name for ESP AP mode */
|
||||
uint8_t Pass[ES_WIFI_MAX_PSWD_NAME_SIZE + 1]; /*!< Network password for ESP AP mode */
|
||||
ES_WIFI_SecurityType_t Security; /*!< Security of Wi-Fi spot. This parameter can be a value of \ref ESP8266_Ecn_t enumeration */
|
||||
uint8_t Channel; /*!< Channel Wi-Fi is operating at */
|
||||
uint8_t MaxConnections; /*!< Max number of stations that are allowed to connect to ESP AP, between 1 and 4 */
|
||||
uint8_t Hidden; /*!< Set to 1 if network is hidden (not broadcast) or zero if noz */
|
||||
} ES_WIFI_APConfig_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1]; /*!< Network public name for ESP AP mode */
|
||||
uint8_t IP_Addr[4]; /*!< IP Address */
|
||||
uint8_t MAC_Addr[6]; /*!< MAC address */
|
||||
} ES_WIFI_APSettings_t;
|
||||
|
||||
typedef struct {
|
||||
ES_WIFI_AP_t AP[ES_WIFI_MAX_DETECTED_AP];
|
||||
uint8_t nbr;
|
||||
} ES_WIFI_APs_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t SSID[ES_WIFI_MAX_SSID_NAME_SIZE + 1];
|
||||
uint8_t pswd[ES_WIFI_MAX_PSWD_NAME_SIZE + 1];
|
||||
ES_WIFI_SecurityType_t Security;
|
||||
uint8_t DHCP_IsEnabled;
|
||||
uint8_t JoinRetries;
|
||||
uint8_t IsConnected;
|
||||
uint8_t AutoConnect;
|
||||
ES_WIFI_IPVer_t IP_Ver;
|
||||
uint8_t IP_Addr[4];
|
||||
uint8_t IP_Mask[4];
|
||||
uint8_t Gateway_Addr[4];
|
||||
uint8_t DNS1[4];
|
||||
uint8_t DNS2[4];
|
||||
} ES_WIFI_Network_t;
|
||||
|
||||
typedef struct {
|
||||
ES_WIFI_ConnType_t Protocol;
|
||||
uint8_t Local_IP_Addr[4];
|
||||
uint16_t Local_Port;
|
||||
uint8_t Remote_IP_Addr[4];
|
||||
uint16_t Remote_Port;
|
||||
uint8_t TCP_Server;
|
||||
uint8_t UDP_Server;
|
||||
uint8_t TCP_Backlogs;
|
||||
uint8_t Accept_Loop;
|
||||
uint8_t Read_Mode;
|
||||
} ES_WIFI_Transport_t;
|
||||
|
||||
#if (ES_WIFI_USE_AWS == 1)
|
||||
typedef struct {
|
||||
ES_WIFI_ConnType_t Type;
|
||||
uint8_t Number;
|
||||
uint16_t RemotePort;
|
||||
uint8_t RemoteIP[4];
|
||||
uint8_t *PublishTopic;
|
||||
uint8_t *SubscribeTopic;
|
||||
uint8_t *ClientID;
|
||||
uint8_t MQTTMode;
|
||||
} ES_WIFI_AWS_Conn_t;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
ES_WIFI_ConnType_t Type;
|
||||
uint8_t Number;
|
||||
uint16_t RemotePort;
|
||||
uint16_t LocalPort;
|
||||
uint8_t RemoteIP[4];
|
||||
char* Name;
|
||||
uint8_t Backlog;
|
||||
} ES_WIFI_Conn_t;
|
||||
|
||||
typedef struct {
|
||||
IO_Init_Func IO_Init;
|
||||
IO_DeInit_Func IO_DeInit;
|
||||
IO_Delay_Func IO_Delay;
|
||||
IO_Send_Func IO_Send;
|
||||
IO_Receive_Func IO_Receive;
|
||||
} ES_WIFI_IO_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t Product_ID[ES_WIFI_PRODUCT_ID_SIZE];
|
||||
uint8_t FW_Rev[ES_WIFI_FW_REV_SIZE];
|
||||
uint8_t API_Rev[ES_WIFI_API_REV_SIZE];
|
||||
uint8_t Stack_Rev[ES_WIFI_STACK_REV_SIZE];
|
||||
uint8_t RTOS_Rev[ES_WIFI_RTOS_REV_SIZE];
|
||||
uint8_t Product_Name[ES_WIFI_PRODUCT_NAME_SIZE];
|
||||
uint32_t CPU_Clock;
|
||||
ES_WIFI_SecurityType_t Security;
|
||||
ES_WIFI_Network_t NetSettings;
|
||||
ES_WIFI_APSettings_t APSettings;
|
||||
ES_WIFI_IO_t fops;
|
||||
uint8_t CmdData[ES_WIFI_DATA_SIZE];
|
||||
uint32_t Timeout;
|
||||
uint32_t BufferSize;
|
||||
} ES_WIFIObject_t;
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
ES_WIFI_Status_t ES_WIFI_Init(ES_WIFIObject_t *Obj);
|
||||
ES_WIFI_Status_t ES_WIFI_SetTimeout(ES_WIFIObject_t *Obj, uint32_t Timeout);
|
||||
ES_WIFI_Status_t ES_WIFI_ListAccessPoints(ES_WIFIObject_t *Obj, ES_WIFI_APs_t *APs);
|
||||
ES_WIFI_Status_t ES_WIFI_Connect(ES_WIFIObject_t *Obj, const char* SSID, const char* Password,
|
||||
ES_WIFI_SecurityType_t SecType);
|
||||
ES_WIFI_Status_t ES_WIFI_Disconnect(ES_WIFIObject_t *Obj);
|
||||
uint8_t ES_WIFI_IsConnected(ES_WIFIObject_t *Obj);
|
||||
ES_WIFI_Status_t ES_WIFI_GetNetworkSettings(ES_WIFIObject_t *Obj);
|
||||
ES_WIFI_Status_t ES_WIFI_GetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac);
|
||||
ES_WIFI_Status_t ES_WIFI_GetIPAddress(ES_WIFIObject_t *Obj, uint8_t *ipaddr);
|
||||
ES_WIFI_Status_t ES_WIFI_GetProductID(ES_WIFIObject_t *Obj, uint8_t *productID);
|
||||
ES_WIFI_Status_t ES_WIFI_GetFWRevID(ES_WIFIObject_t *Obj, uint8_t *FWRev);
|
||||
ES_WIFI_Status_t ES_WIFI_GetRTOSRev(ES_WIFIObject_t *Obj, uint8_t *RTOSRev);
|
||||
ES_WIFI_Status_t ES_WIFI_GetProductName(ES_WIFIObject_t *Obj, uint8_t *productName);
|
||||
ES_WIFI_Status_t ES_WIFI_GetAPIRev(ES_WIFIObject_t *Obj, uint8_t *APIRev);
|
||||
ES_WIFI_Status_t ES_WIFI_GetStackRev(ES_WIFIObject_t *Obj, uint8_t *StackRev);
|
||||
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_SetMACAddress(ES_WIFIObject_t *Obj, uint8_t *mac);
|
||||
ES_WIFI_Status_t ES_WIFI_ResetToFactoryDefault(ES_WIFIObject_t *Obj);
|
||||
ES_WIFI_Status_t ES_WIFI_ResetModule(ES_WIFIObject_t *Obj);
|
||||
ES_WIFI_Status_t ES_WIFI_HardResetModule(ES_WIFIObject_t *Obj);
|
||||
ES_WIFI_Status_t ES_WIFI_SetProductName(ES_WIFIObject_t *Obj, uint8_t *ProductName);
|
||||
#if (ES_WIFI_USE_PING == 1)
|
||||
ES_WIFI_Status_t ES_WIFI_Ping(ES_WIFIObject_t *Obj, uint8_t *address, uint16_t count, uint16_t interval_ms, int32_t res[]);
|
||||
#endif
|
||||
ES_WIFI_Status_t ES_WIFI_DNS_LookUp(ES_WIFIObject_t *Obj, const char *url, uint8_t *ipaddress);
|
||||
ES_WIFI_Status_t ES_WIFI_StartClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn);
|
||||
ES_WIFI_Status_t ES_WIFI_StopClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn);
|
||||
#if (ES_WIFI_USE_AWS == 1)
|
||||
ES_WIFI_Status_t ES_WIFI_StartAWSClientConnection(ES_WIFIObject_t *Obj, ES_WIFI_AWS_Conn_t *conn);
|
||||
#endif
|
||||
ES_WIFI_Status_t ES_WIFI_StartServerSingleConn(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn);
|
||||
ES_WIFI_Status_t ES_WIFI_WaitServerConnection(ES_WIFIObject_t *Obj,uint32_t Timeout,ES_WIFI_Conn_t *);
|
||||
ES_WIFI_Status_t ES_WIFI_CloseServerConnection(ES_WIFIObject_t *Obj,int socket);
|
||||
ES_WIFI_Status_t ES_WIFI_StopServerSingleConn(ES_WIFIObject_t *Obj, int socket);
|
||||
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_StartServerMultiConn(ES_WIFIObject_t *Obj, ES_WIFI_Conn_t *conn);
|
||||
ES_WIFI_Status_t ES_WIFI_StopServerMultiConn(ES_WIFIObject_t *Obj,ES_WIFI_Conn_t *conn);
|
||||
ES_WIFI_Status_t ES_WIFI_SendData(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen , uint16_t *SentLen, uint32_t Timeout);
|
||||
ES_WIFI_Status_t ES_WIFI_SendDataTo(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen , uint16_t *SentLen, uint32_t Timeout, uint8_t *IPaddr, uint16_t Port);
|
||||
ES_WIFI_Status_t ES_WIFI_ReceiveData(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *Receivedlen, uint32_t Timeout);
|
||||
ES_WIFI_Status_t ES_WIFI_ReceiveDataFrom(ES_WIFIObject_t *Obj, uint8_t Socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *Receivedlen, uint32_t Timeout, uint8_t *IPaddr, uint16_t *pPort);
|
||||
ES_WIFI_Status_t ES_WIFI_ActivateAP(ES_WIFIObject_t *Obj, ES_WIFI_APConfig_t *ApConfig);
|
||||
ES_WIFI_APState_t ES_WIFI_WaitAPStateChange(ES_WIFIObject_t *Obj);
|
||||
|
||||
#if (ES_WIFI_USE_FIRMWAREUPDATE == 1)
|
||||
ES_WIFI_Status_t ES_WIFI_OTA_Upgrade(ES_WIFIObject_t *Obj, uint8_t *link);
|
||||
#endif
|
||||
|
||||
#if (ES_WIFI_USE_UART == 1)
|
||||
ES_WIFI_Status_t ES_WIFI_SetUARTBaudRate(ES_WIFIObject_t *Obj, uint16_t BaudRate);
|
||||
ES_WIFI_Status_t ES_WIFI_GetUARTConfig(ES_WIFIObject_t *Obj, ES_WIFI_UARTConfig_t *pconf);
|
||||
#endif
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_GetSystemConfig(ES_WIFIObject_t *Obj, ES_WIFI_SystemConfig_t *pconf);
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_RegisterBusIO(ES_WIFIObject_t *Obj, IO_Init_Func IO_Init,
|
||||
IO_DeInit_Func IO_DeInit,
|
||||
IO_Delay_Func IO_Delay,
|
||||
IO_Send_Func IO_Send,
|
||||
IO_Receive_Func IO_Receive);
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_StoreCreds( ES_WIFIObject_t *Obj,
|
||||
ES_WIFI_CredsFunction_t credsFunction, uint8_t credSet,
|
||||
uint8_t* ca, uint16_t caLength,
|
||||
uint8_t* certificate, uint16_t certificateLength,
|
||||
uint8_t* key, uint16_t keyLength );
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_StoreCA( ES_WIFIObject_t *Obj,
|
||||
ES_WIFI_CredsFunction_t credsFunction,
|
||||
uint8_t credSet,
|
||||
uint8_t* ca,
|
||||
uint16_t caLength );
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_StoreCertificate( ES_WIFIObject_t *Obj,
|
||||
ES_WIFI_CredsFunction_t credsFunction,
|
||||
uint8_t credSet,
|
||||
uint8_t* certificate,
|
||||
uint16_t certificateLength );
|
||||
|
||||
ES_WIFI_Status_t ES_WIFI_StoreKey( ES_WIFIObject_t *Obj,
|
||||
ES_WIFI_CredsFunction_t credsFunction,
|
||||
uint8_t credSet,
|
||||
uint8_t* key,
|
||||
uint16_t keyLength );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__ES_WIFI_H*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
80
P5_SETR2/LibWIFI/Inc/es_wifi_conf.h
Normal file
80
P5_SETR2/LibWIFI/Inc/es_wifi_conf.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file es_wifi_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief ES-WIFI configuration.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ES_WIFI_CONF_H
|
||||
#define ES_WIFI_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#define WIFI_USE_CMSIS_OS
|
||||
|
||||
#ifdef WIFI_USE_CMSIS_OS
|
||||
#include "cmsis_os.h"
|
||||
|
||||
extern osMutexId es_wifi_mutex;
|
||||
|
||||
#define LOCK_SPI() osMutexWait(spi_mutex, 0)
|
||||
#define UNLOCK_SPI() osMutexRelease(spi_mutex)
|
||||
#define LOCK_WIFI() osMutexWait(es_wifi_mutex, 0)
|
||||
#define UNLOCK_WIFI() osMutexRelease(es_wifi_mutex)
|
||||
#define SEM_SIGNAL(a) osSemaphoreRelease(a)
|
||||
#define SEM_WAIT(a,timeout) osSemaphoreWait(a,timeout)
|
||||
#define SPI_INTERFACE_PRIO configMAX_SYSCALL_INTERRUPT_PRIORITY
|
||||
#else
|
||||
|
||||
#define LOCK_WIFI()
|
||||
#define UNLOCK_WIFI()
|
||||
#define LOCK_SPI()
|
||||
#define UNLOCK_SPI()
|
||||
#define SEM_SIGNAL(a)
|
||||
#define SPI_INTERFACE_PRIO 0
|
||||
#endif
|
||||
|
||||
#define ES_WIFI_MAX_SSID_NAME_SIZE 32
|
||||
#define ES_WIFI_MAX_PSWD_NAME_SIZE 32
|
||||
#define ES_WIFI_PRODUCT_ID_SIZE 32
|
||||
#define ES_WIFI_PRODUCT_NAME_SIZE 32
|
||||
#define ES_WIFI_FW_REV_SIZE 24
|
||||
#define ES_WIFI_API_REV_SIZE 16
|
||||
#define ES_WIFI_STACK_REV_SIZE 16
|
||||
#define ES_WIFI_RTOS_REV_SIZE 16
|
||||
|
||||
#define ES_WIFI_DATA_SIZE 2000 /*Increased from 1400 to fit scan result.*/
|
||||
#define ES_WIFI_MAX_DETECTED_AP 10
|
||||
|
||||
#define ES_WIFI_TIMEOUT 30000
|
||||
|
||||
#define ES_WIFI_USE_PING 1
|
||||
#define ES_WIFI_USE_AWS 0
|
||||
#define ES_WIFI_USE_FIRMWAREUPDATE 0
|
||||
#define ES_WIFI_USE_WPS 0
|
||||
|
||||
#define ES_WIFI_USE_SPI 1
|
||||
#define ES_WIFI_USE_UART (!ES_WIFI_USE_SPI)
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ES_WIFI_CONF_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
67
P5_SETR2/LibWIFI/Inc/es_wifi_io.h
Normal file
67
P5_SETR2/LibWIFI/Inc/es_wifi_io.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file es_wifi_io.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the functions prototypes for es_wifi IO operations.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef WIFI_IO_H
|
||||
#define WIFI_IO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#define WIFI_RESET_MODULE() do{\
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, GPIO_PIN_RESET);\
|
||||
HAL_Delay(10);\
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, GPIO_PIN_SET);\
|
||||
HAL_Delay(500);\
|
||||
}while(0);
|
||||
|
||||
|
||||
#define WIFI_ENABLE_NSS() do{ \
|
||||
HAL_GPIO_WritePin( GPIOE, GPIO_PIN_0, GPIO_PIN_RESET );\
|
||||
}while(0);
|
||||
|
||||
#define WIFI_DISABLE_NSS() do{ \
|
||||
HAL_GPIO_WritePin( GPIOE, GPIO_PIN_0, GPIO_PIN_SET );\
|
||||
}while(0);
|
||||
|
||||
#define WIFI_IS_CMDDATA_READY() (HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_1) == GPIO_PIN_SET)
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void SPI_WIFI_MspInit(SPI_HandleTypeDef* hspi);
|
||||
int8_t SPI_WIFI_DeInit(void);
|
||||
int8_t SPI_WIFI_Init(uint16_t mode);
|
||||
int8_t SPI_WIFI_ResetModule(void);
|
||||
int16_t SPI_WIFI_ReceiveData(uint8_t *pData, uint16_t len, uint32_t timeout);
|
||||
int16_t SPI_WIFI_SendData( uint8_t *pData, uint16_t len, uint32_t timeout);
|
||||
void SPI_WIFI_Delay(uint32_t Delay);
|
||||
void SPI_WIFI_ISR(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WIFI_IO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
168
P5_SETR2/LibWIFI/Inc/wifi.h
Normal file
168
P5_SETR2/LibWIFI/Inc/wifi.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file wifi.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the different WiFi core resources definitions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef WIFI_H
|
||||
#define WIFI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "es_wifi.h"
|
||||
#include "es_wifi_io.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define WIFI_MAX_SSID_NAME 100
|
||||
#define WIFI_MAX_PSWD_NAME 100
|
||||
#define WIFI_MAX_APS 20
|
||||
#define WIFI_MAX_CONNECTIONS 4
|
||||
#define WIFI_MAX_MODULE_NAME 100
|
||||
#define WIFI_MAX_CONNECTED_STATIONS 2
|
||||
#define WIFI_MSG_JOINED 1
|
||||
#define WIFI_MSG_ASSIGNED 2
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
WIFI_ECN_OPEN = 0x00,
|
||||
WIFI_ECN_WEP = 0x01,
|
||||
WIFI_ECN_WPA_PSK = 0x02,
|
||||
WIFI_ECN_WPA2_PSK = 0x03,
|
||||
WIFI_ECN_WPA_WPA2_PSK = 0x04,
|
||||
}WIFI_Ecn_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_TCP_PROTOCOL = 0,
|
||||
WIFI_UDP_PROTOCOL = 1,
|
||||
}WIFI_Protocol_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_SERVER = 0,
|
||||
WIFI_CLIENT = 1,
|
||||
}WIFI_Type_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_STATUS_OK = 0,
|
||||
WIFI_STATUS_ERROR = 1,
|
||||
WIFI_STATUS_NOT_SUPPORTED = 2,
|
||||
WIFI_STATUS_JOINED = 3,
|
||||
WIFI_STATUS_ASSIGNED = 4,
|
||||
WIFI_STATUS_TIMEOUT = 5,
|
||||
}WIFI_Status_t;
|
||||
|
||||
typedef struct {
|
||||
WIFI_Ecn_t Ecn; /*!< Security of Wi-Fi spot. This parameter has a value of \ref WIFI_Ecn_t enumeration */
|
||||
char SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Service Set Identifier value. Wi-Fi spot name */
|
||||
int16_t RSSI; /*!< Signal strength of Wi-Fi spot */
|
||||
uint8_t MAC[6]; /*!< MAC address of spot */
|
||||
uint8_t Channel; /*!< Wi-Fi channel */
|
||||
uint8_t Offset; /*!< Frequency offset from base 2.4GHz in kHz */
|
||||
uint8_t Calibration; /*!< Frequency offset calibration */
|
||||
}WIFI_AP_t;
|
||||
|
||||
typedef struct {
|
||||
WIFI_AP_t ap[WIFI_MAX_APS];
|
||||
uint8_t count;
|
||||
} WIFI_APs_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t Number; /*!< Connection number */
|
||||
uint16_t RemotePort; /*!< Remote PORT number */
|
||||
uint16_t LocalPort;
|
||||
uint8_t RemoteIP[4]; /*!< IP address of device */
|
||||
WIFI_Protocol_t Protocol; /*!< Connection type. Parameter is valid only if connection is made as client */
|
||||
uint32_t TotalBytesReceived; /*!< Number of bytes received in entire connection lifecycle */
|
||||
uint32_t TotalBytesSent; /*!< Number of bytes sent in entire connection lifecycle */
|
||||
uint8_t Active; /*!< Status if connection is active */
|
||||
uint8_t Client; /*!< Set to 1 if connection was made as client */
|
||||
} WIFI_Socket_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t SSID[WIFI_MAX_SSID_NAME + 1];
|
||||
uint8_t PSWD[WIFI_MAX_PSWD_NAME + 1];
|
||||
uint8_t channel;
|
||||
WIFI_Ecn_t Ecn;
|
||||
} WIFI_APConfig_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Network public name for ESP AP mode */
|
||||
uint8_t IP_Addr[4]; /*!< IP Address */
|
||||
uint8_t MAC_Addr[6]; /*!< MAC address */
|
||||
} WIFI_APSettings_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t IsConnected;
|
||||
uint8_t IP_Addr[4];
|
||||
uint8_t IP_Mask[4];
|
||||
uint8_t Gateway_Addr[4];
|
||||
} WIFI_Conn_t;
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
WIFI_Status_t WIFI_Init(void);
|
||||
WIFI_Status_t WIFI_ListAccessPoints(WIFI_APs_t *APs, uint8_t AP_MaxNbr);
|
||||
WIFI_Status_t WIFI_Connect(
|
||||
const char* SSID,
|
||||
const char* Password,
|
||||
WIFI_Ecn_t ecn);
|
||||
WIFI_Status_t WIFI_GetIP_Address(uint8_t *ipaddr);
|
||||
WIFI_Status_t WIFI_GetMAC_Address(uint8_t *mac);
|
||||
|
||||
WIFI_Status_t WIFI_Disconnect(void);
|
||||
WIFI_Status_t WIFI_ConfigureAP(
|
||||
uint8_t *ssid,
|
||||
uint8_t *pass,
|
||||
WIFI_Ecn_t ecn,
|
||||
uint8_t channel,
|
||||
uint8_t max_conn);
|
||||
|
||||
WIFI_Status_t WIFI_HandleAPEvents(WIFI_APSettings_t *setting);
|
||||
WIFI_Status_t WIFI_Ping(uint8_t *ipaddr, uint16_t count, uint16_t interval_ms,int32_t result[]);
|
||||
WIFI_Status_t WIFI_GetHostAddress(const char *location, uint8_t *ipaddr);
|
||||
WIFI_Status_t WIFI_OpenClientConnection(uint32_t socket, WIFI_Protocol_t type, const char *name, uint8_t *ipaddr, uint16_t port, uint16_t local_port);
|
||||
WIFI_Status_t WIFI_CloseClientConnection(uint32_t socket);
|
||||
|
||||
WIFI_Status_t WIFI_StartServer(uint32_t socket, WIFI_Protocol_t type, uint16_t backlog, const char *name, uint16_t port);
|
||||
WIFI_Status_t WIFI_WaitServerConnection(int socket,uint32_t Timeout,uint8_t *remoteipaddr, uint16_t *remoteport);
|
||||
WIFI_Status_t WIFI_CloseServerConnection(int socket);
|
||||
WIFI_Status_t WIFI_StopServer(uint32_t socket);
|
||||
|
||||
WIFI_Status_t WIFI_SendData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *SentDatalen, uint32_t Timeout);
|
||||
WIFI_Status_t WIFI_SendDataTo(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *SentDatalen, uint32_t Timeout, uint8_t *ipaddr, uint16_t port);
|
||||
WIFI_Status_t WIFI_ReceiveData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *RcvDatalen, uint32_t Timeout);
|
||||
WIFI_Status_t WIFI_ReceiveDataFrom(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *RcvDatalen, uint32_t Timeout, uint8_t *ipaddr, uint16_t *port);
|
||||
WIFI_Status_t WIFI_StartClient(void);
|
||||
WIFI_Status_t WIFI_StopClient(void);
|
||||
|
||||
WIFI_Status_t WIFI_SetOEMProperties(const char *name, uint8_t *Mac);
|
||||
WIFI_Status_t WIFI_ResetModule(void);
|
||||
WIFI_Status_t WIFI_SetModuleDefault(void);
|
||||
WIFI_Status_t WIFI_ModuleFirmwareUpdate(const char *url);
|
||||
WIFI_Status_t WIFI_GetModuleID(char *Id);
|
||||
WIFI_Status_t WIFI_GetModuleFwRevision(char *rev);
|
||||
WIFI_Status_t WIFI_GetModuleName(char *ModuleName);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WIFI_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user