This commit is contained in:
Bogdan Pilyugin 2023-01-11 16:54:37 +02:00
commit 3bccda1486
5 changed files with 16 additions and 9 deletions

View File

@ -501,6 +501,13 @@ menu "WebGUIApp"
Pin to unlock the SIM Pin to unlock the SIM
menu "UART Configuration" menu "UART Configuration"
config MODEM_UART_PORT_NUM
int "Modem UART port number"
default 1
range 0 2
help
UART port number dedicated to modem
config MODEM_UART_TX_PIN config MODEM_UART_TX_PIN
int "TXD Pin Number" int "TXD Pin Number"
default 17 default 17

View File

@ -93,9 +93,6 @@ void NextDefaultNetIF(void);
void PrintDefaultNetIF(void); void PrintDefaultNetIF(void);
void GetDefaultNetIFName(char *name); void GetDefaultNetIFName(char *name);
void InitRS485(void);
void RS485Task(void *pvParameter);
void PrintNetifs(void); void PrintNetifs(void);
void GotEthIF(void); void GotEthIF(void);

View File

@ -176,6 +176,7 @@ static void GSMInitTask(void *pvParameter)
/* Configure the DTE */ /* Configure the DTE */
esp_modem_dte_config_t dte_config = ESP_MODEM_DTE_DEFAULT_CONFIG(); esp_modem_dte_config_t dte_config = ESP_MODEM_DTE_DEFAULT_CONFIG();
/* setup UART specific configuration based on kconfig options */ /* setup UART specific configuration based on kconfig options */
//dte_config.uart_config.port_num = CONFIG_MODEM_UART_PORT_NUM;
dte_config.uart_config.tx_io_num = CONFIG_MODEM_UART_TX_PIN; dte_config.uart_config.tx_io_num = CONFIG_MODEM_UART_TX_PIN;
dte_config.uart_config.rx_io_num = CONFIG_MODEM_UART_RX_PIN; dte_config.uart_config.rx_io_num = CONFIG_MODEM_UART_RX_PIN;
dte_config.uart_config.rts_io_num = CONFIG_MODEM_UART_RTS_PIN; dte_config.uart_config.rts_io_num = CONFIG_MODEM_UART_RTS_PIN;

View File

@ -46,7 +46,7 @@
#define MESSAGE_LENGTH 32 #define MESSAGE_LENGTH 32
#define TAG "LoRaWANApp" #define TAG "LoRaWANApp"
#define LORAWAN_APP_LOG_ENABLED 1 #define LORAWAN_APP_LOG_ENABLED 1
#define LORAWAN_MESSAGE_BUFER_LENTH 8 #define LORAWAN_MESSAGE_BUFER_LENTH 5
QueueHandle_t LORAMessagesQueueHandle; QueueHandle_t LORAMessagesQueueHandle;
static StaticQueue_t xStaticLoRaMessagesQueue; static StaticQueue_t xStaticLoRaMessagesQueue;

View File

@ -24,7 +24,7 @@
#include "NetTransport.h" #include "NetTransport.h"
#include "MQTT.h" #include "MQTT.h"
#define MQTT_MESSAGE_BUFER_LENTH 8 //size of mqtt queue #define MQTT_MESSAGE_BUFER_LENTH 5 //size of mqtt queue
#define MQTT_RECONNECT_CHANGE_ADAPTER 3 #define MQTT_RECONNECT_CHANGE_ADAPTER 3
#if CONFIG_WEBGUIAPP_MQTT_ENABLE #if CONFIG_WEBGUIAPP_MQTT_ENABLE
@ -40,7 +40,8 @@ mqtt_client_t mqtt[CONFIG_WEBGUIAPP_MQTT_CLIENTS_NUM] = { 0 };
#define TAG "MQTTApp" #define TAG "MQTTApp"
static void mqtt_system_event_handler(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data); static void mqtt_system_event_handler(int idx, void *handler_args, esp_event_base_t base, int32_t event_id,
void *event_data);
static void mqtt1_system_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data); static void mqtt1_system_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data);
static void mqtt2_system_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data); static void mqtt2_system_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data);
@ -49,7 +50,7 @@ static void mqtt2_user_event_handler(void *handler_args, esp_event_base_t base,
void (*UserEventHandler)(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data); void (*UserEventHandler)(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data);
void regUserEventHandler( void regUserEventHandler(
void (*event_handler)(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)) void (*event_handler)(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data))
{ {
UserEventHandler = event_handler; UserEventHandler = event_handler;
} }
@ -97,7 +98,8 @@ void ComposeTopic(char *topic, int idx, char *service_name, char *direct)
strcat((char*) topic, direct); // Data direction UPLINK or DOWNLINK strcat((char*) topic, direct); // Data direction UPLINK or DOWNLINK
} }
static void mqtt_system_event_handler(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) static void mqtt_system_event_handler(int idx, void *handler_args, esp_event_base_t base, int32_t event_id,
void *event_data)
{ {
xSemaphoreTake(xSemaphoreMQTTHandle, pdMS_TO_TICKS(1000)); xSemaphoreTake(xSemaphoreMQTTHandle, pdMS_TO_TICKS(1000));
ESP_LOGI(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); ESP_LOGI(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id);
@ -223,7 +225,7 @@ void MQTTTaskTransmit(void *pvParameter)
xQueueReceive(mqtt[idx].mqtt_queue, &DSS, portMAX_DELAY); xQueueReceive(mqtt[idx].mqtt_queue, &DSS, portMAX_DELAY);
if (mqtt[idx].mqtt) if (mqtt[idx].mqtt)
{ {
ESP_LOGW(TAG,"MQTT data send:%.*s", DSS.data_length, DSS.raw_data_ptr); ESP_LOGI(TAG, "MQTT client %d data send:%.*s", idx, DSS.data_length, DSS.raw_data_ptr);
esp_mqtt_client_publish(mqtt[idx].mqtt, esp_mqtt_client_publish(mqtt[idx].mqtt,
(const char*) DSS.topic, (const char*) DSS.topic,
(const char*) DSS.raw_data_ptr, (const char*) DSS.raw_data_ptr,