Skip to content

Commit

Permalink
feat: Support using runtime ATECC608A I2C address setup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSciBoy committed Aug 26, 2024
1 parent b5b8033 commit 49923a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/mqtt_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ typedef struct esp_mqtt_client_config_t {
bool use_secure_element; /*!< Enable secure element, available in ESP32-ROOM-32SE, for SSL connection */
void *ds_data; /*!< Carrier of handle for digital signature parameters, digital signature peripheral is
available in some Espressif devices. It's not copied nor freed by the client, user needs to clean up.*/
#ifdef CONFIG_ATECC608A_RUNTIME_SELECTION
uint8_t atecc608a_i2c_addr; /*!< I2C address for the ATECC608A chip that is being used */
#endif // CONFIG_ATECC608A_RUNTIME_SELECTION
} authentication; /*!< Client authentication */
} credentials; /*!< User credentials for broker */
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/include/mqtt_client_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ typedef struct {
uint64_t outbox_limit;
esp_transport_handle_t transport;
struct ifreq * if_name;
#ifdef CONFIG_ATECC608A_RUNTIME_SELECTION
uint8_t atecc608a_i2c_addr;
#endif // CONFIG_ATECC608A_RUNTIME_SELECTION
} mqtt_config_storage_t;

typedef enum {
Expand Down
7 changes: 7 additions & 0 deletions mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ static esp_err_t esp_mqtt_set_ssl_transport_properties(esp_transport_list_handle
if (cfg->use_secure_element) {
#ifdef MQTT_SUPPORTED_FEATURE_SECURE_ELEMENT
#ifdef CONFIG_ESP_TLS_USE_SECURE_ELEMENT
#ifdef CONFIG_ATECC608A_RUNTIME_SELECTION
esp_transport_ssl_use_secure_element(ssl, cfg->atecc608a_i2c_addr);
#else
esp_transport_ssl_use_secure_element(ssl);
#endif
#else
ESP_LOGE(TAG, "Secure element not enabled for esp-tls in menuconfig");
goto esp_mqtt_set_transport_failed;
Expand Down Expand Up @@ -565,6 +569,9 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
client->config->skip_cert_common_name_check = config->broker.verification.skip_cert_common_name_check;
client->config->common_name = config->broker.verification.common_name;
client->config->use_secure_element = config->credentials.authentication.use_secure_element;
#ifdef CONFIG_ATECC608A_RUNTIME_SELECTION
client->config->atecc608a_i2c_addr = config->credentials.authentication.atecc608a_i2c_addr;
#endif // CONFIG_ATECC608A_RUNTIME_SELECTION
client->config->ds_data = config->credentials.authentication.ds_data;

if (config->credentials.authentication.key_password && config->credentials.authentication.key_password_len) {
Expand Down

0 comments on commit 49923a6

Please sign in to comment.