Merge branch 'master' into feature/esp32s2beta_merge

This commit is contained in:
Angus Gratton
2019-10-22 13:51:49 +11:00
committed by Angus Gratton
143 changed files with 4319 additions and 1090 deletions

View File

@@ -11,4 +11,4 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(mqtt_publish)
target_add_binary_data(mqtt_publish.elf "main/iot_eclipse_org.pem" TEXT)
target_add_binary_data(mqtt_publish.elf "main/mqtt_eclipse_org.pem" TEXT)

View File

@@ -2,25 +2,25 @@ menu "Example Configuration"
config EXAMPLE_BROKER_SSL_URI
string "Broker SSL URL"
default "mqtts://iot.eclipse.org:8883"
default "mqtts://mqtt.eclipse.org:8883"
help
URL of an mqtt broker for ssl transport
config EXAMPLE_BROKER_TCP_URI
string "Broker TCP URL"
default "mqtt://iot.eclipse.org:1883"
default "mqtt://mqtt.eclipse.org:1883"
help
URL of an mqtt broker for tcp transport
config EXAMPLE_BROKER_WS_URI
string "Broker WS URL"
default "ws://iot.eclipse.org:80/ws"
default "ws://mqtt.eclipse.org:80/mqtt"
help
URL of an mqtt broker for ws transport
config EXAMPLE_BROKER_WSS_URI
string "Broker WSS URL"
default "wss://iot.eclipse.org:443/ws"
default "wss://mqtt.eclipse.org:443/mqtt"
help
URL of an mqtt broker for wss transport

View File

@@ -1 +1 @@
COMPONENT_EMBED_TXTFILES := iot_eclipse_org.pem
COMPONENT_EMBED_TXTFILES := mqtt_eclipse_org.pem

View File

