Compare commits

...

7 Commits

Author SHA1 Message Date
3236358ded Update WiFiClient.cpp (#4573)
Replace (depricated) bzero, bcopy with memset and memcpy.
2020-12-01 16:35:12 +02:00
82e71f9b50 Update ssl_client.cpp (#4574)
Replace (depricated) bzero with memset.
2020-12-01 16:34:36 +02:00
2e12392721 IDF release/v3.3 c33fc7821
esp-face: master 420fc7e
esp32-camera: master 0107093
2020-12-01 16:22:18 +02:00
6b0114366b Fix logic in SPIClass::setHwCs. (#4559)
Fixes #4558
2020-11-23 14:22:43 +02:00
18832bb418 M5TimerCam: add LED_BUILTIN & SS/MOSI/MISO/SCK (#4560) 2020-11-23 14:21:58 +02:00
97dcea2b99 Update library.properties (#4563)
Set the category to silence this warning in the Arduino IDE:
```
WARNING: Category '' in library WiFiProv is not valid. Setting to 'Uncategorized'
```
2020-11-23 14:21:34 +02:00
dcff2e9774 Separate Provisioning library from WiFi library (#4547) 2020-11-19 00:12:16 +02:00
81 changed files with 81 additions and 39 deletions

View File

@ -72,11 +72,11 @@ set(LIBRARY_SRCS
libraries/WiFi/src/WiFi.cpp
libraries/WiFi/src/WiFiGeneric.cpp
libraries/WiFi/src/WiFiMulti.cpp
libraries/WiFi/src/WiFiProv.cpp
libraries/WiFi/src/WiFiScan.cpp
libraries/WiFi/src/WiFiServer.cpp
libraries/WiFi/src/WiFiSTA.cpp
libraries/WiFi/src/WiFiUdp.cpp
libraries/WiFiProv/src/WiFiProv.cpp
libraries/Wire/src/Wire.cpp
)
@ -202,6 +202,7 @@ set(COMPONENT_ADD_INCLUDEDIRS
libraries/WebServer/src
libraries/WiFiClientSecure/src
libraries/WiFi/src
libraries/WiFiProv/src
libraries/Wire/src
)

View File

@ -85,7 +85,7 @@ void SPIClass::setHwCs(bool use)
if(use && !_use_hw_ss) {
spiAttachSS(_spi, 0, _ss);
spiSSEnable(_spi);
} else if(_use_hw_ss) {
} else if(!use && _use_hw_ss) {
spiSSDisable(_spi);
spiDetachSS(_spi, _ss);
}

View File

@ -88,4 +88,14 @@ void WiFiClass::printDiag(Print& p)
p.println(conf.sta.bssid_set);
}
void WiFiClass::enableProv(bool status)
{
prov_enable = status;
}
bool WiFiClass::isProvEnabled()
{
return prov_enable;
}
WiFiClass WiFi;

View File

@ -37,11 +37,17 @@
#include "WiFiClient.h"
#include "WiFiServer.h"
#include "WiFiUdp.h"
#include "WiFiProv.h"
class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass, public WiFiProvClass
class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass
{
private:
bool prov_enable;
public:
WiFiClass()
{
prov_enable = false;
}
using WiFiGenericClass::channel;
using WiFiSTAClass::SSID;
@ -60,6 +66,8 @@ public:
friend class WiFiClient;
friend class WiFiServer;
friend class WiFiUDP;
void enableProv(bool status);
bool isProvEnabled();
};
extern WiFiClass WiFi;

View File

@ -216,9 +216,9 @@ int WiFiClient::connect(IPAddress ip, uint16_t port, int32_t timeout)
uint32_t ip_addr = ip;
struct sockaddr_in serveraddr;
bzero((char *) &serveraddr, sizeof(serveraddr));
memset((char *) &serveraddr, 0, sizeof(serveraddr));
serveraddr.sin_family = AF_INET;
bcopy((const void *)(&ip_addr), (void *)&serveraddr.sin_addr.s_addr, 4);
memcpy((void *)&serveraddr.sin_addr.s_addr, (const void *)(&ip_addr), 4);
serveraddr.sin_port = htons(port);
fd_set fdset;
struct timeval tv;

View File

@ -227,7 +227,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
log_v("Verifying peer X.509 certificate...");
if ((flags = mbedtls_ssl_get_verify_result(&ssl_client->ssl_ctx)) != 0) {
bzero(buf, sizeof(buf));
memset(buf, 0, sizeof(buf));
mbedtls_x509_crt_verify_info(buf, sizeof(buf), " ! ", flags);
log_e("Failed to verify peer certificate! verification info: %s", buf);
stop_ssl_socket(ssl_client, rootCABuff, cli_cert, cli_key); //It's not safe continue.

View File

@ -1,4 +1,4 @@
#include "WiFi.h"
#include "WiFiProv.h"
void SysProvEvent(system_event_t *sys_event,wifi_prov_event_t *prov_event)
{
if(sys_event) {
@ -56,8 +56,8 @@ void setup() {
/* uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf,
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/
WiFi.onEvent(SysProvEvent);
//WiFi.beginProvision(provSchemeBLE, WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "PROV_XXX", NULL, NULL);
WiFi.beginProvision(provSchemeSoftAP, WIFI_PROV_EVENT_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", NULL, NULL, NULL);
//WiFiProv.beginProvision(provSchemeBLE, WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "PROV_XXX", NULL, NULL);
WiFiProv.beginProvision(provSchemeSoftAP, WIFI_PROV_EVENT_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", NULL, NULL, NULL);
}
void loop() {

View File

@ -0,0 +1,9 @@
name=WiFiProv
version=1.0
author=Switi Mhaiske <sweetymhaiske@gmail.com>
maintainer=Hristo Gochkov <hristo@espressif.com>
sentence=Enables provisioning.
paragraph=With this library you can perform provisioning on esp32 via SoftAP or BLE.
category=Communication
url=
architectures=esp32

View File

@ -31,7 +31,8 @@
#include <wifi_provisioning/scheme_softap.h>
#include <wifi_provisioning/manager.h>
#undef IPADDR_NONE
#include "WiFi.h"
#include "WiFiProv.h"
#include "SimpleBLE.h"
extern esp_err_t postToSysQueue(system_prov_event_t *);
@ -42,13 +43,6 @@ static const uint8_t custom_service_uuid[16] = { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f,
#define SERV_NAME_PREFIX_PROV "PROV_"
bool WiFiProvClass::prov_enable = true;
bool WiFiProvClass::isProvEnabled()
{
return prov_enable;
}
void provSchemeBLE()
{
prov_scheme = WIFI_PROV_SCHEME_BLE;
@ -109,7 +103,7 @@ static void get_device_service_name(char *service_name, size_t max)
void WiFiProvClass :: beginProvision(void (*scheme_cb)(), wifi_prov_event_handler_t scheme_event_handler, wifi_prov_security_t security, const char * pop, const char *service_name, const char *service_key, uint8_t * uuid)
{
prov_enable = true;
WiFi.enableProv(true);
bool provisioned = false;
scheme_cb();
config.scheme_event_handler = scheme_event_handler;
@ -152,7 +146,7 @@ void WiFiProvClass :: beginProvision(void (*scheme_cb)(), wifi_prov_event_handle
} else {
wifi_prov_mgr_deinit();
WiFi.mode(WIFI_MODE_STA);
log_i("Aleardy Provisioned, starting Wi-Fi STA");
log_i("Already Provisioned, starting Wi-Fi STA");
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
wifi_config_t conf;
esp_wifi_get_config(WIFI_IF_STA,&conf);
@ -162,4 +156,4 @@ void WiFiProvClass :: beginProvision(void (*scheme_cb)(), wifi_prov_event_handle
WiFi.begin();
}
}
WiFiProvClass WiFiProv;

View File

@ -17,10 +17,9 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "WiFi.h"
#include "wifi_provisioning/manager.h"
#include "wifi_provisioning/scheme_ble.h"
#include "nvs_flash.h"
#include "SimpleBLE.h"
//Select the scheme using which you want to provision
typedef enum
{
@ -34,19 +33,11 @@ extern void provSchemeBLE();
//Provisioning class
class WiFiProvClass
{
protected:
static bool prov_enable;
public:
WiFiProvClass() {
prov_enable = false;
}
bool isProvEnabled();
void beginProvision(void (*scheme_cb)() = provSchemeSoftAP, wifi_prov_event_handler_t scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE, wifi_prov_security_t security = WIFI_PROV_SECURITY_1, const char * pop = "abcd1234", const char * service_name = NULL, const char * service_key = NULL, uint8_t *uuid = NULL);
};
extern WiFiProvClass WiFiProv;
/*
Event Handler for BLE
- WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM

Binary file not shown.

View File

@ -393,5 +393,5 @@
#define CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG 1
#define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR 1
#define CONFIG_FATFS_API_ENCODING_ANSI_OEM 1
#define CONFIG_ARDUINO_IDF_COMMIT "68b237fe5"
#define CONFIG_ARDUINO_IDF_COMMIT "c33fc7821"
#define CONFIG_ARDUINO_IDF_BRANCH "release/v3.3"

View File

@ -80,10 +80,17 @@ typedef enum {
*/
typedef enum {
MQTT_ERROR_TYPE_NONE = 0,
MQTT_ERROR_TYPE_ESP_TLS,
MQTT_ERROR_TYPE_TCP_TRANSPORT,
MQTT_ERROR_TYPE_CONNECTION_REFUSED,
} esp_mqtt_error_type_t;
/**
* MQTT_ERROR_TYPE_TCP_TRANSPORT error type hold all sorts of transport layer errors,
* including ESP-TLS error, but in the past only the errors from MQTT_ERROR_TYPE_ESP_TLS layer
* were reported, so the ESP-TLS error type is re-defined here for backward compatibility
*/
#define MQTT_ERROR_TYPE_ESP_TLS MQTT_ERROR_TYPE_TCP_TRANSPORT
typedef enum {
MQTT_TRANSPORT_UNKNOWN = 0x0,
MQTT_TRANSPORT_OVER_TCP, /*!< MQTT over TCP, using scheme: ``mqtt`` */
@ -110,7 +117,7 @@ typedef enum {
* Use this structure directly checking error_type first and then appropriate error code depending on the source of the error:
*
* | error_type | related member variables | note |
* | MQTT_ERROR_TYPE_ESP_TLS | esp_tls_last_esp_err, esp_tls_stack_err, esp_tls_cert_verify_flags | Error reported from esp-tls |
* | MQTT_ERROR_TYPE_TCP_TRANSPORT | esp_tls_last_esp_err, esp_tls_stack_err, esp_tls_cert_verify_flags, sock_errno | Error reported from tcp_transport/esp-tls |
* | MQTT_ERROR_TYPE_CONNECTION_REFUSED | connect_return_code | Internal error reported from MQTT broker on connection |
*/
typedef struct esp_mqtt_error_codes {
@ -121,6 +128,9 @@ typedef struct esp_mqtt_error_codes {
/* esp-mqtt specific structure extension */
esp_mqtt_error_type_t error_type; /*!< error type referring to the source of the error */
esp_mqtt_connect_return_code_t connect_return_code; /*!< connection refused error code reported from MQTT broker on connection */
/* tcp_transport extension */
int esp_transport_sock_errno; /*!< errno from the underlying socket */
} esp_mqtt_error_codes_t;
/**
@ -179,7 +189,7 @@ typedef struct {
int refresh_connection_after_ms; /*!< Refresh connection after this value (in milliseconds) */
const struct psk_key_hint* psk_hint_key; /*!< Pointer to PSK struct defined in esp_tls.h to enable PSK authentication (as alternative to certificate verification). If not NULL and server/client certificates are NULL, PSK is enabled */
bool use_global_ca_store; /*!< Use a global ca_store for all the connections in which this bool is set. */
int reconnect_timeout_ms; /*!< Reconnect to the broker after this value in miliseconds if auto reconnect is not disabled */
int reconnect_timeout_ms; /*!< Reconnect to the broker after this value in miliseconds if auto reconnect is not disabled (defaults to 10s) */
const char **alpn_protos; /*!< NULL-terminated list of supported application protocols to be used for ALPN */
const char *clientkey_password; /*!< Client key decryption password string */
int clientkey_password_len; /*!< String length of the password pointed to by clientkey_password */
@ -188,6 +198,8 @@ typedef struct {
bool skip_cert_common_name_check; /*!< Skip any validation of server certificate CN field, this reduces the security of TLS and makes the mqtt client susceptible to MITM attacks */
bool use_secure_element; /*!< enable secure element for enabling SSL connection */
void *ds_data; /*!< carrier of handle for digital signature parameters */
int network_timeout_ms; /*!< Abort network operation if it is not completed after this value, in milliseconds (defaults to 10s) */
bool disable_keepalive; /*!< Set disable_keepalive=true to turn off keep-alive mechanism, false by default (keepalive is active by default). Note: setting the config value `keepalive` to `0` doesn't disable keepalive feature, but uses a default keepalive period */
} esp_mqtt_client_config_t;
/**
@ -347,6 +359,14 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
*/
esp_err_t esp_mqtt_client_register_event(esp_mqtt_client_handle_t client, esp_mqtt_event_id_t event, esp_event_handler_t event_handler, void* event_handler_arg);
/**
* @brief Get outbox size
*
* @param client mqtt client handle
* @return outbox size
*/
int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client);
#ifdef __cplusplus
}
#endif //__cplusplus

View File

@ -84,8 +84,8 @@
#endif
#endif
#ifdef CONFIG_OUTBOX_EXPIRED_TIMEOUT_MS
#define OUTBOX_EXPIRED_TIMEOUT_MS CONFIG_OUTBOX_EXPIRED_TIMEOUT_MS
#ifdef CONFIG_MQTT_OUTBOX_EXPIRED_TIMEOUT_MS
#define OUTBOX_EXPIRED_TIMEOUT_MS CONFIG_MQTT_OUTBOX_EXPIRED_TIMEOUT_MS
#else
#define OUTBOX_EXPIRED_TIMEOUT_MS (30*1000)
#endif

View File

@ -56,6 +56,7 @@
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
// Features supported in 4.3
#define MQTT_SUPPORTED_FEATURE_DIGITAL_SIGNATURE
#define MQTT_SUPPORTED_FEATURE_TRANSPORT_SOCK_ERRNO_REPORTING
#endif
#endif /* ESP_IDF_VERSION */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,12 +11,20 @@
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34)
static const uint8_t LED_BUILTIN = 2;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
static const uint8_t TX = 1;
static const uint8_t RX = 3;
static const uint8_t SDA = 4;
static const uint8_t SCL = 13;
static const uint8_t SS = 5;
static const uint8_t MOSI = 23;
static const uint8_t MISO = 19;
static const uint8_t SCK = 18;
static const uint8_t G23 = 23;
static const uint8_t G25 = 25;
static const uint8_t G27 = 27;