2016-05-21 17:13:23 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* apps/include/netutils/esp8266.h
|
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2016-05-21 17:13:23 +02:00
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-05-21 17:13:23 +02:00
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2016-05-21 17:13:23 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __APPS_INCLUDE_NETUTILS_ESP8266_H
|
|
|
|
#define __APPS_INCLUDE_NETUTILS_ESP8266_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "nuttx/config.h"
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_NETUTILS_ESP8266
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-12-04 15:35:02 +01:00
|
|
|
#define lespSSID_SIZE 32 /* Number of character max of SSID (null char not included) */
|
|
|
|
#define lespBSSID_SIZE 6
|
2016-05-21 17:13:23 +02:00
|
|
|
|
2016-05-21 19:11:32 +02:00
|
|
|
#define lespIP(x1,x2,x3,x4) ((x1) << 24 | (x2) << 16 | (x3) << 8 | (x4) << 0)
|
2016-05-21 17:13:23 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-12-04 15:35:02 +01:00
|
|
|
typedef enum
|
2016-05-21 17:13:23 +02:00
|
|
|
{
|
|
|
|
lesp_eMODE_AP = 0,
|
|
|
|
lesp_eMODE_STATION = 1,
|
2016-05-21 19:11:32 +02:00
|
|
|
lesp_eMODE_BOTH = 2
|
2016-05-21 17:13:23 +02:00
|
|
|
} lesp_mode_t;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2016-12-04 15:35:02 +01:00
|
|
|
lesp_eSECURITY_NONE = 0,
|
2016-05-21 17:13:23 +02:00
|
|
|
lesp_eSECURITY_WEP,
|
|
|
|
lesp_eSECURITY_WPA_PSK,
|
|
|
|
lesp_eSECURITY_WPA2_PSK,
|
|
|
|
lesp_eSECURITY_WPA_WPA2_PSK,
|
|
|
|
lesp_eSECURITY_NBR
|
|
|
|
} lesp_security_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
lesp_security_t security;
|
2021-06-11 11:07:52 +02:00
|
|
|
char ssid[lespSSID_SIZE + 1]; /* +1 for null char */
|
2016-05-21 17:13:23 +02:00
|
|
|
uint8_t bssid[lespBSSID_SIZE];
|
2016-12-04 15:35:02 +01:00
|
|
|
int rssi;
|
|
|
|
int channel;
|
2016-05-21 17:13:23 +02:00
|
|
|
} lesp_ap_t;
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int lesp_initialize(void);
|
|
|
|
int lesp_soft_reset(void);
|
|
|
|
|
|
|
|
const char *lesp_security_to_str(lesp_security_t security);
|
|
|
|
|
2021-06-11 11:07:52 +02:00
|
|
|
int lesp_ap_connect(const char *ssid_name,
|
|
|
|
const char *ap_key, int timeout_s);
|
2016-12-04 15:35:02 +01:00
|
|
|
int lesp_ap_get(lesp_ap_t *ap);
|
2016-05-21 17:13:23 +02:00
|
|
|
|
|
|
|
int lesp_ap_is_connected(void);
|
|
|
|
|
2016-12-04 15:35:02 +01:00
|
|
|
int lesp_set_dhcp(lesp_mode_t mode, bool enable);
|
|
|
|
int lesp_get_dhcp(bool *ap_enable, bool *sta_enable);
|
|
|
|
int lesp_set_net(lesp_mode_t mode, in_addr_t ip, in_addr_t mask,
|
|
|
|
in_addr_t gateway);
|
|
|
|
int lesp_get_net(lesp_mode_t mode, in_addr_t *ip, in_addr_t *mask,
|
|
|
|
in_addr_t *gw);
|
2016-05-21 17:13:23 +02:00
|
|
|
|
2016-12-04 15:35:02 +01:00
|
|
|
typedef void (*lesp_cb_t)(lesp_ap_t *wlan);
|
2016-05-21 17:13:23 +02:00
|
|
|
|
|
|
|
int lesp_list_access_points(lesp_cb_t cb);
|
|
|
|
|
|
|
|
int lesp_socket(int domain, int type, int protocol);
|
|
|
|
int lesp_closesocket(int sockfd);
|
2021-06-11 11:07:52 +02:00
|
|
|
int lesp_bind(int sockfd,
|
|
|
|
FAR const struct sockaddr *addr, socklen_t addrlen);
|
|
|
|
int lesp_connect(int sockfd,
|
|
|
|
FAR const struct sockaddr *addr, socklen_t addrlen);
|
2016-05-21 17:13:23 +02:00
|
|
|
int lesp_listen(int sockfd, int backlog);
|
|
|
|
int lesp_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
|
|
|
|
ssize_t lesp_send(int sockfd, FAR const uint8_t *buf, size_t len, int flags);
|
|
|
|
ssize_t lesp_recv(int sockfd, FAR uint8_t *buf, size_t len, int flags);
|
|
|
|
int lesp_setsockopt(int sockfd, int level, int option,
|
|
|
|
FAR const void *value, socklen_t value_len);
|
2016-12-04 15:35:02 +01:00
|
|
|
FAR struct hostent *lesp_gethostbyname(FAR const char *hostname);
|
2016-05-21 17:13:23 +02:00
|
|
|
|
|
|
|
#endif /* CONFIG_NETUTILS_ESP8266 */
|
|
|
|
#endif /* __APPS_INCLUDE_NETUTILS_ESP8266_H */
|