fixed lorawan send issue
This commit is contained in:
parent
cfcc766037
commit
0fe87215ef
|
|
@ -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 32
|
#define LORAWAN_MESSAGE_BUFER_LENTH 8
|
||||||
|
|
||||||
QueueHandle_t LORAMessagesQueueHandle;
|
QueueHandle_t LORAMessagesQueueHandle;
|
||||||
static StaticQueue_t xStaticLoRaMessagesQueue;
|
static StaticQueue_t xStaticLoRaMessagesQueue;
|
||||||
|
|
@ -60,7 +60,6 @@ void regLoRaUserReceiveHandler(
|
||||||
LoRaUserReceiveHandler = user_handler;
|
LoRaUserReceiveHandler = user_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t LORASendData(LORA_DATA_SEND_STRUCT *pdss)
|
esp_err_t LORASendData(LORA_DATA_SEND_STRUCT *pdss)
|
||||||
{
|
{
|
||||||
char *ptr = (char*) malloc(MESSAGE_LENGTH);
|
char *ptr = (char*) malloc(MESSAGE_LENGTH);
|
||||||
|
|
@ -111,14 +110,13 @@ void LoRaWANTransportTask(void *pvParameter)
|
||||||
if (ttn_is_provisioned())
|
if (ttn_is_provisioned())
|
||||||
{
|
{
|
||||||
xQueueReceive(LORAMessagesQueueHandle, &DSS, portMAX_DELAY);
|
xQueueReceive(LORAMessagesQueueHandle, &DSS, portMAX_DELAY);
|
||||||
ttn_transmit_message((const uint8_t*) DSS.raw_data_ptr, MESSAGE_LENGTH, 1, true);
|
|
||||||
|
|
||||||
#if LORAWAN_APP_LOG_ENABLED == 1
|
#if LORAWAN_APP_LOG_ENABLED == 1
|
||||||
char P[MESSAGE_LENGTH * 2 + 1];
|
char P[MESSAGE_LENGTH * 2 + 1];
|
||||||
BytesToStr((unsigned char*) DSS.raw_data_ptr, (unsigned char*) P, MESSAGE_LENGTH);
|
BytesToStr((unsigned char*) DSS.raw_data_ptr, (unsigned char*) P, MESSAGE_LENGTH);
|
||||||
P[MESSAGE_LENGTH * 2] = 0x00;
|
P[MESSAGE_LENGTH * 2] = 0x00;
|
||||||
ESP_LOGI(TAG, "Sent=%s", P);
|
ESP_LOGI(TAG, "Send=%s", P);
|
||||||
#endif
|
#endif
|
||||||
|
ttn_transmit_message((const uint8_t*) DSS.raw_data_ptr, MESSAGE_LENGTH, 1, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "NetTransport.h"
|
#include "NetTransport.h"
|
||||||
#include "MQTT.h"
|
#include "MQTT.h"
|
||||||
|
|
||||||
#define MQTT_MESSAGE_BUFER_LENTH 32 //size of mqtt queue
|
#define MQTT_MESSAGE_BUFER_LENTH 8 //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
|
||||||
|
|
@ -221,7 +221,7 @@ void MQTTTaskTransmit(void *pvParameter)
|
||||||
{
|
{
|
||||||
while (!mqtt[idx].is_connected)
|
while (!mqtt[idx].is_connected)
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
xQueuePeek(mqtt[idx].mqtt_queue, &DSS, portMAX_DELAY);
|
xQueueReceive(mqtt[idx].mqtt_queue, &DSS, portMAX_DELAY);
|
||||||
if (mqtt[idx].mqtt)
|
if (mqtt[idx].mqtt)
|
||||||
{
|
{
|
||||||
esp_mqtt_client_publish(mqtt[idx].mqtt,
|
esp_mqtt_client_publish(mqtt[idx].mqtt,
|
||||||
|
|
@ -232,12 +232,7 @@ void MQTTTaskTransmit(void *pvParameter)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ESP_LOGE(TAG, "MQTT client not initialized");
|
ESP_LOGE(TAG, "MQTT client not initialized");
|
||||||
|
|
||||||
//Here, if need, can be added repeat transmission after delivery timeout.
|
|
||||||
//In this case, follow code must be skipped here and executed on delivery confirm or on exceeded retry attempts
|
|
||||||
xQueueReceive(mqtt[idx].mqtt_queue, &DSS, 0);
|
|
||||||
free(DSS.raw_data_ptr);
|
free(DSS.raw_data_ptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
#include "romfs.h"
|
#include "romfs.h"
|
||||||
#include "HTTPServer.h"
|
#include "HTTPServer.h"
|
||||||
|
|
||||||
#define MESSAGE_LENGTH 32 //base message length, mainly depended by radio requirements
|
#define PANEL_MESSAGE_LENGTH 32 //base message length, mainly depended by radio requirements
|
||||||
#define MAX_JSON_MESSAGE 256 //max size of mqtt message to publish
|
#define MAX_JSON_MESSAGE 256 //max size of mqtt message to publish
|
||||||
#define MAX_FILE_PUBLISH 4096 //bufer for mqtt data publish
|
#define MAX_FILE_PUBLISH 4096 //bufer for mqtt data publish
|
||||||
#define MAX_DYNVAR_LENTH 64
|
#define MAX_DYNVAR_LENTH 64
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user