feat(esptouch_v2): support esptouch_v2

This commit is contained in:
chenwen
2020-11-11 18:43:45 +08:00
committed by Dong Heng
parent 48be630192
commit b9628e8608
17 changed files with 179 additions and 43 deletions

View File

@@ -28,6 +28,7 @@ typedef enum {
SC_TYPE_ESPTOUCH = 0, /**< protocol: ESPTouch */
SC_TYPE_AIRKISS, /**< protocol: AirKiss */
SC_TYPE_ESPTOUCH_AIRKISS, /**< protocol: ESPTouch and AirKiss */
SC_TYPE_ESPTOUCH_V2, /**< protocol: ESPTouch V2*/
} smartconfig_type_t;
/** Smartconfig event declarations */
@@ -54,12 +55,16 @@ typedef struct {
/** Configure structure for esp_smartconfig_start */
typedef struct {
bool enable_log; /**< Enable smartconfig logs. */
bool enable_log; /**< Enable smartconfig logs. */
bool esp_touch_v2_enable_crypt; /**< Enable ESPTOUCH V2 crypt. */
char* esp_touch_v2_key; /**< ESPTOUCH V2 crypt key, len should be 16. */
} smartconfig_start_config_t;
#define SMARTCONFIG_START_CONFIG_DEFAULT() { \
.enable_log = false \
};
.enable_log = false, \
.esp_touch_v2_enable_crypt = false,\
.esp_touch_v2_key = NULL \
};
/**
* @brief Get the version of SmartConfig.
@@ -139,6 +144,18 @@ esp_err_t esp_smartconfig_set_type(smartconfig_type_t type);
*/
esp_err_t esp_smartconfig_fast_mode(bool enable);
/**
* @brief Get reserved data of ESPTouch_v2.
*
* @param rvd_data reserved data
* @param len length of reserved data
*
* @return
* - ESP_OK: succeed
* - others: fail
*/
esp_err_t esp_smartconfig_get_rvd_data(uint8_t* rvd_data, uint8_t len);
#ifdef __cplusplus
}
#endif

View File

@@ -761,6 +761,8 @@ typedef struct {
esp_aes_decrypt_t aes_decrypt;
esp_aes_decrypt_init_t aes_decrypt_init;
esp_aes_decrypt_deinit_t aes_decrypt_deinit;
esp_aes_128_encrypt_t aes_128_encrypt;
esp_aes_128_decrypt_t aes_128_decrypt;
esp_omac1_aes_128_t omac1_aes_128;
esp_ccmp_decrypt_t ccmp_decrypt;
esp_ccmp_encrypt_t ccmp_encrypt;

View File

@@ -1,8 +1,8 @@
gwen:
core: 5a78602
net80211: 8c48ba9
pp: 8c48ba9
espnow: 5a78602
core: 7a93d71
net80211: 7a93d71
pp: 7a93d71
espnow: 7a93d71
smartconfig: 2.9.0
smartconfig: 3.0.0
phy: 1163.0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
components/esp8266/lib/libsmartconfig.a Normal file → Executable file

Binary file not shown.

View File

@@ -35,7 +35,9 @@
#define SC_ACK_TASK_PRIORITY 2 /*!< Priority of sending smartconfig ACK task */
#define SC_ACK_TASK_STACK_SIZE 2048 /*!< Stack size of sending smartconfig ACK task */
#define SC_ACK_TOUCH_DEVICE_PORT 7001 /*!< ESPTOUCH UDP port of server on device */
#define SC_ACK_TOUCH_SERVER_PORT 18266 /*!< ESP touch UDP port of server on cellphone */
#define SC_ACK_TOUCH_V2_SERVER_PORT(i) (18266+i*10000) /*!< ESP touch_v2 UDP port of server on cellphone */
#define SC_ACK_AIRKISS_SERVER_PORT 10000 /*!< Airkiss UDP port of server on cellphone */
#define SC_ACK_AIRKISS_DEVICE_PORT 10001 /*!< Airkiss UDP port of server on device */
#define SC_ACK_AIRKISS_TIMEOUT 1500 /*!< Airkiss read data timout millisecond */
@@ -78,7 +80,6 @@ static void sc_ack_send_task(void* pvParameters)
tcpip_adapter_ip_info_t local_ip;
uint8_t remote_ip[4];
memset(remote_ip, 0xFF, sizeof(remote_ip));
int remote_port = (ack->type == SC_TYPE_ESPTOUCH) ? SC_ACK_TOUCH_SERVER_PORT : SC_ACK_AIRKISS_SERVER_PORT;
struct sockaddr_in server_addr;
socklen_t sin_size = sizeof(server_addr);
int send_sock = -1;
@@ -88,6 +89,19 @@ static void sc_ack_send_task(void* pvParameters)
uint8_t packet_count = 1;
int err;
int ret;
int remote_port = 0;
if (ack->type == SC_TYPE_ESPTOUCH) {
remote_port = SC_ACK_TOUCH_SERVER_PORT;
} else if (ack->type == SC_TYPE_ESPTOUCH_V2) {
uint8_t port_bit = ack->ctx.token;
if(port_bit > 3) {
port_bit = 0;
}
remote_port = SC_ACK_TOUCH_V2_SERVER_PORT(port_bit);
} else {
remote_port = SC_ACK_AIRKISS_SERVER_PORT;
}
bzero(&server_addr, sizeof(struct sockaddr_in));
server_addr.sin_family = AF_INET;
@@ -152,7 +166,7 @@ static void sc_ack_send_task(void* pvParameters)
sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
if (sendlen > 0) {
/* Totally send 30 smartconfig ACKs. Then smartconfig is successful. */
/* Totally send 60 smartconfig ACKs. Then smartconfig is successful. */
if (packet_count++ >= SC_ACK_MAX_COUNT) {
esp_event_post(SC_EVENT, SC_EVENT_SEND_ACK_DONE, NULL, 0, portMAX_DELAY);
goto _end;