|
|
|
@ -111,8 +111,8 @@ void loraOnReceive(int packetSize) {
@@ -111,8 +111,8 @@ void loraOnReceive(int packetSize) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void loraTask(void *params) { |
|
|
|
|
char outBuf[20]; |
|
|
|
|
const size_t outBufLen = (sizeof(outBuf) / sizeof(uint8_t)); |
|
|
|
|
char tx_buf[20]; |
|
|
|
|
const size_t tx_buf_len = (sizeof(tx_buf) / sizeof(tx_buf[0])); |
|
|
|
|
int packet_len; |
|
|
|
|
TickType_t send_period = pdMS_TO_TICKS(2000); |
|
|
|
|
TickType_t current_time = xTaskGetTickCount(); |
|
|
|
@ -134,17 +134,17 @@ void loraTask(void *params) {
@@ -134,17 +134,17 @@ void loraTask(void *params) {
|
|
|
|
|
} |
|
|
|
|
current_time = xTaskGetTickCount(); |
|
|
|
|
if (current_time >= next_send) { |
|
|
|
|
int len = sprintf(outBuf, "hello world %d", packet_num); |
|
|
|
|
if (len < 0) { |
|
|
|
|
ESP_LOGE(TAG, "sprintf error: %d", len); |
|
|
|
|
int written_bytes = snprintf(tx_buf, tx_buf_len, "hello world %d", packet_num); |
|
|
|
|
if (written_bytes < 0) { |
|
|
|
|
ESP_LOGE(TAG, "snprintf error: %d", written_bytes); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
packet_num++; |
|
|
|
|
esp_err_t ret = sx127x_send_packet(lora, outBuf, len); |
|
|
|
|
esp_err_t ret = sx127x_send_packet(lora, tx_buf, written_bytes, 0); // 0 means error if queue full
|
|
|
|
|
if (ret != ESP_OK) { |
|
|
|
|
ESP_LOGE(TAG, "error sending packet: %d", ret); |
|
|
|
|
} else { |
|
|
|
|
ESP_LOGI(TAG, "lora wrote %d bytes\n", len); |
|
|
|
|
ESP_LOGI(TAG, "lora wrote %d bytes\n", written_bytes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
current_time = xTaskGetTickCount(); |
|
|
|
@ -156,7 +156,7 @@ void loraTask(void *params) {
@@ -156,7 +156,7 @@ void loraTask(void *params) {
|
|
|
|
|
void loop(void) { |
|
|
|
|
ESP_LOGI(TAG, "loop"); |
|
|
|
|
u8g2_FirstPage(&u8g2); |
|
|
|
|
bool recieved_packet = xQueueReceive(lora_packet_recv_queue, &packet, 10); |
|
|
|
|
xQueueReceive(lora_packet_recv_queue, &packet, 10); |
|
|
|
|
do { |
|
|
|
|
u8g2_DrawRFrame(&u8g2, 0, 0, OLED_W, OLED_H, 4); |
|
|
|
|
|
|
|
|
|