From 354b0a5a2d4b19e6b8b6dff84a19f8b9aff606e6 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 15 Jan 2024 11:20:47 +0100 Subject: [PATCH 1/4] projects/03app_dotbot_gateway: add long range gateway application --- doc/sphinx/applications.md | 1 + .../03app_dotbot_gateway.c | 6 ++- projects/03app_dotbot_gateway/conf.h | 3 ++ projects/03app_dotbot_gateway_lr/README.md | 15 ++++++ projects/03app_dotbot_gateway_lr/conf.h | 3 ++ projects/projects-gateway.emProject | 47 +++++++++++++++++-- 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 projects/03app_dotbot_gateway/conf.h create mode 100644 projects/03app_dotbot_gateway_lr/README.md create mode 100644 projects/03app_dotbot_gateway_lr/conf.h diff --git a/doc/sphinx/applications.md b/doc/sphinx/applications.md index 8ca8530dd..2d3f1eda9 100644 --- a/doc/sphinx/applications.md +++ b/doc/sphinx/applications.md @@ -10,6 +10,7 @@ Main applications _projects/03app_dotbot _projects/03app_dotbot_gateway +_projects/03app_dotbot_gateway_lr _projects/03app_sailbot _projects/03app_log_dump _projects/03app_nrf5340_app diff --git a/projects/03app_dotbot_gateway/03app_dotbot_gateway.c b/projects/03app_dotbot_gateway/03app_dotbot_gateway.c index 3bdfe113a..595a9dc1e 100644 --- a/projects/03app_dotbot_gateway/03app_dotbot_gateway.c +++ b/projects/03app_dotbot_gateway/03app_dotbot_gateway.c @@ -27,6 +27,8 @@ #include "timer.h" #include "uart.h" +#include "conf.h" + //=========================== defines ========================================== #define DB_BUFFER_MAX_BYTES (255U) ///< Max bytes in UART receive buffer @@ -154,8 +156,8 @@ int main(void) { db_protocol_init(); // Configure Radio as transmitter - db_radio_init(&_radio_callback, DB_RADIO_BLE_1MBit); // All RX packets received are forwarded in an HDLC frame over UART - db_radio_set_frequency(8); // Set the radio frequency to 2408 MHz. + db_radio_init(&_radio_callback, DOTBOT_GW_RADIO_MODE); // All RX packets received are forwarded in an HDLC frame over UART + db_radio_set_frequency(8); // Set the radio frequency to 2408 MHz. // Initialize the gateway context _gw_vars.buttons = 0x0000; _gw_vars.radio_queue.current = 0; diff --git a/projects/03app_dotbot_gateway/conf.h b/projects/03app_dotbot_gateway/conf.h new file mode 100644 index 000000000..03f2078fe --- /dev/null +++ b/projects/03app_dotbot_gateway/conf.h @@ -0,0 +1,3 @@ +#include + +#define DOTBOT_GW_RADIO_MODE DB_RADIO_BLE_1MBit diff --git a/projects/03app_dotbot_gateway_lr/README.md b/projects/03app_dotbot_gateway_lr/README.md new file mode 100644 index 000000000..2c79e3c48 --- /dev/null +++ b/projects/03app_dotbot_gateway_lr/README.md @@ -0,0 +1,15 @@ +# DotBot gateway application - long range + +This application can be used as a gateway for communication between a computer +and a SailBot. + +Plug an nRF52840-DK on your computer and flash this application on it. + +You can then use [dotbot-controller tool](https://github.com/DotBots/PyDotBot) +to communicate with the firmware from your computer. + +`dotbot-controller` is available on PyPI: + +``` +$ pip install dotbot-controller +``` diff --git a/projects/03app_dotbot_gateway_lr/conf.h b/projects/03app_dotbot_gateway_lr/conf.h new file mode 100644 index 000000000..549f604cb --- /dev/null +++ b/projects/03app_dotbot_gateway_lr/conf.h @@ -0,0 +1,3 @@ +#include + +#define DOTBOT_GW_RADIO_MODE DB_RADIO_BLE_LR125Kbit diff --git a/projects/projects-gateway.emProject b/projects/projects-gateway.emProject index ce8fd51a5..285404785 100644 --- a/projects/projects-gateway.emProject +++ b/projects/projects-gateway.emProject @@ -7,8 +7,8 @@ project_directory="03app_dotbot_gateway" project_type="Executable" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + From da5b0a1fcfe2e4da2ed3af4b7389dbd0f0995a03 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 15 Jan 2024 11:23:49 +0100 Subject: [PATCH 2/4] projects/03app_sailbot: use radio in long range mode --- projects/03app_sailbot/03app_sailbot.c | 6 +++--- projects/03app_sailbot/README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/03app_sailbot/03app_sailbot.c b/projects/03app_sailbot/03app_sailbot.c index 368bd8d3f..0ebf7226e 100644 --- a/projects/03app_sailbot/03app_sailbot.c +++ b/projects/03app_sailbot/03app_sailbot.c @@ -121,9 +121,9 @@ int main(void) { db_protocol_init(); // Configure Radio as a receiver - db_radio_init(&radio_callback, DB_RADIO_BLE_1MBit); // Set the callback function. - db_radio_set_frequency(8); // Set the RX frequency to 2408 MHz. - db_radio_rx(); // Start receiving packets. + db_radio_init(&radio_callback, DB_RADIO_BLE_LR125Kbit); // Set the callback function. + db_radio_set_frequency(8); // Set the RX frequency to 2408 MHz. + db_radio_rx(); // Start receiving packets. // Init the IMU chips imu_init(NULL, NULL); diff --git a/projects/03app_sailbot/README.md b/projects/03app_sailbot/README.md index 2d5150054..b56e04eac 100644 --- a/projects/03app_sailbot/README.md +++ b/projects/03app_sailbot/README.md @@ -11,5 +11,5 @@ This app contains the main firmware of the SailBot platform based on Kyosho's Fo ## Instructions 1. Load this app on the SailBot board. -1. Program an nRF52840-DK with [gateway firmware](https://github.com/DotBots/DotBot-firmware/tree/main/projects/03app_dotbot_gateway). +1. Program an nRF52840-DK with [logn range gateway firmware](https://github.com/DotBots/DotBot-firmware/tree/main/projects/03app_dotbot_gateway). 1. Start [DotBot controller](https://github.com/DotBots/PyDotBot)on your computer. From da6cfdbea4f49dc5dac0ad982e96086c457a9c27 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 15 Jan 2024 11:26:04 +0100 Subject: [PATCH 3/4] Makefile: adapt list of supported application and artifacts --- Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 29706c924..617997529 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ ifeq (nrf5340dk-app,$(BUILD_TARGET)) 01drv_pid \ 03app_dotbot \ 03app_dotbot_gateway \ + 03app_dotbot_gateway_lr \ 03app_log_dump \ 03app_nrf5340_app \ 03app_sailbot \ @@ -51,6 +52,7 @@ else ifeq (nrf5340dk-net,$(BUILD_TARGET)) 01drv_lis2mdl \ 01drv_pid \ 03app_dotbot_gateway \ + 03app_dotbot_gateway_lr \ 03app_log_dump \ 03app_nrf5340_net \ # @@ -62,20 +64,20 @@ TESTBED_APPS ?= $(shell find testbed/ -maxdepth 1 -mindepth 1 -type d | tr -d "/ # remove incompatible apps (nrf5340, sailbot gateway) for dotbot (v1, v2) builds ifneq (,$(filter dotbot-v1,$(BUILD_TARGET))) - PROJECTS := $(filter-out 01bsp_qdec 01crypto_% 01drv_lis3mdl 01drv_move 03app_dotbot_gateway 03app_sailbot 03app_nrf5340_%,$(PROJECTS)) + PROJECTS := $(filter-out 01bsp_qdec 01crypto_% 01drv_lis3mdl 01drv_move 03app_dotbot_gateway 03app_dotbot_gateway_lr 03app_sailbot 03app_nrf5340_%,$(PROJECTS)) ARTIFACT_PROJECTS := 03app_dotbot TESTBED_APPS := $(filter-out bootloader partition0 partition1,$(TESTBED_APPS)) endif ifneq (,$(filter dotbot-v2,$(BUILD_TARGET))) - PROJECTS := $(filter-out 01crypto_% 03app_dotbot_gateway 03app_sailbot 03app_nrf5340_net,$(PROJECTS)) + PROJECTS := $(filter-out 01crypto_% 03app_dotbot_gateway 03app_dotbot_gateway_lr 03app_sailbot 03app_nrf5340_net,$(PROJECTS)) ARTIFACT_PROJECTS := 03app_dotbot TESTBED_APPS := $(filter-out bootloader partition0 partition1,$(TESTBED_APPS)) endif # remove incompatible apps (nrf5340, dotbot, gateway) for sailbot-v1 build ifeq (sailbot-v1,$(BUILD_TARGET)) - PROJECTS := $(filter-out 01bsp_qdec 01crypto_% 01drv_lis3mdl 01drv_move 03app_dotbot_gateway 03app_dotbot 03app_nrf5340_%,$(PROJECTS)) + PROJECTS := $(filter-out 01bsp_qdec 01crypto_% 01drv_lis3mdl 01drv_move 03app_dotbot_gateway 03app_dotbot_gateway_lr 03app_dotbot 03app_nrf5340_%,$(PROJECTS)) ARTIFACT_PROJECTS := 03app_sailbot TESTBED_APPS := $(filter-out bootloader partition0 partition1,$(TESTBED_APPS)) endif @@ -87,11 +89,11 @@ endif # remove incompatible apps (nrf5340) for nrf52833dk/nrf52840dk build ifneq (,$(filter nrf52833dk nrf52840dk,$(BUILD_TARGET))) PROJECTS := $(filter-out 01bsp_qdec 01drv_move 03app_nrf5340_%,$(PROJECTS)) - ARTIFACT_PROJECTS := 03app_dotbot_gateway + ARTIFACT_PROJECTS := 03app_dotbot_gateway 03app_dotbot_gateway_lr endif ifneq (,$(filter nrf5340dk-app,$(BUILD_TARGET))) - ARTIFACT_PROJECTS := 03app_dotbot_gateway + ARTIFACT_PROJECTS := 03app_dotbot_gateway 03app_dotbot_gateway_lr endif ifneq (,$(filter nrf5340dk-net,$(BUILD_TARGET))) From 857773b98dbb4785aee15d243f2d8c76e5706e43 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 16 Jan 2024 10:24:37 +0100 Subject: [PATCH 4/4] projects/01bsp_radio_txrx*: deduplicate long range sample application --- Makefile | 4 +- doc/sphinx/examples.md | 2 +- .../01bsp_radio_lr_txrx/01bsp_radio_lr_txrx.c | 86 ------------------- projects/01bsp_radio_txrx/01bsp_radio_txrx.c | 9 +- projects/01bsp_radio_txrx/conf.h | 3 + .../README.md | 0 projects/01bsp_radio_txrx_lr/conf.h | 3 + projects/projects-bsp-drv.emProject | 8 +- 8 files changed, 19 insertions(+), 96 deletions(-) delete mode 100644 projects/01bsp_radio_lr_txrx/01bsp_radio_lr_txrx.c create mode 100644 projects/01bsp_radio_txrx/conf.h rename projects/{01bsp_radio_lr_txrx => 01bsp_radio_txrx_lr}/README.md (100%) create mode 100644 projects/01bsp_radio_txrx_lr/conf.h diff --git a/Makefile b/Makefile index 617997529..458c980b5 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ ifeq (nrf5340dk-app,$(BUILD_TARGET)) 01bsp_nvmc \ 01bsp_qdec \ 01bsp_radio_txrx \ - 01bsp_radio_lr_txrx \ + 01bsp_radio_txrx_lr \ 01bsp_rgbled \ 01bsp_rng \ 01bsp_rpm \ @@ -42,7 +42,7 @@ else ifeq (nrf5340dk-net,$(BUILD_TARGET)) 01bsp_motors \ 01bsp_nvmc \ 01bsp_radio_txrx \ - 01bsp_radio_lr_txrx \ + 01bsp_radio_txrx_lr \ 01bsp_rgbled \ 01bsp_rng \ 01bsp_rpm \ diff --git a/doc/sphinx/examples.md b/doc/sphinx/examples.md index 4dddf2a4d..fdfdab710 100644 --- a/doc/sphinx/examples.md +++ b/doc/sphinx/examples.md @@ -21,7 +21,7 @@ _examples/01bsp_lighthouse _examples/01bsp_motors _examples/01bsp_nvmc _examples/01bsp_qdec -_examples/01bsp_radio_lr_txrx +_examples/01bsp_radio_txrx_lr _examples/01bsp_radio_txrx _examples/01bsp_rgbled _examples/01bsp_rng diff --git a/projects/01bsp_radio_lr_txrx/01bsp_radio_lr_txrx.c b/projects/01bsp_radio_lr_txrx/01bsp_radio_lr_txrx.c deleted file mode 100644 index d0517cf89..000000000 --- a/projects/01bsp_radio_lr_txrx/01bsp_radio_lr_txrx.c +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file - * @ingroup samples_bsp - * @author Trifun savic - * @brief This is a short example of how to interface with the Long Range BLE radio. - * - * - * - * @copyright Inria, 2022 - * - */ -#include -#include -#include -#include - -// Include BSP packages -#include "board.h" -#include "board_config.h" -#include "gpio.h" -#include "radio.h" -#include "timer_hf.h" - -//=========================== defines ========================================= - -#define DELAY_MS (100) // Wait 100ms between each send -#define RADIO_FREQ (8) // Set the frequency to 2408 MHz -#define RADIO_MODE (DB_RADIO_BLE_LR125Kbit) // Use BLE Long Range 125Kbit/s - -//=========================== variables ========================================= - -static const uint8_t packet_tx[] = { - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x41, // ABCDEFGH - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x00 // ABCDEFG -}; - -static const gpio_t _dbg_pin = { .port = DB_DEBUG1_PORT, .pin = DB_DEBUG1_PIN }; - -//=========================== prototypes ========================================= - -static void radio_callback(uint8_t *packet, uint8_t length) { - db_gpio_toggle(&_dbg_pin); - printf("packet received (%dB): %s, RSSI: %i\n", length, (char *)packet, db_radio_rssi()); -} - -//=========================== main =============================================== - -/** - * @brief The program starts executing here. - */ -int main(void) { - - // Turn ON the DotBot board regulator - db_board_init(); - - //=========================== Initialize GPIO and timer ====================== - - db_gpio_init(&_dbg_pin, DB_GPIO_OUT); - db_timer_hf_init(); - - //=========================== Configure Radio ================================s - - db_radio_init(&radio_callback, RADIO_MODE); - db_radio_set_frequency(RADIO_FREQ); - db_radio_rx(); - - while (1) { - db_radio_disable(); - db_radio_tx((uint8_t *)packet_tx, sizeof(packet_tx) / sizeof(packet_tx[0])); - db_timer_hf_delay_ms(DELAY_MS); - } -} diff --git a/projects/01bsp_radio_txrx/01bsp_radio_txrx.c b/projects/01bsp_radio_txrx/01bsp_radio_txrx.c index d5dd657d6..6b76fec8e 100644 --- a/projects/01bsp_radio_txrx/01bsp_radio_txrx.c +++ b/projects/01bsp_radio_txrx/01bsp_radio_txrx.c @@ -17,11 +17,12 @@ #include "radio.h" #include "timer_hf.h" +#include "conf.h" + //=========================== defines =========================================== -#define DELAY_MS (100) // Wait 100ms between each send -#define RADIO_FREQ (8) // Set the frequency to 2408 MHz -#define RADIO_MODE (DB_RADIO_BLE_1MBit) // Use BLE 1Mbit/s +#define DELAY_MS (100) // Wait 100ms between each send +#define RADIO_FREQ (8) // Set the frequency to 2408 MHz //=========================== variables ========================================= @@ -70,7 +71,7 @@ int main(void) { //=========================== Configure Radio =============================== - db_radio_init(&radio_callback, RADIO_MODE); + db_radio_init(&radio_callback, DOTBOT_GW_RADIO_MODE); db_radio_set_frequency(RADIO_FREQ); db_radio_rx(); diff --git a/projects/01bsp_radio_txrx/conf.h b/projects/01bsp_radio_txrx/conf.h new file mode 100644 index 000000000..549f604cb --- /dev/null +++ b/projects/01bsp_radio_txrx/conf.h @@ -0,0 +1,3 @@ +#include + +#define DOTBOT_GW_RADIO_MODE DB_RADIO_BLE_LR125Kbit diff --git a/projects/01bsp_radio_lr_txrx/README.md b/projects/01bsp_radio_txrx_lr/README.md similarity index 100% rename from projects/01bsp_radio_lr_txrx/README.md rename to projects/01bsp_radio_txrx_lr/README.md diff --git a/projects/01bsp_radio_txrx_lr/conf.h b/projects/01bsp_radio_txrx_lr/conf.h new file mode 100644 index 000000000..03f2078fe --- /dev/null +++ b/projects/01bsp_radio_txrx_lr/conf.h @@ -0,0 +1,3 @@ +#include + +#define DOTBOT_GW_RADIO_MODE DB_RADIO_BLE_1MBit diff --git a/projects/projects-bsp-drv.emProject b/projects/projects-bsp-drv.emProject index ee1b16c3c..a53ef8641 100644 --- a/projects/projects-bsp-drv.emProject +++ b/projects/projects-bsp-drv.emProject @@ -234,11 +234,11 @@ - + @@ -263,7 +263,8 @@ - + + @@ -303,6 +304,7 @@ +