Commit a33e3a4a authored by Vowstar's avatar Vowstar
Browse files

Merge pull request #687 from DiUS/dev140

Major upgrade to SDK 1.4.0 & open LWIP
parents 093a8959 8fba0f47
#!/bin/bash
echo "gen_misc.sh version 20150511"
echo ""
echo "Please follow below steps(1-5) to generate specific bin(s):"
echo "STEP 1: choose boot version(0=boot_v1.1, 1=boot_v1.2+, 2=none)"
echo "enter(0/1/2, default 2):"
read input
if [ -z "$input" ]; then
boot=none
elif [ $input == 0 ]; then
boot=old
elif [ $input == 1 ]; then
boot=new
else
boot=none
fi
echo "boot mode: $boot"
echo ""
echo "STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)"
echo "enter (0/1/2, default 0):"
read input
if [ -z "$input" ]; then
if [ $boot != none ]; then
boot=none
echo "ignore boot"
fi
app=0
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
elif [ $input == 1 ]; then
if [ $boot == none ]; then
app=0
echo "choose no boot before"
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
else
app=1
echo "generate bin: user1.bin"
fi
elif [ $input == 2 ]; then
if [ $boot == none ]; then
app=0
echo "choose no boot before"
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
else
app=2
echo "generate bin: user2.bin"
fi
else
if [ $boot != none ]; then
boot=none
echo "ignore boot"
fi
app=0
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
fi
echo ""
echo "STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)"
echo "enter (0/1/2/3, default 2):"
read input
if [ -z "$input" ]; then
spi_speed=40
elif [ $input == 0 ]; then
spi_speed=20
elif [ $input == 1 ]; then
spi_speed=26.7
elif [ $input == 3 ]; then
spi_speed=80
else
spi_speed=40
fi
echo "spi speed: $spi_speed MHz"
echo ""
echo "STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)"
echo "enter (0/1/2/3, default 0):"
read input
if [ -z "$input" ]; then
spi_mode=QIO
elif [ $input == 1 ]; then
spi_mode=QOUT
elif [ $input == 2 ]; then
spi_mode=DIO
elif [ $input == 3 ]; then
spi_mode=DOUT
else
spi_mode=QIO
fi
echo "spi mode: $spi_mode"
echo ""
echo "STEP 5: choose spi size and map"
echo " 0= 512KB( 256KB+ 256KB)"
echo " 2=1024KB( 512KB+ 512KB)"
echo " 3=2048KB( 512KB+ 512KB)"
echo " 4=4096KB( 512KB+ 512KB)"
echo " 5=2048KB(1024KB+1024KB)"
echo " 6=4096KB(1024KB+1024KB)"
echo "enter (0/2/3/4/5/6, default 0):"
read input
if [ -z "$input" ]; then
spi_size_map=0
echo "spi size: 512KB"
echo "spi ota map: 256KB + 256KB"
elif [ $input == 2 ]; then
spi_size_map=2
echo "spi size: 1024KB"
echo "spi ota map: 512KB + 512KB"
elif [ $input == 3 ]; then
spi_size_map=3
echo "spi size: 2048KB"
echo "spi ota map: 512KB + 512KB"
elif [ $input == 4 ]; then
spi_size_map=4
echo "spi size: 4096KB"
echo "spi ota map: 512KB + 512KB"
elif [ $input == 5 ]; then
spi_size_map=5
echo "spi size: 2048KB"
echo "spi ota map: 1024KB + 1024KB"
elif [ $input == 6 ]; then
spi_size_map=6
echo "spi size: 4096KB"
echo "spi ota map: 1024KB + 1024KB"
else
spi_size_map=0
echo "spi size: 512KB"
echo "spi ota map: 256KB + 256KB"
fi
echo ""
touch user/user_main.c
echo ""
echo "start..."
echo ""
make COMPILE=gcc BOOT=$boot APP=$app SPI_SPEED=$spi_speed SPI_MODE=$spi_mode SPI_SIZE_MAP=$spi_size_map
#ifndef __KEY_H__
#define __KEY_H__
#include "gpio.h"
typedef void (* key_function)(void);
struct single_key_param {
uint8 key_level;
uint8 gpio_id;
uint8 gpio_func;
uint32 gpio_name;
os_timer_t key_5s;
os_timer_t key_50ms;
key_function short_press;
key_function long_press;
};
struct keys_param {
uint8 key_num;
struct single_key_param **single_key;
};
struct single_key_param *key_init_single(uint8 gpio_id, uint32 gpio_name, uint8 gpio_func, key_function long_press, key_function short_press);
void key_init(struct keys_param *key);
#endif
#ifndef __USER_CONFIG_H__
#define __USER_CONFIG_H__
#endif
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
# a generated lib/image xxx.a () # a generated lib/image xxx.a ()
# #
ifndef PDIR ifndef PDIR
GEN_LIBS = libuser.a
GEN_LIBS = libsslssl.a
endif endif
...@@ -41,6 +39,7 @@ endif ...@@ -41,6 +39,7 @@ endif
INCLUDES := $(INCLUDES) -I $(PDIR)include INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./ INCLUDES += -I ./
INCLUDES += -I ../../include/ets
PDIR := ../$(PDIR) PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile sinclude $(PDIR)Makefile
/******************************************************************************
* Copyright 2013-2014 Espressif Systems (Wuxi)
*
* FileName: user_main.c
*
* Description: entry file of user application
*
* Modification history:
* 2015/7/3, v1.0 create this file.
*******************************************************************************/
#include "osapi.h"
#include "user_interface.h"
#include "driver/key.h"
#define WPS_KEY_NUM 1
#define WPS_KEY_IO_MUX PERIPHS_IO_MUX_MTCK_U
#define WPS_KEY_IO_NUM 13
#define WPS_KEY_IO_FUNC FUNC_GPIO13
LOCAL struct keys_param keys;
LOCAL struct single_key_param *single_key;
LOCAL void ICACHE_FLASH_ATTR
user_wps_status_cb(int status)
{
switch (status) {
case WPS_CB_ST_SUCCESS:
wifi_wps_disable();
wifi_station_connect();
break;
case WPS_CB_ST_FAILED:
case WPS_CB_ST_TIMEOUT:
wifi_wps_start();
break;
}
}
LOCAL void ICACHE_FLASH_ATTR
user_wps_key_short_press(void)
{
wifi_wps_disable();
wifi_wps_enable(WPS_TYPE_PBC);
wifi_set_wps_cb(user_wps_status_cb);
wifi_wps_start();
}
void ICACHE_FLASH_ATTR
user_rf_pre_init(void)
{
}
void ICACHE_FLASH_ATTR
user_init(void)
{
single_key = key_init_single(WPS_KEY_IO_NUM, WPS_KEY_IO_MUX, WPS_KEY_IO_FUNC,
NULL, user_wps_key_short_press);
keys.key_num = WPS_KEY_NUM;
keys.single_key = &single_key;
key_init(&keys);
wifi_set_opmode(STATION_MODE);
}
...@@ -33,6 +33,12 @@ typedef struct ...@@ -33,6 +33,12 @@ typedef struct
void (*at_exeCmd)(uint8_t id); void (*at_exeCmd)(uint8_t id);
}at_funcationType; }at_funcationType;
typedef void (*at_custom_uart_rx_intr)(uint8* data,int32 len);
typedef void (*at_custom_response_func_type)(const char *str);
extern uint8 at_customLinkMax;
/** /**
* @brief Response "OK" to uart. * @brief Response "OK" to uart.
* @param None * @param None
...@@ -41,10 +47,24 @@ typedef struct ...@@ -41,10 +47,24 @@ typedef struct
void at_response_ok(void); void at_response_ok(void);
/** /**
* @brief Response "ERROR" to uart. * @brief Response "ERROR" to uart.
* @param events: no used * @param None
* @retval None * @retval None
*/ */
void at_response_error(void); void at_response_error(void);
/**
* @brief Response string.
* It is equivalent to at_port_print,if not call at_register_response_func or call at_register_response_func(NULL);
* It will run custom response function,if call at_register_response_func and parameter is not NULL.
* @param string
* @retval None
*/
void at_response(const char *str);
/**
* @brief register custom response function.
* @param response_func: the function that will run when call at_response
* @retval None
*/
void at_register_response_func(at_custom_response_func_type response_func);
/** /**
* @brief Task of process command or txdata. * @brief Task of process command or txdata.
* @param custom_at_cmd_array: the array of at cmd that custom defined * @param custom_at_cmd_array: the array of at cmd that custom defined
...@@ -82,4 +102,42 @@ void at_init(void); ...@@ -82,4 +102,42 @@ void at_init(void);
* @retval None * @retval None
*/ */
void at_port_print(const char *str); void at_port_print(const char *str);
/**
* @brief print custom information when AT+GMR
* @param string
* @retval None
*/
void at_set_custom_info(char* info);
/**
* @brief if current at command is processing,you can call at_enter_special_state,
* then if other comamnd coming,it will return busy.
* @param None
* @retval None
*/
void at_enter_special_state(void);
/**
* @brief
* @param None
* @retval None
*/
void at_leave_special_state(void);
/**
* @brief get at version
* @param None
* @retval at version
* bit24~31: at main version
* bit23~16: at sub version
* bit15~8 : at test version
* bit7~0 : customized version
*/
uint32 at_get_version(void);
/**
* @brief register custom uart rx interrupt function
* @param rx_func: custom uart rx interrupt function.
* If rx_func is non-void,when rx interrupt comming,it will call rx_func(data,len),
* data is the buffer of data,len is the length of data.Otherwise,it will run AT rx function.
* @retval None
*/
void at_register_uart_rx_intr(at_custom_uart_rx_intr rx_func);
#endif #endif
...@@ -16,7 +16,6 @@ typedef unsigned long uint32_t; ...@@ -16,7 +16,6 @@ typedef unsigned long uint32_t;
typedef signed long sint32_t; typedef signed long sint32_t;
typedef signed long int32_t; typedef signed long int32_t;
typedef signed long long sint64_t; typedef signed long long sint64_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
typedef unsigned long long u_int64_t; typedef unsigned long long u_int64_t;
typedef float real32_t; typedef float real32_t;
...@@ -45,12 +44,7 @@ typedef double real64; ...@@ -45,12 +44,7 @@ typedef double real64;
#define __le16 u16 #define __le16 u16
//typedef unsigned int size_t; typedef unsigned int size_t;
#if !defined(__size_t)
#define __size_t 1
typedef unsigned int size_t; /* others (e.g. <stdio.h>) also define */
/* the unsigned integral type of the result of the sizeof operator. */
#endif
#define __packed __attribute__((packed)) #define __packed __attribute__((packed))
...@@ -82,11 +76,9 @@ typedef enum { ...@@ -82,11 +76,9 @@ typedef enum {
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text"))) #define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
#else #else
#define ICACHE_FLASH_ATTR #define ICACHE_FLASH_ATTR
#define ICACHE_RODATA_ATTR
#endif /* ICACHE_FLASH */ #endif /* ICACHE_FLASH */
#define TEXT_SECTION_ATTR __attribute__((section(".text")))
#define RAM_CONST_ATTR __attribute__((section(".rodata")))
#ifndef __cplusplus #ifndef __cplusplus
typedef unsigned char bool; typedef unsigned char bool;
#define BOOL bool #define BOOL bool
......
...@@ -55,8 +55,7 @@ ...@@ -55,8 +55,7 @@
//}} //}}
//Periheral Clock {{ //Periheral Clock {{
#define CPU_CLK_FREQ 80*1000000 //unit: Hz #define APB_CLK_FREQ 80*1000000 //unit: Hz
#define APB_CLK_FREQ CPU_CLK_FREQ
#define UART_CLK_FREQ APB_CLK_FREQ #define UART_CLK_FREQ APB_CLK_FREQ
#define TIMER_CLK_FREQ (APB_CLK_FREQ>>8) //divided by 256 #define TIMER_CLK_FREQ (APB_CLK_FREQ>>8) //divided by 256
//}} //}}
...@@ -184,9 +183,9 @@ ...@@ -184,9 +183,9 @@
#define PERIPHS_IO_MUX_FUNC 0x13 #define PERIPHS_IO_MUX_FUNC 0x13
#define PERIPHS_IO_MUX_FUNC_S 4 #define PERIPHS_IO_MUX_FUNC_S 4
#define PERIPHS_IO_MUX_PULLUP BIT7 #define PERIPHS_IO_MUX_PULLUP BIT7
#define PERIPHS_IO_MUX_PULLDWN BIT6 #define PERIPHS_IO_MUX_PULLUP2 BIT6
#define PERIPHS_IO_MUX_SLEEP_PULLUP BIT3 #define PERIPHS_IO_MUX_SLEEP_PULLUP BIT3
#define PERIPHS_IO_MUX_SLEEP_PULLDWN BIT2 #define PERIPHS_IO_MUX_SLEEP_PULLUP2 BIT2
#define PERIPHS_IO_MUX_SLEEP_OE BIT1 #define PERIPHS_IO_MUX_SLEEP_OE BIT1
#define PERIPHS_IO_MUX_OE BIT0 #define PERIPHS_IO_MUX_OE BIT0
...@@ -203,7 +202,6 @@ ...@@ -203,7 +202,6 @@
#define FUNC_GPIO15 3 #define FUNC_GPIO15 3
#define FUNC_U0RTS 4 #define FUNC_U0RTS 4
#define PERIPHS_IO_MUX_U0RXD_U (PERIPHS_IO_MUX + 0x14) #define PERIPHS_IO_MUX_U0RXD_U (PERIPHS_IO_MUX + 0x14)
#define FUNC_U0RXD 0
#define FUNC_GPIO3 3 #define FUNC_GPIO3 3
#define PERIPHS_IO_MUX_U0TXD_U (PERIPHS_IO_MUX + 0x18) #define PERIPHS_IO_MUX_U0TXD_U (PERIPHS_IO_MUX + 0x18)
#define FUNC_U0TXD 0 #define FUNC_U0TXD 0
...@@ -244,11 +242,12 @@ ...@@ -244,11 +242,12 @@
#define PIN_PULLUP_DIS(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLUP) #define PIN_PULLUP_DIS(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLUP)
#define PIN_PULLUP_EN(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLUP) #define PIN_PULLUP_EN(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLUP)
#define PIN_PULLDWN_DIS(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLDWN)
#define PIN_PULLDWN_EN(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLDWN)
#define PIN_FUNC_SELECT(PIN_NAME, FUNC) do { \ #define PIN_FUNC_SELECT(PIN_NAME, FUNC) do { \
CLEAR_PERI_REG_MASK(PIN_NAME, (PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)); \ WRITE_PERI_REG(PIN_NAME, \
SET_PERI_REG_MASK(PIN_NAME, (((FUNC&BIT2)<<2)|(FUNC&0x3))<<PERIPHS_IO_MUX_FUNC_S); \ READ_PERI_REG(PIN_NAME) \
& (~(PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)) \
|( (((FUNC&BIT2)<<2)|(FUNC&0x3))<<PERIPHS_IO_MUX_FUNC_S) ); \
} while (0) } while (0)
//}} //}}
......
#ifndef __ESPCONN_H__ #ifndef __ESPCONN_H__
#define __ESPCONN_H__ #define __ESPCONN_H__
#include "lwip/ip_addr.h" typedef sint8 err_t;
typedef sint8 err_t; typedef void *espconn_handle;
typedef void (* espconn_connect_callback)(void *arg);
typedef void *espconn_handle; typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
typedef void (* espconn_connect_callback)(void *arg);
typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); /* Definitions for error constants. */
/* Definitions for error constants. */ #define ESPCONN_OK 0 /* No error, everything OK. */
#define ESPCONN_MEM -1 /* Out of memory error. */
#define ESPCONN_OK 0 /* No error, everything OK. */ #define ESPCONN_TIMEOUT -3 /* Timeout. */
#define ESPCONN_MEM -1 /* Out of memory error. */ #define ESPCONN_RTE -4 /* Routing problem. */
#define ESPCONN_TIMEOUT -3 /* Timeout. */ #define ESPCONN_INPROGRESS -5 /* Operation in progress */
#define ESPCONN_RTE -4 /* Routing problem. */ #define ESPCONN_MAXNUM -7 /* Total number exceeds the set maximum*/
#define ESPCONN_INPROGRESS -5 /* Operation in progress */
#define ESPCONN_ABRT -8 /* Connection aborted. */
#define ESPCONN_ABRT -8 /* Connection aborted. */ #define ESPCONN_RST -9 /* Connection reset. */
#define ESPCONN_RST -9 /* Connection reset. */ #define ESPCONN_CLSD -10 /* Connection closed. */
#define ESPCONN_CLSD -10 /* Connection closed. */ #define ESPCONN_CONN -11 /* Not connected. */
#define ESPCONN_CONN -11 /* Not connected. */
#define ESPCONN_ARG -12 /* Illegal argument. */
#define ESPCONN_ARG -12 /* Illegal argument. */ #define ESPCONN_IF -14 /* UDP send error */
#define ESPCONN_ISCONN -15 /* Already connected. */ #define ESPCONN_ISCONN -15 /* Already connected. */
/** Protocol family and type of the espconn */ #define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */
enum espconn_type { #define ESPCONN_SSL_INVALID_DATA -61 /* ssl application invalid */
ESPCONN_INVALID = 0,
/* ESPCONN_TCP Group */ /** Protocol family and type of the espconn */
ESPCONN_TCP = 0x10, enum espconn_type {
/* ESPCONN_UDP Group */ ESPCONN_INVALID = 0,
ESPCONN_UDP = 0x20, /* ESPCONN_TCP Group */
}; ESPCONN_TCP = 0x10,
/* ESPCONN_UDP Group */
/** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */ ESPCONN_UDP = 0x20,
enum espconn_state { };
ESPCONN_NONE,
ESPCONN_WAIT, /** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */
ESPCONN_LISTEN, enum espconn_state {
ESPCONN_CONNECT, ESPCONN_NONE,
ESPCONN_WRITE, ESPCONN_WAIT,
ESPCONN_READ, ESPCONN_LISTEN,
ESPCONN_CLOSE ESPCONN_CONNECT,
}; ESPCONN_WRITE,
ESPCONN_READ,
typedef struct _esp_tcp { ESPCONN_CLOSE
int remote_port; };
int local_port;
uint8 local_ip[4]; typedef struct _esp_tcp {
uint8 remote_ip[4]; int remote_port;
espconn_connect_callback connect_callback; int local_port;
espconn_reconnect_callback reconnect_callback; uint8 local_ip[4];
espconn_connect_callback disconnect_callback; uint8 remote_ip[4];
espconn_connect_callback write_finish_fn; espconn_connect_callback connect_callback;
} esp_tcp; espconn_reconnect_callback reconnect_callback;
espconn_connect_callback disconnect_callback;
typedef struct _esp_udp { espconn_connect_callback write_finish_fn;
int remote_port; } esp_tcp;
int local_port;
uint8 local_ip[4]; typedef struct _esp_udp {
uint8 remote_ip[4]; int remote_port;
} esp_udp; int local_port;
uint8 local_ip[4];
typedef struct _remot_info{ uint8 remote_ip[4];
enum espconn_state state; } esp_udp;
int remote_port;
uint8 remote_ip[4]; typedef struct _remot_info{
}remot_info; enum espconn_state state;
int remote_port;
/** A callback prototype to inform about events for a espconn */ uint8 remote_ip[4];
typedef void (* espconn_recv_callback)(void *arg, char *pdata, unsigned short len); }remot_info;
typedef void (* espconn_sent_callback)(void *arg);
/** A callback prototype to inform about events for a espconn */
/** A espconn descriptor */ typedef void (* espconn_recv_callback)(void *arg, char *pdata, unsigned short len);
struct espconn { typedef void (* espconn_sent_callback)(void *arg);
/** type of the espconn (TCP, UDP) */
enum espconn_type type; /** A espconn descriptor */
/** current state of the espconn */ struct espconn {
enum espconn_state state; /** type of the espconn (TCP, UDP) */
union { enum espconn_type type;
esp_tcp *tcp; /** current state of the espconn */
esp_udp *udp; enum espconn_state state;
} proto; union {
/** A callback function that is informed about events for this espconn */ esp_tcp *tcp;
espconn_recv_callback recv_callback; esp_udp *udp;
espconn_sent_callback sent_callback; } proto;
uint8 link_cnt; /** A callback function that is informed about events for this espconn */
void *reverse; espconn_recv_callback recv_callback;
}; espconn_sent_callback sent_callback;
uint8 link_cnt;
enum espconn_option{ void *reverse;
ESPCONN_START = 0x00, };
ESPCONN_REUSEADDR = 0x01,
ESPCONN_NODELAY = 0x02, enum espconn_option{
ESPCONN_COPY = 0x04, ESPCONN_START = 0x00,
ESPCONN_END ESPCONN_REUSEADDR = 0x01,
}; ESPCONN_NODELAY = 0x02,
ESPCONN_COPY = 0x04,
/****************************************************************************** ESPCONN_KEEPALIVE = 0x08,
* FunctionName : espconn_connect ESPCONN_END
* Description : The function given as the connect };
* Parameters : espconn -- the espconn used to listen the connection
* Returns : none enum espconn_level{
*******************************************************************************/ ESPCONN_KEEPIDLE,
ESPCONN_KEEPINTVL,
sint8 espconn_connect(struct espconn *espconn); ESPCONN_KEEPCNT
};
/******************************************************************************
* FunctionName : espconn_disconnect enum {
* Description : disconnect with host ESPCONN_IDLE = 0,
* Parameters : espconn -- the espconn used to disconnect the connection ESPCONN_CLIENT,
* Returns : none ESPCONN_SERVER,
*******************************************************************************/ ESPCONN_BOTH,
ESPCONN_MAX
sint8 espconn_disconnect(struct espconn *espconn); };
/****************************************************************************** struct espconn_packet{
* FunctionName : espconn_delete uint16 sent_length; /* sent length successful*/
* Description : disconnect with host uint16 snd_buf_size; /* Available buffer size for sending */
* Parameters : espconn -- the espconn used to disconnect the connection uint16 snd_queuelen; /* Available buffer space for sending */
* Returns : none uint16 total_queuelen; /* total Available buffer space for sending */
*******************************************************************************/ uint32 packseqno; /* seqno to be sent */
uint32 packseq_nxt; /* seqno expected */
sint8 espconn_delete(struct espconn *espconn); uint32 packnum;
};
/******************************************************************************
* FunctionName : espconn_accept struct mdns_info {
* Description : The function given as the listen char *host_name;
* Parameters : espconn -- the espconn used to listen the connection char *server_name;
* Returns : none uint16 server_port;
*******************************************************************************/ unsigned long ipAddr;
char *txt_data[10];
sint8 espconn_accept(struct espconn *espconn); };
/******************************************************************************
/****************************************************************************** * FunctionName : espconn_connect
* FunctionName : espconn_create * Description : The function given as the connect
* Description : sent data for client or server * Parameters : espconn -- the espconn used to listen the connection
* Parameters : espconn -- espconn to the data transmission * Returns : none
* Returns : result *******************************************************************************/
*******************************************************************************/
sint8 espconn_connect(struct espconn *espconn);
sint8 espconn_create(struct espconn *espconn);
/******************************************************************************
/****************************************************************************** * FunctionName : espconn_disconnect
* FunctionName : espconn_tcp_get_max_con * Description : disconnect with host
* Description : get the number of simulatenously active TCP connections * Parameters : espconn -- the espconn used to disconnect the connection
* Parameters : none * Returns : none
* Returns : none *******************************************************************************/
*******************************************************************************/
sint8 espconn_disconnect(struct espconn *espconn);
uint8 espconn_tcp_get_max_con(void);
/******************************************************************************
/****************************************************************************** * FunctionName : espconn_delete
* FunctionName : espconn_tcp_set_max_con * Description : disconnect with host
* Description : set the number of simulatenously active TCP connections * Parameters : espconn -- the espconn used to disconnect the connection
* Parameters : num -- total number * Returns : none
* Returns : none *******************************************************************************/
*******************************************************************************/
sint8 espconn_delete(struct espconn *espconn);
sint8 espconn_tcp_set_max_con(uint8 num);
/******************************************************************************
/****************************************************************************** * FunctionName : espconn_accept
* FunctionName : espconn_tcp_get_max_con_allow * Description : The function given as the listen
* Description : get the count of simulatenously active connections on the server * Parameters : espconn -- the espconn used to listen the connection
* Parameters : espconn -- espconn to get the count * Returns : none
* Returns : result *******************************************************************************/
*******************************************************************************/
sint8 espconn_accept(struct espconn *espconn);
sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
/******************************************************************************
/****************************************************************************** * FunctionName : espconn_create
* FunctionName : espconn_tcp_set_max_con_allow * Description : sent data for client or server
* Description : set the count of simulatenously active connections on the server * Parameters : espconn -- espconn to the data transmission
* Parameters : espconn -- espconn to set the count * Returns : result
* num -- support the connection number *******************************************************************************/
* Returns : result
*******************************************************************************/ sint8 espconn_create(struct espconn *espconn);
sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num); /******************************************************************************
* FunctionName : espconn_tcp_get_max_con
/****************************************************************************** * Description : get the number of simulatenously active TCP connections
* FunctionName : espconn_regist_time * Parameters : none
* Description : used to specify the time that should be called when don't recv data * Returns : none
* Parameters : espconn -- the espconn used to the connection *******************************************************************************/
* interval -- the timer when don't recv data
* Returns : none uint8 espconn_tcp_get_max_con(void);
*******************************************************************************/
/******************************************************************************
sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag); * FunctionName : espconn_tcp_set_max_con
* Description : set the number of simulatenously active TCP connections
/****************************************************************************** * Parameters : num -- total number
* FunctionName : espconn_get_connection_info * Returns : none
* Description : used to specify the function that should be called when disconnect *******************************************************************************/
* Parameters : espconn -- espconn to set the err callback
* discon_cb -- err callback function to call when err sint8 espconn_tcp_set_max_con(uint8 num);
* Returns : none
*******************************************************************************/ /******************************************************************************
* FunctionName : espconn_tcp_get_max_con_allow
sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags); * Description : get the count of simulatenously active connections on the server
* Parameters : espconn -- espconn to get the count
/****************************************************************************** * Returns : result
* FunctionName : espconn_regist_sentcb *******************************************************************************/
* Description : Used to specify the function that should be called when data
* has been successfully delivered to the remote host. sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
* Parameters : struct espconn *espconn -- espconn to set the sent callback
* espconn_sent_callback sent_cb -- sent callback function to /******************************************************************************
* call for this espconn when data is successfully sent * FunctionName : espconn_tcp_set_max_con_allow
* Returns : none * Description : set the count of simulatenously active connections on the server
*******************************************************************************/ * Parameters : espconn -- espconn to set the count
* num -- support the connection number
sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb); * Returns : result
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_regist_sentcb sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
* Description : Used to specify the function that should be called when data
* has been successfully delivered to the remote host. /******************************************************************************
* Parameters : espconn -- espconn to set the sent callback * FunctionName : espconn_regist_time
* sent_cb -- sent callback function to call for this espconn * Description : used to specify the time that should be called when don't recv data
* when data is successfully sent * Parameters : espconn -- the espconn used to the connection
* Returns : none * interval -- the timer when don't recv data
*******************************************************************************/ * Returns : none
*******************************************************************************/
sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag);
/******************************************************************************
* FunctionName : espconn_sent /******************************************************************************
* Description : sent data for client or server * FunctionName : espconn_get_connection_info
* Parameters : espconn -- espconn to set for client or server * Description : used to specify the function that should be called when disconnect
* psent -- data to send * Parameters : espconn -- espconn to set the err callback
* length -- length of data to send * discon_cb -- err callback function to call when err
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length); sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_regist_connectcb * FunctionName : espconn_get_packet_info
* Description : used to specify the function that should be called when * Description : get the packet info with host
* connects to host. * Parameters : espconn -- the espconn used to disconnect the connection
* Parameters : espconn -- espconn to set the connect callback * infoarg -- the packet info
* connect_cb -- connected callback function to call when connected * Returns : the errur code
* Returns : none *******************************************************************************/
*******************************************************************************/
sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* infoarg);
sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb);
/******************************************************************************
/****************************************************************************** * FunctionName : espconn_regist_sentcb
* FunctionName : espconn_regist_recvcb * Description : Used to specify the function that should be called when data
* Description : used to specify the function that should be called when recv * has been successfully delivered to the remote host.
* data from host. * Parameters : struct espconn *espconn -- espconn to set the sent callback
* Parameters : espconn -- espconn to set the recv callback * espconn_sent_callback sent_cb -- sent callback function to
* recv_cb -- recv callback function to call when recv data * call for this espconn when data is successfully sent
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb); sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_regist_reconcb * FunctionName : espconn_regist_sentcb
* Description : used to specify the function that should be called when connection * Description : Used to specify the function that should be called when data
* because of err disconnect. * has been successfully delivered to the remote host.
* Parameters : espconn -- espconn to set the err callback * Parameters : espconn -- espconn to set the sent callback
* recon_cb -- err callback function to call when err * sent_cb -- sent callback function to call for this espconn
* Returns : none * when data is successfully sent
*******************************************************************************/ * Returns : none
*******************************************************************************/
sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb);
sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
/******************************************************************************
* FunctionName : espconn_regist_disconcb /******************************************************************************
* Description : used to specify the function that should be called when disconnect * FunctionName : espconn_send
* Parameters : espconn -- espconn to set the err callback * Description : sent data for client or server
* discon_cb -- err callback function to call when err * Parameters : espconn -- espconn to set for client or server
* Returns : none * psent -- data to send
*******************************************************************************/ * length -- length of data to send
* Returns : none
sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb); *******************************************************************************/
/****************************************************************************** sint8 espconn_send(struct espconn *espconn, uint8 *psent, uint16 length);
* FunctionName : espconn_port
* Description : access port value for client so that we don't end up bouncing /******************************************************************************
* all connections at the same time . * FunctionName : espconn_sent
* Parameters : none * Description : sent data for client or server
* Returns : access port value * Parameters : espconn -- espconn to set for client or server
*******************************************************************************/ * psent -- data to send
* length -- length of data to send
uint32 espconn_port(void); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_set_opt sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
* Description : access port value for client so that we don't end up bouncing
* all connections at the same time . /******************************************************************************
* Parameters : none * FunctionName : espconn_sendto
* Returns : access port value * Description : send data for UDP
*******************************************************************************/ * Parameters : espconn -- espconn to set for UDP
* psent -- data to send
sint8 espconn_set_opt(struct espconn *espconn, uint8 opt); * length -- length of data to send
* Returns : error
/****************************************************************************** *******************************************************************************/
* TypedefName : dns_found_callback
* Description : Callback which is invoked when a hostname is found. sint16 espconn_sendto(struct espconn *espconn, uint8 *psent, uint16 length);
* Parameters : name -- pointer to the name that was looked up.
* ipaddr -- pointer to an ip_addr_t containing the IP address of /******************************************************************************
* the hostname, or NULL if the name could not be found (or on any * FunctionName : espconn_regist_connectcb
* other error). * Description : used to specify the function that should be called when
* callback_arg -- a user-specified callback argument passed to * connects to host.
* dns_gethostbyname * Parameters : espconn -- espconn to set the connect callback
*******************************************************************************/ * connect_cb -- connected callback function to call when connected
* Returns : none
typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); *******************************************************************************/
/****************************************************************************** sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb);
* FunctionName : espconn_gethostbyname
* Description : Resolve a hostname (string) into an IP address. /******************************************************************************
* Parameters : pespconn -- espconn to resolve a hostname * FunctionName : espconn_regist_recvcb
* hostname -- the hostname that is to be queried * Description : used to specify the function that should be called when recv
* addr -- pointer to a ip_addr_t where to store the address if * data from host.
* it is already cached in the dns_table (only valid if ESPCONN_OK * Parameters : espconn -- espconn to set the recv callback
* is returned!) * recv_cb -- recv callback function to call when recv data
* found -- a callback function to be called on success, failure * Returns : none
* or timeout (only if ERR_INPROGRESS is returned!) *******************************************************************************/
* Returns : err_t return code
* - ESPCONN_OK if hostname is a valid IP address string or the host sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb);
* name is already in the local names table.
* - ESPCONN_INPROGRESS enqueue a request to be sent to the DNS server /******************************************************************************
* for resolution if no errors are present. * FunctionName : espconn_regist_reconcb
* - ESPCONN_ARG: dns client not initialized or invalid hostname * Description : used to specify the function that should be called when connection
*******************************************************************************/ * because of err disconnect.
* Parameters : espconn -- espconn to set the err callback
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found); * recon_cb -- err callback function to call when err
* Returns : none
/****************************************************************************** *******************************************************************************/
* FunctionName : espconn_encry_connect
* Description : The function given as connection sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb);
* Parameters : espconn -- the espconn used to connect with the host
* Returns : none /******************************************************************************
*******************************************************************************/ * FunctionName : espconn_regist_disconcb
* Description : used to specify the function that should be called when disconnect
sint8 espconn_secure_connect(struct espconn *espconn); * Parameters : espconn -- espconn to set the err callback
* discon_cb -- err callback function to call when err
/****************************************************************************** * Returns : none
* FunctionName : espconn_encry_disconnect *******************************************************************************/
* Description : The function given as the disconnection
* Parameters : espconn -- the espconn used to disconnect with the host sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
* Returns : none
*******************************************************************************/ /******************************************************************************
* FunctionName : espconn_port
sint8 espconn_secure_disconnect(struct espconn *espconn); * Description : access port value for client so that we don't end up bouncing
* all connections at the same time .
/****************************************************************************** * Parameters : none
* FunctionName : espconn_encry_sent * Returns : access port value
* Description : sent data for client or server *******************************************************************************/
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send uint32 espconn_port(void);
* length -- length of data to send
* Returns : none /******************************************************************************
*******************************************************************************/ * FunctionName : espconn_set_opt
* Description : access port value for client so that we don't end up bouncing
sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length); * all connections at the same time .
* Parameters : none
/****************************************************************************** * Returns : access port value
* FunctionName : espconn_secure_accept *******************************************************************************/
* Description : The function given as the listen
* Parameters : espconn -- the espconn used to listen the connection sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
* Returns : none
*******************************************************************************/ /******************************************************************************
* FunctionName : espconn_clear_opt
sint8 espconn_secure_accept(struct espconn *espconn); * Description : clear the option for connections so that we don't end up bouncing
* all connections at the same time .
/****************************************************************************** * Parameters : espconn -- the espconn used to set the connection
* FunctionName : espconn_igmp_join * opt -- the option for clear
* Description : join a multicast group * Returns : the result
* Parameters : host_ip -- the ip address of udp server *******************************************************************************/
* multicast_ip -- multicast ip given by user
* Returns : none sint8 espconn_clear_opt(struct espconn *espconn, uint8 opt);
*******************************************************************************/
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip); /******************************************************************************
* FunctionName : espconn_set_keepalive
/****************************************************************************** * Description : access level value for connection so that we set the value for
* FunctionName : espconn_igmp_leave * keep alive
* Description : leave a multicast group * Parameters : espconn -- the espconn used to set the connection
* Parameters : host_ip -- the ip address of udp server * level -- the connection's level
* multicast_ip -- multicast ip given by user * value -- the value of time(s)
* Returns : none * Returns : access port value
*******************************************************************************/ *******************************************************************************/
sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
sint8 espconn_set_keepalive(struct espconn *espconn, uint8 level, void* optarg);
/******************************************************************************
* FunctionName : espconn_recv_hold /******************************************************************************
* Description : hold tcp receive * FunctionName : espconn_get_keepalive
* Parameters : espconn -- espconn to hold * Description : access level value for connection so that we get the value for
* Returns : none * keep alive
*******************************************************************************/ * Parameters : espconn -- the espconn used to get the connection
sint8 espconn_recv_hold(struct espconn *pespconn); * level -- the connection's level
* Returns : access keep alive value
/****************************************************************************** *******************************************************************************/
* FunctionName : espconn_recv_unhold
* Description : unhold tcp receive sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *optarg);
* Parameters : espconn -- espconn to unhold
* Returns : none /******************************************************************************
*******************************************************************************/ * TypedefName : dns_found_callback
sint8 espconn_recv_unhold(struct espconn *pespconn); * Description : Callback which is invoked when a hostname is found.
* Parameters : name -- pointer to the name that was looked up.
#endif * ipaddr -- pointer to an ip_addr_t containing the IP address of
* the hostname, or NULL if the name could not be found (or on any
* other error).
* callback_arg -- a user-specified callback argument passed to
* dns_gethostbyname
*******************************************************************************/
typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg);
/******************************************************************************
* FunctionName : espconn_gethostbyname
* Description : Resolve a hostname (string) into an IP address.
* Parameters : pespconn -- espconn to resolve a hostname
* hostname -- the hostname that is to be queried
* addr -- pointer to a ip_addr_t where to store the address if
* it is already cached in the dns_table (only valid if ESPCONN_OK
* is returned!)
* found -- a callback function to be called on success, failure
* or timeout (only if ERR_INPROGRESS is returned!)
* Returns : err_t return code
* - ESPCONN_OK if hostname is a valid IP address string or the host
* name is already in the local names table.
* - ESPCONN_INPROGRESS enqueue a request to be sent to the DNS server
* for resolution if no errors are present.
* - ESPCONN_ARG: dns client not initialized or invalid hostname
*******************************************************************************/
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found);
/******************************************************************************
* FunctionName : espconn_encry_connect
* Description : The function given as connection
* Parameters : espconn -- the espconn used to connect with the host
* Returns : none
*******************************************************************************/
sint8 espconn_secure_connect(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_encry_disconnect
* Description : The function given as the disconnection
* Parameters : espconn -- the espconn used to disconnect with the host
* Returns : none
*******************************************************************************/
sint8 espconn_secure_disconnect(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_secure_send
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
sint8 espconn_secure_send(struct espconn *espconn, uint8 *psent, uint16 length);
/******************************************************************************
* FunctionName : espconn_encry_sent
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
/******************************************************************************
* FunctionName : espconn_secure_set_size
* Description : set the buffer size for client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* size -- buffer size
* Returns : true or false
*******************************************************************************/
bool espconn_secure_set_size(uint8 level, uint16 size);
/******************************************************************************
* FunctionName : espconn_secure_get_size
* Description : get buffer size for client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : buffer size for client or server
*******************************************************************************/
sint16 espconn_secure_get_size(uint8 level);
/******************************************************************************
* FunctionName : espconn_secure_ca_enable
* Description : enable the certificate authenticate and set the flash sector
* as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* flash_sector -- flash sector for save certificate
* Returns : result true or false
*******************************************************************************/
bool espconn_secure_ca_enable(uint8 level, uint8 flash_sector );
/******************************************************************************
* FunctionName : espconn_secure_ca_disable
* Description : disable the certificate authenticate as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : result true or false
*******************************************************************************/
bool espconn_secure_ca_disable(uint8 level);
/******************************************************************************
* FunctionName : espconn_secure_cert_req_enable
* Description : enable the client certificate authenticate and set the flash sector
* as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* flash_sector -- flash sector for save certificate
* Returns : result true or false
*******************************************************************************/
bool espconn_secure_cert_req_enable(uint8 level, uint8 flash_sector );
/******************************************************************************
* FunctionName : espconn_secure_ca_disable
* Description : disable the client certificate authenticate as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : result true or false
*******************************************************************************/
bool espconn_secure_cert_req_disable(uint8 level);
/******************************************************************************
* FunctionName : espconn_secure_set_default_certificate
* Description : Load the certificates in memory depending on compile-time
* and user options.
* Parameters : certificate -- Load the certificate
* length -- Load the certificate length
* Returns : result true or false
*******************************************************************************/
bool espconn_secure_set_default_certificate(const uint8* certificate, uint16 length);
/******************************************************************************
* FunctionName : espconn_secure_set_default_private_key
* Description : Load the key in memory depending on compile-time
* and user options.
* Parameters : private_key -- Load the key
* length -- Load the key length
* Returns : result true or false
*******************************************************************************/
bool espconn_secure_set_default_private_key(const uint8* private_key, uint16 length);
/******************************************************************************
* FunctionName : espconn_secure_accept
* Description : The function given as the listen
* Parameters : espconn -- the espconn used to listen the connection
* Returns : none
*******************************************************************************/
sint8 espconn_secure_accept(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_igmp_join
* Description : join a multicast group
* Parameters : host_ip -- the ip address of udp server
* multicast_ip -- multicast ip given by user
* Returns : none
*******************************************************************************/
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
/******************************************************************************
* FunctionName : espconn_igmp_leave
* Description : leave a multicast group
* Parameters : host_ip -- the ip address of udp server
* multicast_ip -- multicast ip given by user
* Returns : none
*******************************************************************************/
sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
/******************************************************************************
* FunctionName : espconn_recv_hold
* Description : hold tcp receive
* Parameters : espconn -- espconn to hold
* Returns : none
*******************************************************************************/
sint8 espconn_recv_hold(struct espconn *pespconn);
/******************************************************************************
* FunctionName : espconn_recv_unhold
* Description : unhold tcp receive
* Parameters : espconn -- espconn to unhold
* Returns : none
*******************************************************************************/
sint8 espconn_recv_unhold(struct espconn *pespconn);
/******************************************************************************
* FunctionName : espconn_mdns_init
* Description : register a device with mdns
* Parameters : ipAddr -- the ip address of device
* hostname -- the hostname of device
* Returns : none
*******************************************************************************/
void espconn_mdns_init(struct mdns_info *info);
/******************************************************************************
* FunctionName : espconn_mdns_close
* Description : close a device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
void espconn_mdns_close(void);
/******************************************************************************
* FunctionName : espconn_mdns_server_register
* Description : register a device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
void espconn_mdns_server_register(void);
/******************************************************************************
* FunctionName : espconn_mdns_server_unregister
* Description : unregister a device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
void espconn_mdns_server_unregister(void);
/******************************************************************************
* FunctionName : espconn_mdns_get_servername
* Description : get server name of device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
char* espconn_mdns_get_servername(void);
/******************************************************************************
* FunctionName : espconn_mdns_set_servername
* Description : set server name of device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
void espconn_mdns_set_servername(const char *name);
/******************************************************************************
* FunctionName : espconn_mdns_set_hostname
* Description : set host name of device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
void espconn_mdns_set_hostname(char *name);
/******************************************************************************
* FunctionName : espconn_mdns_get_hostname
* Description : get host name of device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
char* espconn_mdns_get_hostname(void);
/******************************************************************************
* FunctionName : espconn_mdns_disable
* Description : disable a device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
void espconn_mdns_disable(void);
/******************************************************************************
* FunctionName : espconn_mdns_enable
* Description : disable a device with mdns
* Parameters : a
* Returns : none
*******************************************************************************/
void espconn_mdns_enable(void);
/******************************************************************************
* FunctionName : espconn_dns_setserver
* Description : Initialize one of the DNS servers.
* Parameters : numdns -- the index of the DNS server to set must
* be < DNS_MAX_SERVERS = 2
* dnsserver -- IP address of the DNS server to set
* Returns : none
*******************************************************************************/
void espconn_dns_setserver(char numdns, ip_addr_t *dnsserver);
#endif
/*
* Copyright (C) 2015 -2018 Espressif System
*
*/
#ifndef __ESPNOW_H__
#define __ESPNOW_H__
enum esp_now_role {
ESP_NOW_ROLE_IDLE = 0,
ESP_NOW_ROLE_CONTROLLER,
ESP_NOW_ROLE_SLAVE,
ESP_NOW_ROLE_MAX,
};
typedef void (*esp_now_recv_cb_t)(u8 *mac_addr, u8 *data, u8 len);
typedef void (*esp_now_send_cb_t)(u8 *mac_addr, u8 status);
int esp_now_init(void);
int esp_now_deinit(void);
int esp_now_register_send_cb(esp_now_send_cb_t cb);
int esp_now_unregister_send_cb(void);
int esp_now_register_recv_cb(esp_now_recv_cb_t cb);
int esp_now_unregister_recv_cb(void);
int esp_now_send(u8 *da, u8 *data, int len);
int esp_now_add_peer(u8 *mac_addr, u8 role, u8 channel, u8 *key, u8 key_len);
int esp_now_del_peer(u8 *mac_addr);
int esp_now_set_self_role(u8 role);
int esp_now_get_self_role(void);
int esp_now_set_peer_role(u8 *mac_addr, u8 role);
int esp_now_get_peer_role(u8 *mac_addr);
int esp_now_set_peer_channel(u8 *mac_addr, u8 channel);
int esp_now_get_peer_channel(u8 *mac_addr);
int esp_now_set_peer_key(u8 *mac_addr, u8 *key, u8 key_len);
int esp_now_get_peer_key(u8 *mac_addr, u8 *key, u8 *key_len);
u8 *esp_now_fetch_peer(bool restart);
int esp_now_is_peer_exist(u8 *mac_addr);
int esp_now_get_cnt_info(u8 *all_cnt, u8 *encrypt_cnt);
int esp_now_set_kok(u8 *key, u8 len);
#endif
...@@ -51,6 +51,9 @@ typedef struct _ETSTIMER_ { ...@@ -51,6 +51,9 @@ typedef struct _ETSTIMER_ {
#define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \ #define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \
ets_isr_attach(ETS_FRC_TIMER1_INUM, (func), (void *)(arg)) ets_isr_attach(ETS_FRC_TIMER1_INUM, (func), (void *)(arg))
#define ETS_FRC_TIMER1_NMI_INTR_ATTACH(func) \
NmiTimSetFunc(func)
#define ETS_GPIO_INTR_ATTACH(func, arg) \ #define ETS_GPIO_INTR_ATTACH(func, arg) \
ets_isr_attach(ETS_GPIO_INUM, (func), (void *)(arg)) ets_isr_attach(ETS_GPIO_INUM, (func), (void *)(arg))
......
...@@ -17,13 +17,13 @@ typedef enum { ...@@ -17,13 +17,13 @@ typedef enum {
GPIO_PIN_INTR_DISABLE = 0, GPIO_PIN_INTR_DISABLE = 0,
GPIO_PIN_INTR_POSEDGE = 1, GPIO_PIN_INTR_POSEDGE = 1,
GPIO_PIN_INTR_NEGEDGE = 2, GPIO_PIN_INTR_NEGEDGE = 2,
GPIO_PIN_INTR_ANYEGDE = 3, GPIO_PIN_INTR_ANYEDGE = 3,
GPIO_PIN_INTR_LOLEVEL = 4, GPIO_PIN_INTR_LOLEVEL = 4,
GPIO_PIN_INTR_HILEVEL = 5 GPIO_PIN_INTR_HILEVEL = 5
} GPIO_INT_TYPE; } GPIO_INT_TYPE;
#define GPIO_OUTPUT_SET(gpio_no, bit_value) \ #define GPIO_OUTPUT_SET(gpio_no, bit_value) \
gpio_output_set(bit_value<<gpio_no, ((~bit_value)&0x01)<<gpio_no, 1<<gpio_no,0) gpio_output_set((bit_value)<<gpio_no, ((~(bit_value))&0x01)<<gpio_no, 1<<gpio_no,0)
#define GPIO_DIS_OUTPUT(gpio_no) gpio_output_set(0,0,0, 1<<gpio_no) #define GPIO_DIS_OUTPUT(gpio_no) gpio_output_set(0,0,0, 1<<gpio_no)
#define GPIO_INPUT_GET(gpio_no) ((gpio_input_get()>>gpio_no)&BIT0) #define GPIO_INPUT_GET(gpio_no) ((gpio_input_get()>>gpio_no)&BIT0)
......
...@@ -15,12 +15,6 @@ struct ip_info { ...@@ -15,12 +15,6 @@ struct ip_info {
struct ip_addr gw; struct ip_addr gw;
}; };
#define IP4_ADDR(ipaddr, a,b,c,d) \
(ipaddr)->addr = ((uint32)((d) & 0xff) << 24) | \
((uint32)((c) & 0xff) << 16) | \
((uint32)((b) & 0xff) << 8) | \
(uint32)((a) & 0xff)
/** /**
* Determine if two address are on the same network. * Determine if two address are on the same network.
* *
......
/* /*
* Copyright (c) 2011-2012, Swedish Institute of Computer Science. * Copyright (c) 2011-2012, Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
*/ */
/** /**
* \file * \file
* A few JSON defines used for parsing and generating JSON. * A few JSON defines used for parsing and generating JSON.
* \author * \author
* Niclas Finne <nfi@sics.se> * Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se> * Joakim Eriksson <joakime@sics.se>
*/ */
#ifndef __JSON_H__ #ifndef __JSON_H__
#define __JSON_H__ #define __JSON_H__
#define JSON_TYPE_ARRAY '[' #define JSON_TYPE_ARRAY '['
#define JSON_TYPE_OBJECT '{' #define JSON_TYPE_OBJECT '{'
#define JSON_TYPE_PAIR ':' #define JSON_TYPE_PAIR ':'
#define JSON_TYPE_PAIR_NAME 'N' /* for N:V pairs */ #define JSON_TYPE_PAIR_NAME 'N' /* for N:V pairs */
#define JSON_TYPE_STRING '"' #define JSON_TYPE_STRING '"'
#define JSON_TYPE_INT 'I' #define JSON_TYPE_INT 'I'
#define JSON_TYPE_NUMBER '0' #define JSON_TYPE_NUMBER '0'
#define JSON_TYPE_ERROR 0 #define JSON_TYPE_ERROR 0
/* how should we handle null vs false - both can be 0? */ /* how should we handle null vs false - both can be 0? */
#define JSON_TYPE_NULL 'n' #define JSON_TYPE_NULL 'n'
#define JSON_TYPE_TRUE 't' #define JSON_TYPE_TRUE 't'
#define JSON_TYPE_FALSE 'f' #define JSON_TYPE_FALSE 'f'
#define JSON_TYPE_CALLBACK 'C' #define JSON_TYPE_CALLBACK 'C'
enum { enum {
JSON_ERROR_OK, JSON_ERROR_OK,
JSON_ERROR_SYNTAX, JSON_ERROR_SYNTAX,
JSON_ERROR_UNEXPECTED_ARRAY, JSON_ERROR_UNEXPECTED_ARRAY,
JSON_ERROR_UNEXPECTED_END_OF_ARRAY, JSON_ERROR_UNEXPECTED_END_OF_ARRAY,
JSON_ERROR_UNEXPECTED_OBJECT, JSON_ERROR_UNEXPECTED_OBJECT,
JSON_ERROR_UNEXPECTED_STRING JSON_ERROR_UNEXPECTED_STRING
}; };
#define JSON_CONTENT_TYPE "application/json" #define JSON_CONTENT_TYPE "application/json"
#endif /* __JSON_H__ */ #endif /* __JSON_H__ */
/* /*
* Copyright (c) 2011-2012, Swedish Institute of Computer Science. * Copyright (c) 2011-2012, Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
*/ */
#ifndef __JSONPARSE_H__ #ifndef __JSONPARSE_H__
#define __JSONPARSE_H__ #define __JSONPARSE_H__
#include "c_types.h" #include "c_types.h"
#include "json/json.h" #include "json/json.h"
#ifdef JSONPARSE_CONF_MAX_DEPTH #ifdef JSONPARSE_CONF_MAX_DEPTH
#define JSONPARSE_MAX_DEPTH JSONPARSE_CONF_MAX_DEPTH #define JSONPARSE_MAX_DEPTH JSONPARSE_CONF_MAX_DEPTH
#else #else
#define JSONPARSE_MAX_DEPTH 10 #define JSONPARSE_MAX_DEPTH 10
#endif #endif
struct jsonparse_state { struct jsonparse_state {
const char *json; const char *json;
int pos; int pos;
int len; int len;
int depth; int depth;
/* for handling atomic values */ /* for handling atomic values */
int vstart; int vstart;
int vlen; int vlen;
char vtype; char vtype;
char error; char error;
char stack[JSONPARSE_MAX_DEPTH]; char stack[JSONPARSE_MAX_DEPTH];
}; };
/** /**
* \brief Initialize a JSON parser state. * \brief Initialize a JSON parser state.
* \param state A pointer to a JSON parser state * \param state A pointer to a JSON parser state
* \param json The string to parse as JSON * \param json The string to parse as JSON
* \param len The length of the string to parse * \param len The length of the string to parse
* *
* This function initializes a JSON parser state for * This function initializes a JSON parser state for
* parsing a string as JSON. * parsing a string as JSON.
*/ */
void jsonparse_setup(struct jsonparse_state *state, const char *json, void jsonparse_setup(struct jsonparse_state *state, const char *json,
int len); int len);
/* move to next JSON element */ /* move to next JSON element */
int jsonparse_next(struct jsonparse_state *state); int jsonparse_next(struct jsonparse_state *state);
/* copy the current JSON value into the specified buffer */ /* copy the current JSON value into the specified buffer */
int jsonparse_copy_value(struct jsonparse_state *state, char *buf, int jsonparse_copy_value(struct jsonparse_state *state, char *buf,
int buf_size); int buf_size);
/* get the current JSON value parsed as an int */ /* get the current JSON value parsed as an int */
int jsonparse_get_value_as_int(struct jsonparse_state *state); int jsonparse_get_value_as_int(struct jsonparse_state *state);
/* get the current JSON value parsed as a long */ /* get the current JSON value parsed as a long */
long jsonparse_get_value_as_long(struct jsonparse_state *state); long jsonparse_get_value_as_long(struct jsonparse_state *state);
/* get the current JSON value parsed as a unsigned long */ /* get the current JSON value parsed as a unsigned long */
unsigned long jsonparse_get_value_as_ulong(struct jsonparse_state *state); unsigned long jsonparse_get_value_as_ulong(struct jsonparse_state *state);
/* get the length of the current JSON value */ /* get the length of the current JSON value */
int jsonparse_get_len(struct jsonparse_state *state); int jsonparse_get_len(struct jsonparse_state *state);
/* get the type of the current JSON value */ /* get the type of the current JSON value */
int jsonparse_get_type(struct jsonparse_state *state); int jsonparse_get_type(struct jsonparse_state *state);
/* compare the JSON value with the specified string */ /* compare the JSON value with the specified string */
int jsonparse_strcmp_value(struct jsonparse_state *state, const char *str); int jsonparse_strcmp_value(struct jsonparse_state *state, const char *str);
#endif /* __JSONPARSE_H__ */ #endif /* __JSONPARSE_H__ */
/* /*
* Copyright (c) 2011-2012, Swedish Institute of Computer Science. * Copyright (c) 2011-2012, Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
*/ */
/** /**
* \file * \file
* JSON output generation * JSON output generation
* \author * \author
* Niclas Finne <nfi@sics.se> * Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se> * Joakim Eriksson <joakime@sics.se>
*/ */
#ifndef __JSONTREE_H__ #ifndef __JSONTREE_H__
#define __JSONTREE_H__ #define __JSONTREE_H__
#include "c_types.h" #include "c_types.h"
#include "json/json.h" #include "json/json.h"
#ifdef JSONTREE_CONF_MAX_DEPTH #ifdef JSONTREE_CONF_MAX_DEPTH
#define JSONTREE_MAX_DEPTH JSONTREE_CONF_MAX_DEPTH #define JSONTREE_MAX_DEPTH JSONTREE_CONF_MAX_DEPTH
#else #else
#define JSONTREE_MAX_DEPTH 10 #define JSONTREE_MAX_DEPTH 10
#endif /* JSONTREE_CONF_MAX_DEPTH */ #endif /* JSONTREE_CONF_MAX_DEPTH */
struct jsontree_context { struct jsontree_context {
struct jsontree_value *values[JSONTREE_MAX_DEPTH]; struct jsontree_value *values[JSONTREE_MAX_DEPTH];
uint16_t index[JSONTREE_MAX_DEPTH]; uint16_t index[JSONTREE_MAX_DEPTH];
int (* putchar)(int); int (* putchar)(int);
uint8_t depth; uint8_t depth;
uint8_t path; uint8_t path;
int callback_state; int callback_state;
}; };
struct jsontree_value { struct jsontree_value {
uint8_t type; uint8_t type;
/* followed by a value */ /* followed by a value */
}; };
struct jsontree_string { struct jsontree_string {
uint8_t type; uint8_t type;
const char *value; const char *value;
}; };
struct jsontree_int { struct jsontree_int {
uint8_t type; uint8_t type;
int value; int value;
}; };
/* NOTE: the jsontree_callback set will receive a jsonparse state */ /* NOTE: the jsontree_callback set will receive a jsonparse state */
struct jsonparse_state; struct jsonparse_state;
struct jsontree_callback { struct jsontree_callback {
uint8_t type; uint8_t type;
int (* output)(struct jsontree_context *js_ctx); int (* output)(struct jsontree_context *js_ctx);
int (* set)(struct jsontree_context *js_ctx, struct jsonparse_state *parser); int (* set)(struct jsontree_context *js_ctx, struct jsonparse_state *parser);
}; };
struct jsontree_pair { struct jsontree_pair {
const char *name; const char *name;
struct jsontree_value *value; struct jsontree_value *value;
}; };
struct jsontree_object { struct jsontree_object {
uint8_t type; uint8_t type;
uint8_t count; uint8_t count;
struct jsontree_pair *pairs; struct jsontree_pair *pairs;
}; };
struct jsontree_array { struct jsontree_array {
uint8_t type; uint8_t type;
uint8_t count; uint8_t count;
struct jsontree_value **values; struct jsontree_value **values;
}; };
#define JSONTREE_STRING(text) {JSON_TYPE_STRING, (text)} #define JSONTREE_STRING(text) {JSON_TYPE_STRING, (text)}
#define JSONTREE_PAIR(name, value) {(name), (struct jsontree_value *)(value)} #define JSONTREE_PAIR(name, value) {(name), (struct jsontree_value *)(value)}
#define JSONTREE_CALLBACK(output, set) {JSON_TYPE_CALLBACK, (output), (set)} #define JSONTREE_CALLBACK(output, set) {JSON_TYPE_CALLBACK, (output), (set)}
#define JSONTREE_OBJECT(name, ...) \ #define JSONTREE_OBJECT(name, ...) \
static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \ static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
static struct jsontree_object name = { \ static struct jsontree_object name = { \
JSON_TYPE_OBJECT, \ JSON_TYPE_OBJECT, \
sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \ sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
jsontree_pair_##name } jsontree_pair_##name }
#define JSONTREE_PAIR_ARRAY(value) (struct jsontree_value *)(value) #define JSONTREE_PAIR_ARRAY(value) (struct jsontree_value *)(value)
#define JSONTREE_ARRAY(name, ...) \ #define JSONTREE_ARRAY(name, ...) \
static struct jsontree_value* jsontree_value_##name[] = {__VA_ARGS__}; \ static struct jsontree_value* jsontree_value_##name[] = {__VA_ARGS__}; \
static struct jsontree_array name = { \ static struct jsontree_array name = { \
JSON_TYPE_ARRAY, \ JSON_TYPE_ARRAY, \
sizeof(jsontree_value_##name)/sizeof(struct jsontree_value*), \ sizeof(jsontree_value_##name)/sizeof(struct jsontree_value*), \
jsontree_value_##name } jsontree_value_##name }
#define JSONTREE_OBJECT_EXT(name, ...) \ #define JSONTREE_OBJECT_EXT(name, ...) \
static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \ static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
struct jsontree_object name = { \ struct jsontree_object name = { \
JSON_TYPE_OBJECT, \ JSON_TYPE_OBJECT, \
sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \ sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
jsontree_pair_##name } jsontree_pair_##name }
void jsontree_setup(struct jsontree_context *js_ctx, void jsontree_setup(struct jsontree_context *js_ctx,
struct jsontree_value *root, int (* putchar)(int)); struct jsontree_value *root, int (* putchar)(int));
void jsontree_reset(struct jsontree_context *js_ctx); void jsontree_reset(struct jsontree_context *js_ctx);
const char *jsontree_path_name(const struct jsontree_context *js_ctx, const char *jsontree_path_name(const struct jsontree_context *js_ctx,
int depth); int depth);
void jsontree_write_int(const struct jsontree_context *js_ctx, int value); void jsontree_write_int(const struct jsontree_context *js_ctx, int value);
void jsontree_write_int_array(const struct jsontree_context *js_ctx, const int *text, uint32 length); void jsontree_write_int_array(const struct jsontree_context *js_ctx, const int *text, uint32 length);
void jsontree_write_atom(const struct jsontree_context *js_ctx, void jsontree_write_atom(const struct jsontree_context *js_ctx,
const char *text); const char *text);
void jsontree_write_string(const struct jsontree_context *js_ctx, void jsontree_write_string(const struct jsontree_context *js_ctx,
const char *text); const char *text);
int jsontree_print_next(struct jsontree_context *js_ctx); int jsontree_print_next(struct jsontree_context *js_ctx);
struct jsontree_value *jsontree_find_next(struct jsontree_context *js_ctx, struct jsontree_value *jsontree_find_next(struct jsontree_context *js_ctx,
int type); int type);
#endif /* __JSONTREE_H__ */ #endif /* __JSONTREE_H__ */
#ifndef __MEM_H__
#define __MEM_H__
#ifndef MEMLEAK_DEBUG
#define os_free(s) vPortFree(s, "", 0)
#define os_malloc(s) pvPortMalloc(s, "", 0)
#define os_calloc(s) pvPortCalloc(s, "", 0);
#define os_realloc(p, s) pvPortRealloc(p, s, "", 0)
#define os_zalloc(s) pvPortZalloc(s, "", 0)
#else
#define os_free(s) \
do{\
const char *file = mem_debug_file;\
vPortFree(s, file, __LINE__);\
}while(0)
#define os_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
#define os_calloc(s) ({const char *file = mem_debug_file; pvPortCalloc(s, file, __LINE__);})
#define os_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);})
#define os_zalloc(s) ({const char *file = mem_debug_file; pvPortZalloc(s, file, __LINE__);})
#endif
#endif
#ifndef __LWIP_API_MESH_H__
#define __LWIP_API_MESH_H__
#include "ip_addr.h"
#include "user_interface.h"
#include "espconn.h"
typedef void (* espconn_mesh_callback)();
enum mesh_type {
MESH_CLOSE = 0,
MESH_LOCAL,
MESH_ONLINE,
MESH_NONE = 0xFF
};
enum mesh_status {
MESH_DISABLE = 0,
MESH_WIFI_CONN,
MESH_NET_CONN,
MESH_LOCAL_AVAIL,
MESH_ONLINE_AVAIL
};
enum mesh_node_type {
MESH_NODE_PARENT = 0,
MESH_NODE_CHILD,
MESH_NODE_ALL
};
bool espconn_mesh_local_addr(struct ip_addr *ip);
bool espconn_mesh_get_node_info(enum mesh_node_type type,
uint8_t **info, uint8_t *count);
bool espconn_mesh_get_router(struct station_config *router);
bool espconn_mesh_set_router(struct station_config *router);
bool espconn_mesh_encrypt_init(AUTH_MODE mode, uint8_t *passwd, uint8_t passwd_len);
bool espconn_mesh_set_ssid_prefix(uint8_t *prefix, uint8_t prefix_len);
bool espconn_mesh_set_max_hops(uint8_t max_hops);
char * espconn_json_find_section(const char *pbuf, u16 len, const char *section);
sint8 espconn_mesh_connect(struct espconn *usr_esp);
sint8 espconn_mesh_disconnect(struct espconn *usr_esp);
sint8 espconn_mesh_get_status();
sint8 espconn_mesh_sent(struct espconn *usr_esp, uint8 *pdata, uint16 len);
uint8 espconn_mesh_get_max_hops();
uint8 espconn_mesh_layer(struct ip_addr *ip);
uint32_t user_json_get_value(const char *pbuffer, uint16_t buf_len,
const uint8_t *json_key);
void espconn_mesh_enable(espconn_mesh_callback enable_cb, enum mesh_type type);
void espconn_mesh_disable(espconn_mesh_callback disable_cb);
void espconn_mesh_init();
void espconn_mesh_init_group_list(uint8_t *dev_mac, uint16_t dev_count);
void espconn_mesh_set_dev_type(uint8_t dev_type);
void espconn_mesh_setup_timer(os_timer_t *timer, uint32_t time,
os_timer_func_t cb, void *arg, bool repeat);
#endif
/* /*
* copyright (c) Espressif System 2010 * copyright (c) Espressif System 2010
* *
* mapping to ETS structures * mapping to ETS structures
* *
*/ */
#ifndef _OS_TYPES_H_ #ifndef _OS_TYPES_H_
#define _OS_TYPES_H_ #define _OS_TYPES_H_
#include "ets_sys.h" #include "ets_sys.h"
#define os_signal_t ETSSignal #define os_signal_t ETSSignal
#define os_param_t ETSParam #define os_param_t ETSParam
#define os_event_t ETSEvent #define os_event_t ETSEvent
#define os_task_t ETSTask #define os_task_t ETSTask
#define os_timer_t ETSTimer #define os_timer_t ETSTimer
#define os_timer_func_t ETSTimerFunc #define os_timer_func_t ETSTimerFunc
#endif #endif
/* /*
* Copyright (c) 2010 Espressif System * Copyright (c) 2010 Espressif System
*/ */
#ifndef _OSAPI_H_ #ifndef _OSAPI_H_
#define _OSAPI_H_ #define _OSAPI_H_
#include <string.h> #include <string.h>
#include "user_config.h" #include "user_config.h"
#define os_bzero ets_bzero #define os_bzero ets_bzero
#define os_delay_us ets_delay_us #define os_delay_us ets_delay_us
#define os_install_putc1 ets_install_putc1 #define os_install_putc1 ets_install_putc1
#define os_install_putc2 ets_install_putc2
#define os_intr_lock ets_intr_lock #define os_memcmp ets_memcmp
#define os_intr_unlock ets_intr_unlock #define os_memcpy ets_memcpy
#define os_isr_attach ets_isr_attach #define os_memmove ets_memmove
#define os_isr_mask ets_isr_mask #define os_memset ets_memset
#define os_isr_unmask ets_isr_unmask #define os_strcat strcat
#define os_memcmp ets_memcmp #define os_strchr strchr
#define os_memcpy ets_memcpy #define os_strcmp ets_strcmp
#define os_memmove ets_memmove #define os_strcpy ets_strcpy
#define os_memset ets_memset #define os_strlen ets_strlen
#define os_putc ets_putc #define os_strncmp ets_strncmp
#define os_str2macaddr ets_str2macaddr #define os_strncpy ets_strncpy
#define os_strcat strcat #define os_strstr ets_strstr
#define os_strchr strchr #ifdef USE_US_TIMER
#define os_strcmp ets_strcmp #define os_timer_arm_us(a, b, c) ets_timer_arm_new(a, b, c, 0)
#define os_strcpy ets_strcpy #endif
#define os_strlen ets_strlen #define os_timer_arm(a, b, c) ets_timer_arm_new(a, b, c, 1)
#define os_strncmp ets_strncmp #define os_timer_disarm ets_timer_disarm
#define os_strncpy ets_strncpy #define os_timer_setfn ets_timer_setfn
#define os_strstr ets_strstr
#ifdef USE_US_TIMER #define os_sprintf ets_sprintf
#define os_timer_arm_us(a, b, c) ets_timer_arm_new(a, b, c, 0)
#endif #ifdef USE_OPTIMIZE_PRINTF
#define os_timer_arm(a, b, c) ets_timer_arm_new(a, b, c, 1) #define os_printf(fmt, ...) do { \
#define os_timer_disarm ets_timer_disarm static const char flash_str[] ICACHE_RODATA_ATTR __attribute__((aligned(4))) = fmt; \
#define os_timer_done ets_timer_done os_printf_plus(flash_str, ##__VA_ARGS__); \
#define os_timer_handler_isr ets_timer_handler_isr } while(0)
#define os_timer_init ets_timer_init #else
#define os_timer_setfn ets_timer_setfn #define os_printf os_printf_plus
#endif
#define os_sprintf ets_sprintf
#define os_update_cpu_frequency ets_update_cpu_frequency unsigned long os_random(void);
int os_get_random(unsigned char *buf, size_t len);
#ifdef USE_OPTIMIZE_PRINTF
#define os_printf(fmt, ...) do { \ #endif
static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
os_printf_plus(flash_str, ##__VA_ARGS__); \
} while(0)
#else
#define os_printf os_printf_plus
#endif
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment