smt
This commit is contained in:
@@ -69,19 +69,19 @@ static void prepare_downbound_packet(DownBoundPacket *packet, uint8_t type, uint
|
|||||||
|
|
||||||
static void send_packet_without_retries(uint8_t *data, uint16_t size)
|
static void send_packet_without_retries(uint8_t *data, uint16_t size)
|
||||||
{
|
{
|
||||||
if (xSemaphoreTake(loraRadioMutex, portMAX_DELAY) == pdTRUE)
|
if (xSemaphoreTake(loraRadioMutex, portMAX_DELAY) == pdTRUE)
|
||||||
|
{
|
||||||
|
if (!LoRaSend(data, size, SX126x_TXMODE_SYNC))
|
||||||
{
|
{
|
||||||
if (!LoRaSend(data, size, SX126x_TXMODE_SYNC))
|
ESP_LOGW(TAG, "LoRaSend failed");
|
||||||
{
|
xSemaphoreGive(loraRadioMutex);
|
||||||
ESP_LOGW(TAG, "LoRaSend failed");
|
|
||||||
xSemaphoreGive(loraRadioMutex);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "%d byte packet sent", size);
|
|
||||||
xSemaphoreGive(loraRadioMutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "%d byte packet sent", size);
|
||||||
|
xSemaphoreGive(loraRadioMutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_packet_with_retries(uint8_t *data, uint16_t size)
|
static void send_packet_with_retries(uint8_t *data, uint16_t size)
|
||||||
@@ -126,7 +126,7 @@ void prepare_and_send_telemetry(uint64_t missionTimer)
|
|||||||
uint8_t bufOut[256] = {0};
|
uint8_t bufOut[256] = {0};
|
||||||
|
|
||||||
DownBoundPacket downboundPacket;
|
DownBoundPacket downboundPacket;
|
||||||
uint32_t crc = esp_rom_crc32_le(0,(uint8_t *) &telemetryPacket, sizeof(telemetryPacket));
|
uint32_t crc = esp_rom_crc32_le(0, (uint8_t *)&telemetryPacket, sizeof(telemetryPacket));
|
||||||
prepare_downbound_packet(&downboundPacket, DownlinkPacketType_Telemetry, missionTimer, crc);
|
prepare_downbound_packet(&downboundPacket, DownlinkPacketType_Telemetry, missionTimer, crc);
|
||||||
|
|
||||||
uint16_t offset = 0;
|
uint16_t offset = 0;
|
||||||
@@ -143,13 +143,12 @@ static void build_and_send_ack(uint32_t ackIndex, uint32_t crc32Checksum, uint64
|
|||||||
{
|
{
|
||||||
uint8_t bufOut[256] = {0};
|
uint8_t bufOut[256] = {0};
|
||||||
|
|
||||||
|
|
||||||
ACKPacket ackPacket = {
|
ACKPacket ackPacket = {
|
||||||
.packetIndex = ackIndex,
|
.packetIndex = ackIndex,
|
||||||
.crc32Checksum = crc32Checksum,
|
.crc32Checksum = crc32Checksum,
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t crc = esp_rom_crc32_le(0, (uint8_t *) &ackPacket, sizeof(ackPacket));
|
uint32_t crc = esp_rom_crc32_le(0, (uint8_t *)&ackPacket, sizeof(ackPacket));
|
||||||
|
|
||||||
DownBoundPacket downboundPacket;
|
DownBoundPacket downboundPacket;
|
||||||
prepare_downbound_packet(&downboundPacket, DownlinkPacketType_ACK, missionTimer, crc);
|
prepare_downbound_packet(&downboundPacket, DownlinkPacketType_ACK, missionTimer, crc);
|
||||||
@@ -199,7 +198,8 @@ void process_uplink_packet(uint8_t *data, uint8_t len, uint64_t missionTimer)
|
|||||||
|
|
||||||
uint32_t crc = esp_rom_crc32_le(0, payload, payloadRXLen);
|
uint32_t crc = esp_rom_crc32_le(0, payload, payloadRXLen);
|
||||||
|
|
||||||
if (crc != uplinkPacket.CRCCheck) {
|
if (crc != uplinkPacket.CRCCheck)
|
||||||
|
{
|
||||||
ESP_LOGE(TAG, "Received BAD CRC for packet %ld, crc is %ld, should be %ld", uplinkPacket.packetIndex, crc, uplinkPacket.CRCCheck);
|
ESP_LOGE(TAG, "Received BAD CRC for packet %ld, crc is %ld, should be %ld", uplinkPacket.packetIndex, crc, uplinkPacket.CRCCheck);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -285,10 +285,6 @@ void lora_receive_task(void *pvParameters)
|
|||||||
void lora_comms_task(void *pvParameters)
|
void lora_comms_task(void *pvParameters)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "lora_comms_task started");
|
|
||||||
|
|
||||||
// while (foundDevices[0] != 2) {
|
// while (foundDevices[0] != 2) {
|
||||||
// vTaskDelay(10);
|
// vTaskDelay(10);
|
||||||
// }
|
// }
|
||||||
@@ -297,7 +293,9 @@ void lora_comms_task(void *pvParameters)
|
|||||||
loraRadioMutex = xSemaphoreCreateMutex();
|
loraRadioMutex = xSemaphoreCreateMutex();
|
||||||
xSemaphoreGive(loraRadioMutex); // Set semaphore as available
|
xSemaphoreGive(loraRadioMutex); // Set semaphore as available
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "lora_comms_task started");
|
||||||
setup_lora();
|
setup_lora();
|
||||||
|
ESP_LOGI(TAG, "lora_comms_task continuing");
|
||||||
xTaskCreate(
|
xTaskCreate(
|
||||||
lora_receive_task,
|
lora_receive_task,
|
||||||
"LoraReceiveTask",
|
"LoraReceiveTask",
|
||||||
@@ -305,10 +303,12 @@ void lora_comms_task(void *pvParameters)
|
|||||||
NULL,
|
NULL,
|
||||||
(tskIDLE_PRIORITY + 2),
|
(tskIDLE_PRIORITY + 2),
|
||||||
NULL);
|
NULL);
|
||||||
|
ESP_LOGI(TAG, "loraInit");
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int64_t start_time = esp_timer_get_time();
|
int64_t start_time = esp_timer_get_time();
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "fdfgtfet");
|
||||||
if (packetReadiness)
|
if (packetReadiness)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Preparing telemetry");
|
ESP_LOGI(TAG, "Preparing telemetry");
|
||||||
|
Reference in New Issue
Block a user