@@ -46,11 +46,11 @@ static int qos_test = 0;
#if CONFIG_EXAMPLE_BROKER_CERTIFICATE_OVERRIDDEN == 1
static const uint8_t iot_eclipse_org_pem_start[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_EXAMPLE_BROKER_CERTIFICATE_OVERRIDE "\n-----END CERTIFICATE-----";
static const uint8_t mqtt_eclipse_org_pem_start[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_EXAMPLE_BROKER_CERTIFICATE_OVERRIDE "\n-----END CERTIFICATE-----";
#else
extern const uint8_t iot_eclipse_org_pem_start[] asm("_binary_iot_eclipse_org_pem_start");
extern const uint8_t mqtt_eclipse_org_pem_start[] asm("_binary_mqtt_eclipse_org_pem_start");
#endif
extern const uint8_t iot_eclipse_org_pem_end[] asm("_binary_iot_eclipse_org_pem_end");
extern const uint8_t mqtt_eclipse_org_pem_end[] asm("_binary_mqtt_eclipse_org_pem_end");
static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event)
{
@@ -127,7 +127,7 @@ static void mqtt_app_start(void)
mqtt_event_group = xEventGroupCreate();
const esp_mqtt_client_config_t mqtt_cfg = {
.event_handle = mqtt_event_handler,
.cert_pem = (const char *)iot_eclipse_org_pem_start,
.cert_pem = (const char *)mqtt_eclipse_org_pem_start,
};
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());

View File

@@ -10,4 +10,4 @@ set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(mqtt_ssl)
target_add_binary_data(mqtt_ssl.elf "main/iot_eclipse_org.pem" TEXT)
target_add_binary_data(mqtt_ssl.elf "main/mqtt_eclipse_org.pem" TEXT)

View File

@@ -2,7 +2,7 @@
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example connects to the broker iot.eclipse.org using ssl transport and as a demonstration subscribes/unsubscribes and send a message on certain topic.
This example connects to the broker mqtt.eclipse.org using ssl transport and as a demonstration subscribes/unsubscribes and send a message on certain topic.
(Please note that the public broker is maintained by the community so may not be always available, for details please see this [disclaimer](https://iot.eclipse.org/getting-started/#sandboxes))
It uses ESP-MQTT library which implements mqtt client to connect to mqtt broker.
@@ -19,13 +19,13 @@ This example can be executed on any ESP32 board, the only required interface is
* Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../../README.md) for more details.
* When using Make build system, set `Default serial port` under `Serial flasher config`.
PEM certificate for this example could be extracted from an openssl `s_client` command connecting to iot.eclipse.org.
PEM certificate for this example could be extracted from an openssl `s_client` command connecting to mqtt.eclipse.org.
In case a host operating system has `openssl` and `sed` packages installed, one could execute the following command to download and save the root certificate to a file (Note for Windows users: Both Linux like environment or Windows native packages may be used).
```
echo "" | openssl s_client -showcerts -connect iot.eclipse.org:8883 | sed -n "1,/Root/d; /BEGIN/,/END/p" | openssl x509 -outform PEM >iot_eclipse_org.pem
echo "" | openssl s_client -showcerts -connect mqtt.eclipse.org:8883 | sed -n "1,/Root/d; /BEGIN/,/END/p" | openssl x509 -outform PEM >mqtt_eclipse_org.pem
```
Please note that this is not a general command for downloading a root certificate for an arbitrary host;
this command works with iot.eclipse.org as the site provides root certificate in the chain, which then could be extracted
this command works with mqtt.eclipse.org as the site provides root certificate in the chain, which then could be extracted
with text operation.
### Build and Flash

View File

@@ -2,7 +2,7 @@ menu "Example Configuration"
config BROKER_URI
string "Broker URL"
default "mqtts://iot.eclipse.org:8883"
default "mqtts://mqtt.eclipse.org:8883"
help
URL of an mqtt broker which this example connects to.

View File

@@ -35,11 +35,11 @@ static const char *TAG = "MQTTS_EXAMPLE";
#if CONFIG_BROKER_CERTIFICATE_OVERRIDDEN == 1
static const uint8_t iot_eclipse_org_pem_start[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_BROKER_CERTIFICATE_OVERRIDE "\n-----END CERTIFICATE-----";
static const uint8_t mqtt_eclipse_org_pem_start[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_BROKER_CERTIFICATE_OVERRIDE "\n-----END CERTIFICATE-----";
#else
extern const uint8_t iot_eclipse_org_pem_start[] asm("_binary_iot_eclipse_org_pem_start");
extern const uint8_t mqtt_eclipse_org_pem_start[] asm("_binary_mqtt_eclipse_org_pem_start");
#endif
extern const uint8_t iot_eclipse_org_pem_end[] asm("_binary_iot_eclipse_org_pem_end");
extern const uint8_t mqtt_eclipse_org_pem_end[] asm("_binary_mqtt_eclipse_org_pem_end");
static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
{
@@ -80,10 +80,14 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
break;
case MQTT_EVENT_ERROR:
ESP_LOGI(TAG, "MQTT_EVENT_ERROR");
int mbedtls_err = 0;
esp_err_t err = esp_tls_get_and_clear_last_error(event->error_handle, &mbedtls_err, NULL);
ESP_LOGI(TAG, "Last esp error code: 0x%x", err);
ESP_LOGI(TAG, "Last mbedtls failure: 0x%x", mbedtls_err);
if (event->error_handle->error_type == MQTT_ERROR_TYPE_ESP_TLS) {
ESP_LOGI(TAG, "Last error code reported from esp-tls: 0x%x", event->error_handle->esp_tls_last_esp_err);
ESP_LOGI(TAG, "Last tls stack error number: 0x%x", event->error_handle->esp_tls_stack_err);
} else if (event->error_handle->error_type == MQTT_ERROR_TYPE_CONNECTION_REFUSED) {
ESP_LOGI(TAG, "Connection refused error: 0x%x", event->error_handle->connect_return_code);
} else {
ESP_LOGW(TAG, "Unknown error type: 0x%x", event->error_handle->error_type);
}
break;
default:
ESP_LOGI(TAG, "Other event id:%d", event->event_id);
@@ -101,7 +105,7 @@ static void mqtt_app_start(void)
{
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.cert_pem = (const char *)iot_eclipse_org_pem_start,
.cert_pem = (const char *)mqtt_eclipse_org_pem_start,
};
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());

View File

@@ -1 +1 @@
COMPONENT_EMBED_TXTFILES := iot_eclipse_org.pem
COMPONENT_EMBED_TXTFILES := mqtt_eclipse_org.pem

View File

@@ -88,7 +88,7 @@ def test_examples_protocol_mqtt_ssl(env, extra_data):
client.on_message = on_message
client.tls_set(None,
None,
None, cert_reqs=ssl.CERT_NONE, tls_version=ssl.PROTOCOL_TLSv1, ciphers=None)
None, cert_reqs=ssl.CERT_NONE, tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)
client.tls_insecure_set(True)
print("Connecting...")
client.connect(broker_url, broker_port, 60)

View File

@@ -2,7 +2,7 @@ menu "Example Configuration"
config BROKER_URL
string "Broker URL"
default "mqtt://iot.eclipse.org"
default "mqtt://mqtt.eclipse.org"
help
URL of the broker to connect to

View File

@@ -2,7 +2,7 @@
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example connects to the broker iot.eclipse.org over web sockets as a demonstration subscribes/unsubscribes and send a message on certain topic.
This example connects to the broker mqtt.eclipse.org over web sockets as a demonstration subscribes/unsubscribes and send a message on certain topic.
(Please note that the public broker is maintained by the community so may not be always available, for details please see this [disclaimer](https://iot.eclipse.org/getting-started/#sandboxes))
It uses ESP-MQTT library which implements mqtt client to connect to mqtt broker.

View File

@@ -2,7 +2,7 @@ menu "Example Configuration"
config BROKER_URI
string "Broker URL"
default "ws://iot.eclipse.org:80/ws"
default "ws://mqtt.eclipse.org:80/mqtt"
help
URL of an mqtt broker which this example connects to.

View File

@@ -83,7 +83,6 @@ def test_examples_protocol_mqtt_ws(env, extra_data):
client = mqtt.Client(transport="websockets")
client.on_connect = on_connect
client.on_message = on_message
client.ws_set_options(path="/ws", headers=None)
print("Connecting...")
client.connect(broker_url, broker_port, 60)
except Exception:

View File

@@ -10,4 +10,4 @@ set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(mqtt_websocket_secure)
target_add_binary_data(mqtt_websocket_secure.elf "main/iot_eclipse_org.pem" TEXT)
target_add_binary_data(mqtt_websocket_secure.elf "main/mqtt_eclipse_org.pem" TEXT)

View File

@@ -1,7 +1,7 @@
# ESP-MQTT MQTT over WSS Sample application
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example connects to the broker iot.eclipse.org over secure websockets and as a demonstration subscribes/unsubscribes and send a message on certain topic.
This example connects to the broker mqtt.eclipse.org over secure websockets and as a demonstration subscribes/unsubscribes and send a message on certain topic.
(Please note that the public broker is maintained by the community so may not be always available, for details please see this [disclaimer](https://iot.eclipse.org/getting-started/#sandboxes))
It uses ESP-MQTT library which implements mqtt client to connect to mqtt broker.
@@ -18,15 +18,15 @@ This example can be executed on any ESP32 board, the only required interface is
* Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../../README.md) for more details.
* When using Make build system, set `Default serial port` under `Serial flasher config`.
Note how to create a PEM certificate for iot.eclipse.org:
Note how to create a PEM certificate for mqtt.eclipse.org:
PEM certificate for this example could be extracted from an openssl `s_client` command connecting to iot.eclipse.org.
PEM certificate for this example could be extracted from an openssl `s_client` command connecting to mqtt.eclipse.org.
In case a host operating system has `openssl` and `sed` packages installed, one could execute the following command to download and save the root certificate to a file (Note for Windows users: Both Linux like environment or Windows native packages may be used).
```
echo "" | openssl s_client -showcerts -connect iot.eclipse.org:443 | sed -n "1,/Root/d; /BEGIN/,/END/p" | openssl x509 -outform PEM >iot_eclipse_org.pem
echo "" | openssl s_client -showcerts -connect mqtt.eclipse.org:443 | sed -n "1,/Root/d; /BEGIN/,/END/p" | openssl x509 -outform PEM >mqtt_eclipse_org.pem
```
Please note that this is not a general command for downloading a root certificate for an arbitrary host;
this command works with iot.eclipse.org as the site provides root certificate in the chain, which then could be extracted
this command works with mqtt.eclipse.org as the site provides root certificate in the chain, which then could be extracted
with text operation.
### Build and Flash

View File

@@ -2,7 +2,7 @@ menu "Example Configuration"
config BROKER_URI
string "Broker URL"
default "wss://iot.eclipse.org:443/ws"
default "wss://mqtt.eclipse.org:443/mqtt"
help
URL of an mqtt broker which this example connects to.

View File

@@ -33,11 +33,11 @@ static const char *TAG = "MQTTWSS_EXAMPLE";
#if CONFIG_BROKER_CERTIFICATE_OVERRIDDEN == 1
static const uint8_t iot_eclipse_org_pem_start[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_BROKER_CERTIFICATE_OVERRIDE "\n-----END CERTIFICATE-----";
static const uint8_t mqtt_eclipse_org_pem_start[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_BROKER_CERTIFICATE_OVERRIDE "\n-----END CERTIFICATE-----";
#else
extern const uint8_t iot_eclipse_org_pem_start[] asm("_binary_iot_eclipse_org_pem_start");
extern const uint8_t mqtt_eclipse_org_pem_start[] asm("_binary_mqtt_eclipse_org_pem_start");
#endif
extern const uint8_t iot_eclipse_org_pem_end[] asm("_binary_iot_eclipse_org_pem_end");
extern const uint8_t mqtt_eclipse_org_pem_end[] asm("_binary_mqtt_eclipse_org_pem_end");
static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
{
@@ -95,7 +95,7 @@ static void mqtt_app_start(void)
{
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.cert_pem = (const char *)iot_eclipse_org_pem_start,
.cert_pem = (const char *)mqtt_eclipse_org_pem_start,
};
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());

View File

@@ -1 +1 @@
COMPONENT_EMBED_TXTFILES := iot_eclipse_org.pem
COMPONENT_EMBED_TXTFILES := mqtt_eclipse_org.pem

View File

@@ -86,7 +86,7 @@ def test_examples_protocol_mqtt_wss(env, extra_data):
client.on_message = on_message
client.tls_set(None,
None,
None, cert_reqs=ssl.CERT_NONE, tls_version=ssl.PROTOCOL_TLSv1, ciphers=None)
None, cert_reqs=ssl.CERT_NONE, tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)
print("Connecting...")
client.connect(broker_url, broker_port, 60)
except Exception: