Skip to content

Commit

Permalink
cleanup examples
Browse files Browse the repository at this point in the history
+ better logging
  • Loading branch information
dernasherbrezon committed Jul 24, 2024
1 parent 88995ff commit 871e822
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions examples/receive_fsk/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ void setup_gpio_interrupts(gpio_num_t gpio, sx127x *device) {

void app_main() {
ESP_LOGI(TAG, "starting up");
ESP_ERROR_CHECK(gpio_set_direction((gpio_num_t) RST, GPIO_MODE_INPUT_OUTPUT));
ESP_ERROR_CHECK(gpio_set_level((gpio_num_t) RST, 0));
vTaskDelay(pdMS_TO_TICKS(5));
ESP_ERROR_CHECK(gpio_set_level((gpio_num_t) RST, 1));
vTaskDelay(pdMS_TO_TICKS(10));
ESP_LOGI(TAG, "sx127x was reset");
ESP_ERROR_CHECK(gpio_reset_pin((gpio_num_t) RST));

spi_bus_config_t config = {
.mosi_io_num = MOSI,
.miso_io_num = MISO,
Expand Down
10 changes: 9 additions & 1 deletion examples/receive_fsk_beacon/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void handle_interrupt_task(void *arg) {
}

void rx_callback(sx127x *device, uint8_t *data, uint16_t data_length) {
uint8_t payload[2090 * 2];
uint8_t payload[514];
const char SYMBOLS[] = "0123456789ABCDEF";
for (size_t i = 0; i < data_length; i++) {
uint8_t cur = data[i];
Expand All @@ -64,6 +64,14 @@ void setup_gpio_interrupts(gpio_num_t gpio, sx127x *device) {

void app_main() {
ESP_LOGI(TAG, "starting up");
ESP_ERROR_CHECK(gpio_set_direction((gpio_num_t) RST, GPIO_MODE_INPUT_OUTPUT));
ESP_ERROR_CHECK(gpio_set_level((gpio_num_t) RST, 0));
vTaskDelay(pdMS_TO_TICKS(5));
ESP_ERROR_CHECK(gpio_set_level((gpio_num_t) RST, 1));
vTaskDelay(pdMS_TO_TICKS(10));
ESP_LOGI(TAG, "sx127x was reset");
ESP_ERROR_CHECK(gpio_reset_pin((gpio_num_t) RST));

spi_bus_config_t config = {
.mosi_io_num = MOSI,
.miso_io_num = MISO,
Expand Down
2 changes: 2 additions & 0 deletions examples/transmit_fsk_beacon/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ void app_main() {

uint8_t payload[] = {0xCA, 0xFE, 0x01, 0x02, 0xBE, 0xEF};
ESP_ERROR_CHECK(sx127x_fsk_ook_set_packet_format(SX127X_FIXED, sizeof(payload), device));
ESP_LOGI(TAG, "sending beacons...");
ESP_ERROR_CHECK(sx127x_fsk_ook_tx_start_beacon(payload, sizeof(payload), 1000, device));
vTaskDelay(10000 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK(sx127x_fsk_ook_tx_stop_beacon(device));
ESP_LOGI(TAG, "stopped");
}

0 comments on commit 871e822

Please sign in to comment.