Enhance DaliCloudBridge: add support for LTE UART transport and extend configuration options
Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -14,6 +14,14 @@ constexpr const char* kKeyDeviceID = "device_id";
|
||||
constexpr const char* kKeyUsername = "username";
|
||||
constexpr const char* kKeyPassword = "password";
|
||||
constexpr const char* kKeyTopicPrefix = "topic_prefix";
|
||||
constexpr const char* kKeyCemiTransport = "cemi_transport";
|
||||
constexpr const char* kKeyLteUartEnabled = "lte_uart_en";
|
||||
constexpr const char* kKeyLteUartPort = "lte_uart_port";
|
||||
constexpr const char* kKeyLteTxPin = "lte_tx_pin";
|
||||
constexpr const char* kKeyLteRxPin = "lte_rx_pin";
|
||||
constexpr const char* kKeyLteBaudrate = "lte_baudrate";
|
||||
constexpr const char* kKeyLteRxBuffer = "lte_rx_buf";
|
||||
constexpr const char* kKeyLteTxBuffer = "lte_tx_buf";
|
||||
constexpr const char* kKeyQos = "qos";
|
||||
|
||||
esp_err_t writeString(nvs_handle_t handle, const char* key, const std::string& value) {
|
||||
@@ -52,6 +60,15 @@ esp_err_t GatewayProvisioningStore::save(const GatewayCloudConfig& config) const
|
||||
if (err == ESP_OK) err = writeString(handle, kKeyUsername, config.username);
|
||||
if (err == ESP_OK) err = writeString(handle, kKeyPassword, config.password);
|
||||
if (err == ESP_OK) err = writeString(handle, kKeyTopicPrefix, config.topicPrefix);
|
||||
if (err == ESP_OK) err = writeString(handle, kKeyCemiTransport, config.cemiTransport);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyLteUartEnabled,
|
||||
config.lteUartEnabled ? 1 : 0);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyLteUartPort, config.lteUartPort);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyLteTxPin, config.lteTxPin);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyLteRxPin, config.lteRxPin);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyLteBaudrate, config.lteBaudrate);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyLteRxBuffer, config.lteRxBufferSize);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyLteTxBuffer, config.lteTxBufferSize);
|
||||
if (err == ESP_OK) err = nvs_set_i32(handle, kKeyQos, config.qos);
|
||||
if (err == ESP_OK) err = nvs_commit(handle);
|
||||
|
||||
@@ -83,6 +100,34 @@ esp_err_t GatewayProvisioningStore::load(GatewayCloudConfig* config) const {
|
||||
config->topicPrefix = "devices";
|
||||
}
|
||||
|
||||
esp_err_t transportErr = readString(handle, kKeyCemiTransport, &config->cemiTransport);
|
||||
if (transportErr != ESP_OK) {
|
||||
config->cemiTransport = "mqtt";
|
||||
}
|
||||
|
||||
int32_t intValue = 0;
|
||||
if (nvs_get_i32(handle, kKeyLteUartEnabled, &intValue) == ESP_OK) {
|
||||
config->lteUartEnabled = intValue != 0;
|
||||
}
|
||||
if (nvs_get_i32(handle, kKeyLteUartPort, &intValue) == ESP_OK) {
|
||||
config->lteUartPort = intValue;
|
||||
}
|
||||
if (nvs_get_i32(handle, kKeyLteTxPin, &intValue) == ESP_OK) {
|
||||
config->lteTxPin = intValue;
|
||||
}
|
||||
if (nvs_get_i32(handle, kKeyLteRxPin, &intValue) == ESP_OK) {
|
||||
config->lteRxPin = intValue;
|
||||
}
|
||||
if (nvs_get_i32(handle, kKeyLteBaudrate, &intValue) == ESP_OK) {
|
||||
config->lteBaudrate = intValue;
|
||||
}
|
||||
if (nvs_get_i32(handle, kKeyLteRxBuffer, &intValue) == ESP_OK) {
|
||||
config->lteRxBufferSize = intValue;
|
||||
}
|
||||
if (nvs_get_i32(handle, kKeyLteTxBuffer, &intValue) == ESP_OK) {
|
||||
config->lteTxBufferSize = intValue;
|
||||
}
|
||||
|
||||
int32_t qos = 1;
|
||||
esp_err_t qosErr = nvs_get_i32(handle, kKeyQos, &qos);
|
||||
if (qosErr == ESP_OK) {
|
||||
|
||||
Reference in New Issue
Block a user