diff --git a/README.md b/README.md index 04861a2..28695f8 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,25 @@ -# LR1110 evaluation kit + +# LR1110 evaluation kit - demonstration application ## Introduction -This repository provides everything you need to use a LR1110 evaluation kit. +This repository proposes a demonstration application running on a **LR1110 evaluation kit**. + +Additional assets can be found in [the Wiki](https://github.com/Lora-net/lr1110_evk_demo_app/wiki/home) (software packages, command tool, etc.). ## Applicative Host -This project needs an applicative companion software to be running on a computer. +When using a **LR1110 transceiver**, an applicative companion software running on a computer shall be used. + This section describes the steps to build/install/use it. ### Build & Install -To build the host softwares, proceed as follow: +To build the host software, proceed as follow: ```bash $ cd $TOP_DIR/host -$ python ./setup.py sdist # Build the source distribution archive +$ python ./setup.py sdist # Build the source distribution archive $ python -m pip install dist/.tar.gz # Install the previously built source distribution ``` @@ -33,10 +37,25 @@ In case of need, a short help page is available: $ Lr1110Demo --help ``` -## Wiki +### AlmanacUpdate Usage + +The `AlmanacUpdate` command line program is to be used to execute a full almanac update operation of the LR1110 (both transceiver and modem). + +It can use almanac coming either from a DAS server or from a GLS server (default is DAS server). + +To use it, execute the following in a command line: + +```bash +$ AlmanacUpdate -h +# Display the help message with all possible flags + +$ AlmanacUpdate -d +# Update the almanac of an evaluation kit connected on using DAS server + +$ AlmancUpdate -g -d +# Update the almanac of an evaluation kit connected on using GLS server +``` -The Wiki will give you all the information about this evaluation kit: +A correct execution of the almanac update operation is determined by the trace being terminated with message *Check terminated*. - - [Software packages](https://github.com/Lora-net/lr1110_evk/wiki/Software-packages) - - [Demonstration examples](https://github.com/Lora-net/lr1110_evk/wiki/Demonstration-examples) - - [Updater tool](https://github.com/Lora-net/lr1110_evk/wiki/Updater-tool) +*Note: this command can also be used to update the almanacs of a **LoRa Basics Modem-E**.* diff --git a/embedded/Makefile b/embedded/Makefile index aba5407..ed63e06 100644 --- a/embedded/Makefile +++ b/embedded/Makefile @@ -49,6 +49,7 @@ BUILD_DIR = build # C sources C_SOURCES = \ application/src/lr1110_hal.c \ +application/src/lr1110_modem_hal.c \ STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_spi.c \ STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_tim.c \ STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_lptim.c \ @@ -82,7 +83,12 @@ lr1110_driver/src/lr1110_radio.c \ lr1110_driver/src/lr1110_regmem.c \ lr1110_driver/src/lr1110_system.c \ lr1110_driver/src/lr1110_wifi.c \ -gcc/syscalls.c \ +lr1110_modem_driver/src/lr1110_modem_driver_version.c \ +lr1110_modem_driver/src/lr1110_modem_gnss.c \ +lr1110_modem_driver/src/lr1110_modem_lorawan.c \ +lr1110_modem_driver/src/lr1110_modem_system.c \ +lr1110_modem_driver/src/lr1110_modem_wifi.c \ +gcc/redirect.c \ gcc/usart_redirect.c # Integration of the LVGL library @@ -101,27 +107,44 @@ communication/src/communication_interface.cpp \ communication/src/communication_print_only.cpp \ communication/src/communication_demo.cpp \ communication/src/communication_field_test.cpp \ +connectivity/src/connectivity_manager_interface.cpp \ +connectivity/src/connectivity_manager_modem.cpp \ +connectivity/src/connectivity_manager_transceiver.cpp \ demo/src/environment_interface.cpp \ -demo/src/demo_base.cpp \ -demo/src/demo_transceiver_base.cpp \ -demo/src/demo_wifi_interface.cpp \ -demo/src/demo_wifi_scan.cpp \ -demo/src/demo_wifi_country_code.cpp \ -demo/src/demo_wifi_types.cpp \ -demo/src/demo_gnss_autonomous.cpp \ -demo/src/demo_gnss_base.cpp \ -demo/src/demo_gnss_assisted.cpp \ -demo/src/demo_radio_interface.cpp \ -demo/src/demo_ping_pong.cpp \ -demo/src/demo_tx_cw.cpp \ -demo/src/demo_radio_per.cpp \ -demo/src/demo.cpp\ -demo/src/device_base.cpp \ -demo/src/device_transceiver.cpp \ +demo/src/demo_modem_interface.cpp \ +demo/src/demo_modem_wifi.cpp \ +demo/src/demo_modem_gnss_interface.cpp \ +demo/src/demo_modem_gnss_autonomous.cpp \ +demo/src/demo_modem_gnss_assisted.cpp \ +demo/src/demo_modem_radio_tx_continuous.cpp \ +demo/src/demo_modem_radio_tx_cw.cpp \ +demo/src/demo_modem_radio_rx_continuous.cpp \ +embedded/demo/src/demo_modem_radio_converters.cpp \ +demo/src/demo_interface.cpp \ +demo/src/demo_transceiver_interface.cpp \ +demo/src/demo_transceiver_wifi_interface.cpp \ +demo/src/demo_transceiver_wifi_scan.cpp \ +demo/src/demo_transceiver_wifi_country_code.cpp \ +demo/src/demo_transceiver_gnss_autonomous.cpp \ +demo/src/demo_transceiver_gnss_interface.cpp \ +demo/src/demo_transceiver_gnss_assisted.cpp \ +demo/src/demo_transceiver_radio_interface.cpp \ +demo/src/demo_transceiver_radio_ping_pong.cpp \ +demo/src/demo_transceiver_radio_tx_cw.cpp \ +demo/src/demo_transceiver_radio_per.cpp \ +demo/src/demo_manager_interface.cpp \ +demo/src/demo_manager_transceiver.cpp \ +demo/src/demo_manager_modem.cpp \ +device/src/device_interface.cpp \ +device/src/device_transceiver.cpp \ +device/src/device_modem.cpp \ +demo/src/interruption_irq.cpp \ +demo/src/interruption_modem.cpp \ gui/src/gui.cpp \ gui/src/guiCommon.cpp \ gui/src/guiMenuCommon.cpp \ gui/src/guiMenu.cpp \ +gui/src/guiConnectivity.cpp \ gui/src/guiMenuRadioTestModes.cpp \ gui/src/guiConfigRadioTestModes.cpp \ gui/src/guiRadioTxCw.cpp \ @@ -136,7 +159,10 @@ gui/src/guiTestGnss.cpp \ gui/src/guiTestWifi.cpp \ gui/src/guiConfigWifi.cpp \ gui/src/guiConfigGnss.cpp \ +gui/src/guiConfigGnssAssistancePosition.cpp \ +gui/src/guiEui.cpp \ supervisor/src/supervisor.cpp \ +connectivity/src/connectivity_conversions.cpp \ hci/hci.cpp \ hci/Command/Src/command_base.cpp \ hci/Command/Src/command_factory.cpp \ @@ -215,9 +241,11 @@ AS_INCLUDES = C_INCLUDES = \ -Iapplication/inc \ -Icommunication/inc \ +-Iconnectivity/inc \ -ICMSIS/Device/ST/STM32L4xx/Include \ -ICMSIS/Core/Include \ -Idemo/inc \ +-Idevice/inc \ -Idisplay_touch/inc \ -Igui/inc\ -Ilvgl \ @@ -233,6 +261,7 @@ C_INCLUDES = \ -Isupervisor/inc \ -Isystem/inc \ -Ilr1110_driver/src \ +-Ilr1110_modem_driver/src \ -Ihci \ -Ihci/Command/Inc diff --git a/embedded/STM32L4xx_HAL_Driver/STM32L422xx_User_Manual.chm b/embedded/STM32L4xx_HAL_Driver/STM32L422xx_User_Manual.chm new file mode 100644 index 0000000..04289c5 Binary files /dev/null and b/embedded/STM32L4xx_HAL_Driver/STM32L422xx_User_Manual.chm differ diff --git a/embedded/STM32L4xx_HAL_Driver/STM32L443xx_User_Manual.chm b/embedded/STM32L4xx_HAL_Driver/STM32L443xx_User_Manual.chm new file mode 100644 index 0000000..1732771 Binary files /dev/null and b/embedded/STM32L4xx_HAL_Driver/STM32L443xx_User_Manual.chm differ diff --git a/embedded/STM32L4xx_HAL_Driver/STM32L462xx_User_Manual.chm b/embedded/STM32L4xx_HAL_Driver/STM32L462xx_User_Manual.chm new file mode 100644 index 0000000..026039c Binary files /dev/null and b/embedded/STM32L4xx_HAL_Driver/STM32L462xx_User_Manual.chm differ diff --git a/embedded/STM32L4xx_HAL_Driver/STM32L486xx_User_Manual.chm b/embedded/STM32L4xx_HAL_Driver/STM32L486xx_User_Manual.chm new file mode 100644 index 0000000..eebbe23 Binary files /dev/null and b/embedded/STM32L4xx_HAL_Driver/STM32L486xx_User_Manual.chm differ diff --git a/embedded/STM32L4xx_HAL_Driver/STM32L4A6xx_User_Manual.chm b/embedded/STM32L4xx_HAL_Driver/STM32L4A6xx_User_Manual.chm new file mode 100644 index 0000000..1a3b10e Binary files /dev/null and b/embedded/STM32L4xx_HAL_Driver/STM32L4A6xx_User_Manual.chm differ diff --git a/embedded/STM32L4xx_HAL_Driver/STM32L4Q5xx_User_Manual.chm b/embedded/STM32L4xx_HAL_Driver/STM32L4Q5xx_User_Manual.chm new file mode 100644 index 0000000..01725d8 Binary files /dev/null and b/embedded/STM32L4xx_HAL_Driver/STM32L4Q5xx_User_Manual.chm differ diff --git a/embedded/STM32L4xx_HAL_Driver/STM32L4S9xx_User_Manual.chm b/embedded/STM32L4xx_HAL_Driver/STM32L4S9xx_User_Manual.chm new file mode 100644 index 0000000..bce2f92 Binary files /dev/null and b/embedded/STM32L4xx_HAL_Driver/STM32L4S9xx_User_Manual.chm differ diff --git a/embedded/application/inc/configuration.h b/embedded/application/inc/configuration.h index b81cc48..cc2a0f6 100644 --- a/embedded/application/inc/configuration.h +++ b/embedded/application/inc/configuration.h @@ -32,8 +32,6 @@ #ifndef _CONFIGURATION_H #define _CONFIGURATION_H -#include "lr1110_hal.h" - #include "stm32l4xx_ll_gpio.h" #include "stm32l4xx_ll_spi.h" diff --git a/embedded/application/inc/version.h b/embedded/application/inc/version.h index 6b89cef..b4c3bca 100644 --- a/embedded/application/inc/version.h +++ b/embedded/application/inc/version.h @@ -32,23 +32,44 @@ #ifndef __VERSION_H__ #define __VERSION_H__ -#include "lr1110_system_types.h" +#define DEMO_VERSION "v2.0.0" -#ifndef DEMO_VERSION -#warning "No demo version provided" -#define DEMO_VERSION "v1.4.0" -#endif +#define VERSION_STRING_LENGTH 10 +#define EUI_LENGTH 8 +#define PIN_LENGTH 4 + +typedef enum +{ + VERSION_DEVICE_TRANSCEIVER, + VERSION_DEVICE_MODEM, +} version_device_type_t; typedef struct { - char version_sw[10]; - char version_driver[10]; - uint8_t version_chip_type; - uint8_t version_chip_hw; - uint16_t version_chip_fw; - lr1110_system_uid_t chip_uid; - uint16_t almanac_date; - uint32_t almanac_crc; + version_device_type_t device_type; + char version_sw[VERSION_STRING_LENGTH]; + char version_driver[VERSION_STRING_LENGTH]; + uint8_t chip_uid[EUI_LENGTH]; + uint8_t dev_eui[EUI_LENGTH]; + uint8_t join_eui[EUI_LENGTH]; + uint8_t pin[PIN_LENGTH]; + uint16_t almanac_date; + uint32_t almanac_crc; + union + { + struct + { + uint8_t version_chip_type; + uint8_t version_chip_hw; + uint16_t version_chip_fw; + } transceiver; + struct + { + uint8_t version_chip_type; + uint32_t version_chip_bootloader; + uint32_t version_chip_fw; + } modem; + }; } version_handler_t; #endif diff --git a/embedded/application/src/lr1110_modem_hal.c b/embedded/application/src/lr1110_modem_hal.c new file mode 100644 index 0000000..b99e45a --- /dev/null +++ b/embedded/application/src/lr1110_modem_hal.c @@ -0,0 +1,271 @@ +/** + * @file lr1110_modem_hal.c + * + * @brief HAL implementation for LR1110 modem radio chip + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "lr1110_modem_hal.h" +#include "configuration.h" +#include "system.h" + +static lr1110_modem_hal_status_t lr1110_modem_hal_wait_on_busy( const void* radio, uint32_t timeout_ms ); +static lr1110_modem_hal_status_t lr1110_modem_hal_wait_on_unbusy( const void* radio, uint32_t timeout_ms ); + +lr1110_modem_hal_status_t lr1110_modem_hal_reset( const void* radio ) +{ + radio_t* radio_local = ( radio_t* ) radio; + + system_gpio_set_pin_state( radio_local->reset, SYSTEM_GPIO_PIN_STATE_LOW ); + system_time_wait_ms( 1 ); + system_gpio_set_pin_state( radio_local->reset, SYSTEM_GPIO_PIN_STATE_HIGH ); + system_time_wait_ms( 100 ); + return LR1110_MODEM_HAL_STATUS_OK; +} + +lr1110_modem_hal_status_t lr1110_modem_hal_wakeup( const void* radio ) +{ + radio_t* radio_local = ( radio_t* ) radio; + + if( lr1110_modem_hal_wait_on_busy( radio_local, 1000 ) == LR1110_MODEM_HAL_STATUS_OK ) + { + // Wakeup radio + system_gpio_set_pin_state( radio_local->nss, 0 ); + system_gpio_set_pin_state( radio_local->nss, 1 ); + } + + // Wait on busy pin for 100 ms + return lr1110_modem_hal_wait_on_unbusy( radio_local, 1000 ); +} + +lr1110_modem_hal_status_t lr1110_modem_hal_read( const void* radio, const uint8_t* cbuffer, + const uint16_t cbuffer_length, uint8_t* rbuffer, + const uint16_t rbuffer_length ) +{ + radio_t* radio_local = ( radio_t* ) radio; + + if( lr1110_modem_hal_wakeup( radio_local ) == LR1110_MODEM_HAL_STATUS_OK ) + { + uint8_t crc = 0; + uint8_t crc_received = 0; + lr1110_modem_hal_status_t status; + + // NSS low + system_gpio_set_pin_state( radio_local->nss, 0 ); + + // Send CMD + system_spi_write( radio_local->spi, cbuffer, cbuffer_length ); + + // Compute and send CRC + crc = lr1110_modem_compute_crc( 0xFF, cbuffer, cbuffer_length ); + + system_spi_write( radio_local->spi, &crc, 1 ); + + // NSS high + system_gpio_set_pin_state( radio_local->nss, 1 ); + + // Wait on busy pin up to 1000 ms + if( lr1110_modem_hal_wait_on_busy( radio_local, 1000 ) != LR1110_MODEM_HAL_STATUS_OK ) + { + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; + } + + // Send dummy byte to retrieve RC & CRC + + // NSS low + system_gpio_set_pin_state( radio_local->nss, 0 ); + + // read RC + system_spi_read( radio_local->spi, &status, 1 ); + // status = ( lr1110_modem_hal_status_t ) system_spi_write_read( radio_local->spi, 0 ); + + system_spi_read( radio_local->spi, rbuffer, rbuffer_length ); + // for( uint16_t i = 0; i < data_length; i++ ) + // { + // data[i] = system_spi_write_read( radio_local->spi_id, 0 ); + // } + + system_spi_read( radio_local->spi, &crc_received, 1 ); + // crc_received = system_spi_write_read( radio_local->spi_id, 0 ); + + // NSS high + system_gpio_set_pin_state( radio_local->nss, 1 ); + + // Compute response crc + crc = lr1110_modem_compute_crc( 0xFF, ( uint8_t* ) &status, 1 ); + crc = lr1110_modem_compute_crc( crc, rbuffer, rbuffer_length ); + + if( crc != crc_received ) + { + // change the response code + status = LR1110_MODEM_HAL_STATUS_BAD_FRAME; + } + // Wait on busy pin up to 1000 ms + if( lr1110_modem_hal_wait_on_unbusy( radio_local, 1000 ) != LR1110_MODEM_HAL_STATUS_OK ) + { + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; + } + + // Wait on busy pin up to 1000 ms + if( lr1110_modem_hal_wait_on_busy( radio_local, 1000 ) != LR1110_MODEM_HAL_STATUS_OK ) + { + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; + } + else + { + return status; + } + } + + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; +} + +lr1110_modem_hal_status_t lr1110_modem_hal_write( const void* radio, const uint8_t* cbuffer, + const uint16_t cbuffer_length, const uint8_t* cdata, + const uint16_t cdata_length ) +{ + radio_t* radio_local = ( radio_t* ) radio; + + if( lr1110_modem_hal_wakeup( radio_local ) == LR1110_MODEM_HAL_STATUS_OK ) + { + uint8_t crc = 0; + uint8_t crc_received = 0; + lr1110_modem_hal_status_t status; + + // NSS low + system_gpio_set_pin_state( radio_local->nss, 0 ); + + // Send CMD + system_spi_write( radio_local->spi, cbuffer, cbuffer_length ); + + // Send Data + system_spi_write( radio_local->spi, cdata, cdata_length ); + + // Compute and send CRC + crc = lr1110_modem_compute_crc( 0xFF, cbuffer, cbuffer_length ); + crc = lr1110_modem_compute_crc( crc, cdata, cdata_length ); + + system_spi_write( radio_local->spi, &crc, 1 ); + + // NSS high + system_gpio_set_pin_state( radio_local->nss, 1 ); + + // Wait on busy pin up to 1000 ms + if( lr1110_modem_hal_wait_on_busy( radio_local, 1000 ) != LR1110_MODEM_HAL_STATUS_OK ) + { + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; + } + + // Send dummy byte to retrieve RC & CRC + + // NSS low + system_gpio_set_pin_state( radio_local->nss, 0 ); + + // read RC + system_spi_read( radio_local->spi, &status, 1 ); + system_spi_read( radio_local->spi, &crc_received, 1 ); + + // Compute response crc + crc = lr1110_modem_compute_crc( 0xFF, ( uint8_t* ) &status, 1 ); + + // NSS high + system_gpio_set_pin_state( radio_local->nss, 1 ); + + if( crc != crc_received ) + { + // change the response code + status = LR1110_MODEM_HAL_STATUS_BAD_FRAME; + } + + // Don't wait on busy in these following cases + // 0x0602 - LR1110_MODEM_GROUP_ID_MODEM / LR1110_MODEM_RESET_CMD + // 0x0603 - LR1110_MODEM_GROUP_ID_MODEM / LR1110_MODEM_FACTORY_RESET_CMD + + if( ( ( ( cbuffer[0] << 8 ) | cbuffer[1] ) != 0x0602 ) && ( ( ( cbuffer[0] << 8 ) | cbuffer[1] ) != 0x0603 ) ) + { + // Wait on busy pin up to 1000 ms + if( lr1110_modem_hal_wait_on_unbusy( radio_local, 1000 ) != LR1110_MODEM_HAL_STATUS_OK ) + { + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; + } + else + { + return status; + } + } + else + { + return status; + } + } + + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; +} + +lr1110_modem_hal_status_t lr1110_modem_hal_write_read( const void* radio, const uint8_t* cbuffer, uint8_t* rbuffer, + const uint16_t length ) +{ + radio_t* radio_local = ( radio_t* ) radio; + + system_gpio_wait_for_state( radio_local->busy, SYSTEM_GPIO_PIN_STATE_LOW ); + + system_gpio_set_pin_state( radio_local->nss, SYSTEM_GPIO_PIN_STATE_LOW ); + system_spi_write_read( radio_local->spi, cbuffer, rbuffer, length ); + system_gpio_set_pin_state( radio_local->nss, SYSTEM_GPIO_PIN_STATE_HIGH ); + + return LR1110_MODEM_HAL_STATUS_OK; +} + +lr1110_modem_hal_status_t lr1110_modem_hal_wait_on_busy( const void* radio, uint32_t timeout_ms ) +{ + radio_t* radio_local = ( radio_t* ) radio; + const uint32_t start_time = system_time_GetTicker( ); + while( system_gpio_get_pin_state( radio_local->busy ) == 0 ) + { + const uint32_t actual_time = system_time_GetTicker( ); + if( ( actual_time - start_time ) > timeout_ms ) + { + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; + } + } + return LR1110_MODEM_HAL_STATUS_OK; +} + +lr1110_modem_hal_status_t lr1110_modem_hal_wait_on_unbusy( const void* radio, uint32_t timeout_ms ) +{ + radio_t* radio_local = ( radio_t* ) radio; + const uint32_t start_time = system_time_GetTicker( ); + while( system_gpio_get_pin_state( radio_local->busy ) == 1 ) + { + const uint32_t actual_time = system_time_GetTicker( ); + if( ( actual_time - start_time ) > timeout_ms ) + { + return LR1110_MODEM_HAL_STATUS_BUSY_TIMEOUT; + } + } + return LR1110_MODEM_HAL_STATUS_OK; +} \ No newline at end of file diff --git a/embedded/application/src/main.cpp b/embedded/application/src/main.cpp index 2b74965..a70b5a7 100644 --- a/embedded/application/src/main.cpp +++ b/embedded/application/src/main.cpp @@ -31,8 +31,8 @@ #include "configuration.h" #include "device_transceiver.h" -#include "lr1110_system.h" -#include "lr1110_wifi.h" +#include "device_modem.h" +#include "lr1110_modem_lorawan.h" #include "system.h" #include "supervisor.h" @@ -42,9 +42,11 @@ #include "timer_interface_implementation.h" #include "gui.h" -#include "stdio.h" -#include "string.h" -#include "demo.h" +#include "demo_manager_transceiver.h" +#include "demo_manager_modem.h" + +#include "connectivity_manager_transceiver.h" +#include "connectivity_manager_modem.h" #include "hci.h" #include "command_factory.h" @@ -57,8 +59,6 @@ #include "command_update_almanac.h" #include "command_check_almanac_update.h" -#include "stm32_assert_template.h" - #include "lvgl.h" #include "lv_port_disp.h" #include "lv_port_indev.h" @@ -209,38 +209,75 @@ uint32_t Signaling::DURATION_RX_ON_MS = 100; int main( void ) { - bool automatic_mode = false; + DeviceInterface* device; + DemoManagerInterface* demo_manager; + ConnectivityManagerInterface* connectivity_manager; system_init( ); - system_time_wait_ms( 500 ); + system_time_wait_ms( 100 ); // Added to avoid screen flickering during power-up lv_init( ); lv_port_disp_init( ); lv_port_indev_init( ); - Environment environment; - AntennaSelector antenna_selector; - Signaling signaling( &environment ); - Gui gui; - Timer timer; - DeviceTransceiver device_transceiver( &radio ); + Environment environment; + AntennaSelector antenna_selector; + Signaling signaling( &environment ); + Gui gui; + Timer timer; + DeviceTransceiver device_transceiver( &radio ); + CommandFactory command_factory; + Hci hci( command_factory, environment ); + CommunicationManager communication_manager( &environment, &hci ); - CommandFactory command_factory; - Hci hci( command_factory, environment ); + environment_location_t default_location( + { DEMO_ASSISTANCE_LOCATION_LATITUDE, DEMO_ASSISTANCE_LOCATION_LONGITUDE, DEMO_ASSISTANCE_LOCATION_ALTITUDE } ); + environment.SetLocation( default_location ); - CommunicationManager communication_manager( &environment, &hci ); + system_gpio_set_pin_state( radio.reset, SYSTEM_GPIO_PIN_STATE_LOW ); + system_time_wait_ms( 1 ); + system_gpio_set_pin_state( radio.reset, SYSTEM_GPIO_PIN_STATE_HIGH ); + + system_time_wait_ms( 500 ); // Added to let the radio perform it startup sequence - Demo demo( &device_transceiver, &environment, &antenna_selector, &signaling, &timer, &communication_manager ); + if( system_gpio_get_pin_state( radio.busy ) == SYSTEM_GPIO_PIN_STATE_HIGH ) + { + lr1110_modem_event_fields_t modem_event; + + device = new DeviceModem( &radio ); + demo_manager = new DemoManagerModem( ( DeviceModem* ) device, &environment, &antenna_selector, &signaling, + &timer, &communication_manager ); + connectivity_manager = new ConnectivityManagerModem( ( DeviceModem* ) device ); + + while( system_gpio_get_pin_state( radio.irq ) == SYSTEM_GPIO_PIN_STATE_LOW ) + { + }; + + lr1110_modem_get_event( &radio, &modem_event ); + + if( modem_event.event_type != LR1110_MODEM_LORAWAN_EVENT_RESET ) + { + while( 1 ) + ; + } + } + else + { + device = new DeviceTransceiver( &radio ); + demo_manager = new DemoManagerTransceiver( ( DeviceTransceiver* ) device, &environment, &antenna_selector, + &signaling, &timer, &communication_manager ); + connectivity_manager = new ConnectivityManagerTransceiver( ); + } CommandGetVersion com_get_version( hci ); - CommandGetAlmanacDates com_get_almanac_dates( &device_transceiver, hci ); - CommandStartDemo com_start( &device_transceiver, hci, demo ); - CommandFetchResult com_fetch_result( hci, environment, demo ); - CommandSetDateLoc com_set_date_loc( &device_transceiver, hci, environment ); - CommandReset com_reset( &device_transceiver, hci ); - CommandUpdateAlmanac com_update_almanac( &device_transceiver, hci ); - CommandCheckAlmanacUpdate com_check_almanac_update( &device_transceiver, hci ); + CommandGetAlmanacDates com_get_almanac_dates( device, hci ); + CommandStartDemo com_start( device, hci, *demo_manager ); + CommandFetchResult com_fetch_result( hci, environment, *demo_manager ); + CommandSetDateLoc com_set_date_loc( device, hci, environment ); + CommandReset com_reset( device, hci ); + CommandUpdateAlmanac com_update_almanac( device, hci ); + CommandCheckAlmanacUpdate com_check_almanac_update( device, hci ); command_factory.AddCommandToPool( com_get_version ); command_factory.AddCommandToPool( com_get_almanac_dates ); @@ -251,7 +288,8 @@ int main( void ) command_factory.AddCommandToPool( com_update_almanac ); command_factory.AddCommandToPool( com_check_almanac_update ); - Supervisor supervisor( &gui, &device_transceiver, &demo, &environment, &communication_manager ); + Supervisor supervisor( &gui, device, demo_manager, &environment, &communication_manager, connectivity_manager ); + supervisor.Init( ); com_get_version.SetVersion( supervisor.GetVersionHandler( ) ); diff --git a/embedded/communication/inc/communication_demo.h b/embedded/communication/inc/communication_demo.h index b8333f8..37d9885 100644 --- a/embedded/communication/inc/communication_demo.h +++ b/embedded/communication/inc/communication_demo.h @@ -45,19 +45,19 @@ typedef enum class CommunicationDemo : public CommunicationInterface { public: - virtual void Runtime( ) override; - virtual bool GetDateAndApproximateLocation( uint32_t& gps_second, float& latitude, float& longitude, - float& altitude ) override; - virtual bool GetResults( float& latitude, float& longitude, float& altitude, float& accuracy, char* geo_coding, - const uint8_t geo_coding_max_length ); - virtual void Store( const demo_wifi_scan_all_results_t& wifi_results ); - virtual void Store( const demo_gnss_all_results_t& gnss_results, uint32_t delay_since_capture ); - virtual void Store( const version_handler_t& version ); - virtual void EraseDataStored( ) override; - virtual void SendDataStoredToServer( ) override; - virtual void vLog( const char* fmt, va_list argp ) override; - virtual bool HasNewCommand( ) const override; - virtual CommandInterface* FetchCommand( ) override; + void Runtime( ) override; + bool GetDateAndApproximateLocation( uint32_t& gps_second, float& latitude, float& longitude, + float& altitude ) override; + bool GetResults( float& latitude, float& longitude, float& altitude, float& accuracy, char* geo_coding, + const uint8_t geo_coding_max_length ) override; + void Store( const demo_wifi_scan_all_results_t& wifi_results ) override; + void Store( const demo_gnss_all_results_t& gnss_results, uint32_t delay_since_capture ) override; + void Store( const version_handler_t& version ) override; + void EraseDataStored( ) override; + void SendDataStoredToServer( ) override; + void vLog( const char* fmt, va_list argp ) override; + bool HasNewCommand( ) const override; + CommandInterface* FetchCommand( ) override; protected: CommunicationDemoStatus_t AskAndParseResults( float& latitude, float& longitude, float& altitude, float& accuracy, diff --git a/embedded/communication/inc/communication_print_only.h b/embedded/communication/inc/communication_print_only.h index 08e5a76..898a0d2 100644 --- a/embedded/communication/inc/communication_print_only.h +++ b/embedded/communication/inc/communication_print_only.h @@ -40,19 +40,20 @@ class CommunicationPrintOnly : public CommunicationInterface public: CommunicationPrintOnly( ); virtual ~CommunicationPrintOnly( ); - virtual void Runtime( ) override; - virtual bool GetDateAndApproximateLocation( uint32_t& gps_second, float& latitude, float& longitude, - float& altitude ) override; - virtual bool GetResults( float& latitude, float& longitude, float& altitude, float& accuracy, char* geo_coding, - const uint8_t geo_coding_max_length ) override; - virtual void vLog( const char* fmt, va_list argp ) override; - virtual void Store( const demo_wifi_scan_all_results_t& wifi_results ); - virtual void Store( const demo_gnss_all_results_t& gnss_results, uint32_t delay_since_capture ); - virtual void Store( const version_handler_t& version ); - virtual void EraseDataStored( ); - virtual void SendDataStoredToServer( ); - virtual bool HasNewCommand( ) const override; - virtual CommandInterface* FetchCommand( ) override; + + void Runtime( ) override; + bool GetDateAndApproximateLocation( uint32_t& gps_second, float& latitude, float& longitude, + float& altitude ) override; + bool GetResults( float& latitude, float& longitude, float& altitude, float& accuracy, char* geo_coding, + const uint8_t geo_coding_max_length ) override; + void vLog( const char* fmt, va_list argp ) override; + void Store( const demo_wifi_scan_all_results_t& wifi_results ) override; + void Store( const demo_gnss_all_results_t& gnss_results, uint32_t delay_since_capture ) override; + void Store( const version_handler_t& version ) override; + void EraseDataStored( ) override; + void SendDataStoredToServer( ) override; + bool HasNewCommand( ) const override; + CommandInterface* FetchCommand( ) override; }; #endif // __COMMUNICATION_PRINT_ONLY_H__ \ No newline at end of file diff --git a/embedded/communication/src/communication_demo.cpp b/embedded/communication/src/communication_demo.cpp index 91d452c..c6e4e0f 100644 --- a/embedded/communication/src/communication_demo.cpp +++ b/embedded/communication/src/communication_demo.cpp @@ -35,7 +35,7 @@ #include "system_time.h" #include "system_uart.h" -#define COMMUNICATION_DEMO_TIMEOUT_SERIAL_RECEIVE_MS ( 2500 ) +#define COMMUNICATION_DEMO_TIMEOUT_SERIAL_RECEIVE_MS ( 5000 ) #define COMMUNICATION_DEMO_GET_RESULT_BUFFER_LENGTH ( 128 ) #define COMMUNICATION_DEMO_TMP_FORMAT_LENGTH ( 32 ) #define COMMUNICATION_DEMO_COMMAND_TOKEN_DATE "DATE" @@ -87,18 +87,33 @@ void CommunicationDemo::Store( const demo_gnss_all_results_t& gnss_results, uint { printf( "%02x", gnss_results.nav_message.message[index] ); } - printf( ", %lu, %lu, %lu", delay_since_capture, gnss_results.timings.radio_ms, - gnss_results.timings.computation_ms ); + printf( ", %u, %u, %u", delay_since_capture, gnss_results.timings.radio_ms, gnss_results.timings.computation_ms ); printf( "\n" ); } void CommunicationDemo::Store( const version_handler_t& version ) { - CommunicationDemo::Store( "%s:%s:%s:0x%04x:0x%x:%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", - COMMUNICATION_DEMO_COMMAND_TOKEN_STORE_VERSION, version.version_sw, - version.version_driver, version.version_chip_fw, version.almanac_date, - version.chip_uid[0], version.chip_uid[1], version.chip_uid[2], version.chip_uid[3], - version.chip_uid[4], version.chip_uid[5], version.chip_uid[6], version.chip_uid[7] ); + switch( version.device_type ) + { + case VERSION_DEVICE_TRANSCEIVER: + { + CommunicationDemo::Store( "%s:%s:%s:0x%04x:0x%x:%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", + COMMUNICATION_DEMO_COMMAND_TOKEN_STORE_VERSION, version.version_sw, + version.version_driver, version.transceiver.version_chip_fw, version.almanac_date, + version.chip_uid[0], version.chip_uid[1], version.chip_uid[2], version.chip_uid[3], + version.chip_uid[4], version.chip_uid[5], version.chip_uid[6], version.chip_uid[7] ); + break; + } + case VERSION_DEVICE_MODEM: + { + CommunicationDemo::Store( "%s:%s:%s:0x%06x:0x%x:%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", + COMMUNICATION_DEMO_COMMAND_TOKEN_STORE_VERSION, version.version_sw, + version.version_driver, version.modem.version_chip_fw, version.almanac_date, + version.chip_uid[0], version.chip_uid[1], version.chip_uid[2], version.chip_uid[3], + version.chip_uid[4], version.chip_uid[5], version.chip_uid[6], version.chip_uid[7] ); + break; + } + } } bool CommunicationDemo::GetDateAndApproximateLocation( uint32_t& gps_second, float& latitude, float& longitude, @@ -112,7 +127,7 @@ bool CommunicationDemo::GetDateAndApproximateLocation( uint32_t& gps_second, flo COMMUNICATION_DEMO_TIMEOUT_SERIAL_RECEIVE_MS ); if( status == COMMUNICATION_DEMO_STATUS_OK ) { - sscanf( data_loc_blob, "%lu,%f,%f,%f", &gps_second, &altitude, &latitude, &longitude ); + sscanf( data_loc_blob, "%u,%f,%f,%f", &gps_second, &altitude, &latitude, &longitude ); success = true; } else diff --git a/embedded/communication/src/communication_print_only.cpp b/embedded/communication/src/communication_print_only.cpp index b3fb34d..09452a9 100644 --- a/embedded/communication/src/communication_print_only.cpp +++ b/embedded/communication/src/communication_print_only.cpp @@ -64,9 +64,9 @@ void CommunicationPrintOnly::Store( const demo_wifi_scan_all_results_t& wifi_res demo_wifi_scan_single_result_t local_result = wifi_results.results[result_index]; printf( - "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x, CHANNEL_%i, %s, %i, %li, %li, " - "%li, " - "%li\n", + "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x, CHANNEL_%i, %s, %i, %u, %u, " + "%u, " + "%u\n", local_result.mac_address[0], local_result.mac_address[1], local_result.mac_address[2], local_result.mac_address[3], local_result.mac_address[4], local_result.mac_address[5], local_result.channel, CommunicationInterface::WifiTypeToStr( local_result.type ), local_result.rssi, @@ -77,24 +77,40 @@ void CommunicationPrintOnly::Store( const demo_wifi_scan_all_results_t& wifi_res void CommunicationPrintOnly::Store( const demo_gnss_all_results_t& gnss_results, uint32_t delay_since_capture ) { - printf( "# GNSS result captured %lu second(s) ago:\n", delay_since_capture ); + printf( "# GNSS result captured %u second(s) ago:\n", delay_since_capture ); for( uint16_t index = 0; index < gnss_results.nav_message.size; index++ ) { printf( "%02x", gnss_results.nav_message.message[index] ); } - printf( ", %lu, %lu, %lu", delay_since_capture, gnss_results.timings.radio_ms, - gnss_results.timings.computation_ms ); + printf( ", %u, %u, %u", delay_since_capture, gnss_results.timings.radio_ms, gnss_results.timings.computation_ms ); printf( "\n" ); } void CommunicationPrintOnly::Store( const version_handler_t& version ) { - printf( - "Software version: %s\nDriver version: %s\nChip version: 0x%04x\nAlmanac date: 0x%x\nChip UID: " - "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", - version.version_sw, version.version_driver, version.version_chip_fw, version.almanac_date, version.chip_uid[0], - version.chip_uid[1], version.chip_uid[2], version.chip_uid[3], version.chip_uid[4], version.chip_uid[5], - version.chip_uid[6], version.chip_uid[7] ); + switch( version.device_type ) + { + case VERSION_DEVICE_TRANSCEIVER: + { + printf( + "Software version: %s\nDriver version: %s\nChip version: 0x%04x\nAlmanac date: 0x%x\nChip UID: " + "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", + version.version_sw, version.version_driver, version.transceiver.version_chip_fw, version.almanac_date, + version.chip_uid[0], version.chip_uid[1], version.chip_uid[2], version.chip_uid[3], version.chip_uid[4], + version.chip_uid[5], version.chip_uid[6], version.chip_uid[7] ); + break; + } + case VERSION_DEVICE_MODEM: + { + printf( + "Software version: %s\nDriver version: %s\nChip version: 0x%06x\nAlmanac date: 0x%x\nChip UID: " + "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", + version.version_sw, version.version_driver, version.modem.version_chip_fw, version.almanac_date, + version.chip_uid[0], version.chip_uid[1], version.chip_uid[2], version.chip_uid[3], version.chip_uid[4], + version.chip_uid[5], version.chip_uid[6], version.chip_uid[7] ); + break; + } + } } void CommunicationPrintOnly::EraseDataStored( ) { return; } diff --git a/embedded/connectivity/inc/connectivity_conversions.h b/embedded/connectivity/inc/connectivity_conversions.h new file mode 100644 index 0000000..c969b05 --- /dev/null +++ b/embedded/connectivity/inc/connectivity_conversions.h @@ -0,0 +1,61 @@ +/** + * @file connectivity_conversions.h + * + * @brief Definition of the ConnectivityConversions class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __CONNECTIVITY_CONVERSIONS_H__ +#define __CONNECTIVITY_CONVERSIONS_H__ + +#include "demo_wifi_types.h" +#include "demo_gnss_types.h" + +typedef enum +{ + CONNECTIVITY_CONVERSION_SUCCESS, + CONNECTIVITY_CONVERSION_ERROR_BUFFER_TOO_SHORT, +} ConnectivityConversionStatus_t; + +class ConnectivityConversions +{ + public: + static ConnectivityConversionStatus_t copy_demo_result_to_tlv_payload_buffer( + const demo_wifi_scan_all_results_t& wifi_results, uint8_t* buffer, uint16_t* buffer_size, + uint16_t max_buffer_size ); + + static ConnectivityConversionStatus_t copy_demo_result_to_tlv_payload_buffer( + const demo_gnss_all_results_t& gnss_result, uint8_t* buffer, uint16_t* buffer_size, uint16_t max_buffer_size ); + + protected: + static uint16_t tlv_paylod_size_from_results( const demo_wifi_scan_all_results_t& wifi_results ); + static uint16_t tlv_paylod_size_from_results( const demo_gnss_all_results_t& gnss_results ); + static uint16_t tlv_value_field_length_from_results( const demo_wifi_scan_all_results_t& wifi_results ); + static uint16_t tlv_value_field_length_from_results( const demo_gnss_all_results_t& gnss_results ); +}; + +#endif // __CONNECTIVITY_CONVERSIONS_H__ \ No newline at end of file diff --git a/embedded/connectivity/inc/connectivity_manager_interface.h b/embedded/connectivity/inc/connectivity_manager_interface.h new file mode 100644 index 0000000..d772a53 --- /dev/null +++ b/embedded/connectivity/inc/connectivity_manager_interface.h @@ -0,0 +1,103 @@ +/** + * @file connectivity_manager_interface.h + * + * @brief Definition of connectivity manager interface class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __CONNECTIVITY_MANAGER_INTERFACE_H__ +#define __CONNECTIVITY_MANAGER_INTERFACE_H__ + +#include "device_interface.h" +#include "interruption_interface.h" +#include "lr1110_modem_lorawan.h" + +#define CONNECTIVITY_MANAGER_INTERFACE_STREAM_APP_PORT ( 199 ) +typedef enum +{ + NETWORK_CONNECTIVITY_STATUS_NO_CHANGE, + NETWORK_CONNECTIVITY_STATUS_JOIN, + NETWORK_CONNECTIVITY_STATUS_STREAM_DONE, + NETWORK_CONNECTIVITY_STATUS_GOT_ALC_SYNC, + NETWORK_CONNECTIVITY_STATUS_LOST_ALC_SYNC, +} network_connectivity_status_t; + +typedef enum +{ + NETWORK_CONNECTIVITY_REGION_EU868, + NETWORK_CONNECTIVITY_REGION_US915, +} network_connectivity_region_t; + +typedef enum +{ + NETWORK_CONNECTIVITY_CMD_STATUS_OK, + NETWORK_CONNECTIVITY_CMD_STATUS_BUFFER_TOO_SHORT, + NETWORK_CONNECTIVITY_CMD_STATUS_ERROR, +} network_connectivity_cmd_status_t; + +typedef enum +{ + NETWORK_CONNECTIVITY_ADR_NETWORK_SERVER_CONTROLLED, + NETWORK_CONNECTIVITY_ADR_MOBILE_LONG_RANGE, + NETWORK_CONNECTIVITY_ADR_MOBILE_LOW_POWER, +} network_connectivity_adr_profile_t; + +typedef struct +{ + network_connectivity_region_t region; + network_connectivity_adr_profile_t adr_profile; +} network_connectivity_settings_t; + +class ConnectivityManagerInterface +{ + public: + explicit ConnectivityManagerInterface( ); + virtual ~ConnectivityManagerInterface( ); + + virtual network_connectivity_status_t Runtime( ) = 0; + + virtual bool IsConnectable( ) const = 0; + virtual void Join( network_connectivity_settings_t* settings ) = 0; + virtual void Leave( ) = 0; + virtual network_connectivity_cmd_status_t Send( uint8_t* data, uint8_t length ) = 0; + virtual void GetCurrentRegion( network_connectivity_region_t* region ) = 0; + virtual void SetRegion( network_connectivity_region_t region ) = 0; + virtual void SetAdrProfile( network_connectivity_adr_profile_t profile ) = 0; + virtual void ResetCommissioningToSemtechJoinServer( ) = 0; + + virtual void InterruptHandler( const InterruptionInterface* interruption ) = 0; + + bool getTimeSyncState( ); + + protected: + bool _is_time_sync; + bool _is_joined; + network_connectivity_settings_t _settings; + static const uint8_t SEMTECH_DEFAULT_JOIN_EUI[LR1110_MODEM_DM_MESSAGE_JOIN_EUI_LENGTH]; +}; + +#endif // __CONNECTIVITY_MANAGER_INTERFACE_H__ diff --git a/embedded/connectivity/inc/connectivity_manager_modem.h b/embedded/connectivity/inc/connectivity_manager_modem.h new file mode 100644 index 0000000..421bb9d --- /dev/null +++ b/embedded/connectivity/inc/connectivity_manager_modem.h @@ -0,0 +1,64 @@ +/** + * @file connectivity_manager_modem.h + * + * @brief Definition of modem connectivity class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __CONNECTIVITY_MANAGER_MODEM_H__ +#define __CONNECTIVITY_MANAGER_MODEM_H__ + +#include "connectivity_manager_interface.h" +#include "device_modem.h" +#include "lr1110_modem_lorawan.h" + +class ConnectivityManagerModem : public ConnectivityManagerInterface +{ + public: + explicit ConnectivityManagerModem( DeviceModem* device ); + virtual ~ConnectivityManagerModem( ); + + network_connectivity_status_t Runtime( ) final; + + bool IsConnectable( ) const final; + void Join( network_connectivity_settings_t* settings ) final; + void Leave( ) final; + network_connectivity_cmd_status_t Send( uint8_t* data, uint8_t length ) final; + void GetCurrentRegion( network_connectivity_region_t* region ) final; + void SetRegion( network_connectivity_region_t region ) final; + void SetAdrProfile( network_connectivity_adr_profile_t profile ) final; + void ResetCommissioningToSemtechJoinServer( ) final; + + void InterruptHandler( const InterruptionInterface* interruption ) final; + + private: + DeviceModem* _device; + bool _has_received_event; + lr1110_modem_event_fields_t _last_received_event; +}; + +#endif // __CONNECTIVITY_MANAGER_MODEM_H__ diff --git a/embedded/connectivity/inc/connectivity_manager_transceiver.h b/embedded/connectivity/inc/connectivity_manager_transceiver.h new file mode 100644 index 0000000..9d5239d --- /dev/null +++ b/embedded/connectivity/inc/connectivity_manager_transceiver.h @@ -0,0 +1,63 @@ +/** + * @file connectivity_manager_transceiver.h + * + * @brief Definition of transceiver connectivity class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __CONNECTIVITY_MANAGER_TRANSCEIVER_H__ +#define __CONNECTIVITY_MANAGER_TRANSCEIVER_H__ + +#include "connectivity_manager_interface.h" +#include + +/** + * @brief Connectivity manager for transceiver + * + * This connectivity manager does basically nothing. There is no LoRaWan connectivity implemented for transceiver here. + */ +class ConnectivityManagerTransceiver : public ConnectivityManagerInterface +{ + public: + ConnectivityManagerTransceiver( ); + virtual ~ConnectivityManagerTransceiver( ); + + network_connectivity_status_t Runtime( ) final; + + bool IsConnectable( ) const final; + void Join( network_connectivity_settings_t* settings ) final; + void Leave( ) final; + network_connectivity_cmd_status_t Send( uint8_t* data, uint8_t length ) final; + void GetCurrentRegion( network_connectivity_region_t* region ) final; + void SetRegion( network_connectivity_region_t region ) final; + void SetAdrProfile( network_connectivity_adr_profile_t profile ) final; + void ResetCommissioningToSemtechJoinServer( ) final; + + void InterruptHandler( const InterruptionInterface* interruption ) final; +}; + +#endif // __CONNECTIVITY_MANAGER_TRANSCEIVER_H__ \ No newline at end of file diff --git a/embedded/connectivity/src/connectivity_conversions.cpp b/embedded/connectivity/src/connectivity_conversions.cpp new file mode 100644 index 0000000..40dbeb2 --- /dev/null +++ b/embedded/connectivity/src/connectivity_conversions.cpp @@ -0,0 +1,101 @@ +/** + * @file connectivity_conversions.cpp + * + * @brief Implementation of the ConnectivityConversions class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "connectivity_conversions.h" + +#define CONNECTIVITY_CONVERSIONS_WIFI_SINGLE_VALUE_LENGTH ( 7 ) +#define CONNECTIVITY_CONVERSIONS_TLV_LENGTH_TAG_FIELD ( 1 ) +#define CONNECTIVITY_CONVERSIONS_TLV_LENGTH_LEN_FIELD ( 1 ) +#define CONNECTIVITY_CONVERSIONS_TLV_TAG_WIFI ( 0x08 ) +#define CONNECTIVITY_CONVERSIONS_TLV_TAG_GNSS ( 0x07 ) + +ConnectivityConversionStatus_t ConnectivityConversions::copy_demo_result_to_tlv_payload_buffer( + const demo_wifi_scan_all_results_t& wifi_results, uint8_t* buffer, uint16_t* buffer_size, uint16_t max_buffer_size ) +{ + const uint16_t length_value_field = ConnectivityConversions::tlv_value_field_length_from_results( wifi_results ); + const uint16_t local_buffer_size = length_value_field + CONNECTIVITY_CONVERSIONS_TLV_LENGTH_TAG_FIELD + + CONNECTIVITY_CONVERSIONS_TLV_LENGTH_LEN_FIELD; + // 0. Check the buffer is long enough to contain the TLV + if( max_buffer_size < local_buffer_size ) + { + return CONNECTIVITY_CONVERSION_ERROR_BUFFER_TOO_SHORT; + } + + *buffer_size = local_buffer_size; + + // 1. Write the tag and length fields + buffer[0] = CONNECTIVITY_CONVERSIONS_TLV_TAG_WIFI; + buffer[1] = length_value_field; + + // 2. Write the value field + for( uint8_t index_wifi_result = 0; index_wifi_result < wifi_results.nbrResults; index_wifi_result++ ) + { + const uint16_t local_buffer_offset = 2 + index_wifi_result * CONNECTIVITY_CONVERSIONS_WIFI_SINGLE_VALUE_LENGTH; + const demo_wifi_scan_single_result_t local_wifi_result = wifi_results.results[index_wifi_result]; + buffer[local_buffer_offset] = local_wifi_result.rssi; + memcpy( &buffer[local_buffer_offset + 1], local_wifi_result.mac_address, DEMO_TYPE_WIFI_MAC_ADDRESS_LENGTH ); + } + return CONNECTIVITY_CONVERSION_SUCCESS; +} + +ConnectivityConversionStatus_t ConnectivityConversions::copy_demo_result_to_tlv_payload_buffer( + const demo_gnss_all_results_t& gnss_result, uint8_t* buffer, uint16_t* buffer_size, uint16_t max_buffer_size ) +{ + const uint16_t length_value_field = ConnectivityConversions::tlv_value_field_length_from_results( gnss_result ); + const uint16_t local_buffer_size = length_value_field + CONNECTIVITY_CONVERSIONS_TLV_LENGTH_TAG_FIELD + + CONNECTIVITY_CONVERSIONS_TLV_LENGTH_LEN_FIELD; + // 0. Check the buffer is long enough to contain the TLV + if( max_buffer_size < local_buffer_size ) + { + return CONNECTIVITY_CONVERSION_ERROR_BUFFER_TOO_SHORT; + } + + *buffer_size = local_buffer_size; + // 1. Write the tag and length fields + buffer[0] = CONNECTIVITY_CONVERSIONS_TLV_TAG_GNSS; + buffer[1] = length_value_field; + + // 2. Write the value field. WARNING: do not copy the first byte of the nav message in the buffer + memcpy( &buffer[2], &gnss_result.nav_message.message[1], gnss_result.nav_message.size - 1 ); + return CONNECTIVITY_CONVERSION_SUCCESS; +} + +uint16_t ConnectivityConversions::tlv_value_field_length_from_results( + const demo_wifi_scan_all_results_t& wifi_results ) +{ + return wifi_results.nbrResults * CONNECTIVITY_CONVERSIONS_WIFI_SINGLE_VALUE_LENGTH; +} + +uint16_t ConnectivityConversions::tlv_value_field_length_from_results( const demo_gnss_all_results_t& gnss_results ) +{ + return gnss_results.nav_message.size - 1; +} diff --git a/embedded/connectivity/src/connectivity_manager_interface.cpp b/embedded/connectivity/src/connectivity_manager_interface.cpp new file mode 100644 index 0000000..02c96d8 --- /dev/null +++ b/embedded/connectivity/src/connectivity_manager_interface.cpp @@ -0,0 +1,42 @@ +/** + * @file connectivity_manager_interface.cpp + * + * @brief Implementation of connectivity manager interface class + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "connectivity_manager_interface.h" + +const uint8_t ConnectivityManagerInterface::SEMTECH_DEFAULT_JOIN_EUI[LR1110_MODEM_DM_MESSAGE_JOIN_EUI_LENGTH] = { + 0x00, 0x16, 0xC0, 0x01, 0xFF, 0xFE, 0x00, 0x01 +}; + +ConnectivityManagerInterface::ConnectivityManagerInterface( ) : _is_time_sync( false ), _is_joined( false ) {} + +ConnectivityManagerInterface::~ConnectivityManagerInterface( ) {} + +bool ConnectivityManagerInterface::getTimeSyncState( ) { return this->_is_time_sync; } diff --git a/embedded/connectivity/src/connectivity_manager_modem.cpp b/embedded/connectivity/src/connectivity_manager_modem.cpp new file mode 100644 index 0000000..8c84b5c --- /dev/null +++ b/embedded/connectivity/src/connectivity_manager_modem.cpp @@ -0,0 +1,270 @@ +/** + * @file connectivity_manager_modem.cpp + * + * @brief Implementation of connectivity manager for modem. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "connectivity_manager_modem.h" +#include "system_time.h" + +#define CONNECTIVITY_MANAGER_PERIOD_TEST_GPS_TIME_MS ( 1000 ) + +ConnectivityManagerModem::ConnectivityManagerModem( DeviceModem* device ) + : ConnectivityManagerInterface( ), _device( device ), _has_received_event( false ) +{ +} + +ConnectivityManagerModem::~ConnectivityManagerModem( ) {} + +network_connectivity_status_t ConnectivityManagerModem::Runtime( ) +{ + if( this->_has_received_event == true ) + { + this->_has_received_event = false; + + switch( this->_last_received_event.event_type ) + { + case LR1110_MODEM_LORAWAN_EVENT_JOINED: + { + uint8_t adr_profile_custom[16] = { 0 }; + + this->_is_joined = true; + + this->SetAdrProfile( this->_settings.adr_profile ); + + lr1110_modem_stream_init( this->_device->GetRadio( ), CONNECTIVITY_MANAGER_INTERFACE_STREAM_APP_PORT, + LR1110_MODEM_FILE_ENCRYPTION_DISABLE ); + return NETWORK_CONNECTIVITY_STATUS_JOIN; + } + case LR1110_MODEM_LORAWAN_EVENT_STREAM_DONE: + { + return NETWORK_CONNECTIVITY_STATUS_STREAM_DONE; + } + case LR1110_MODEM_LORAWAN_EVENT_TIME_UPDATED_ALC_SYNC: + { + if( this->_last_received_event.buffer[0] == 0x01 ) + { + this->_is_time_sync = true; + return NETWORK_CONNECTIVITY_STATUS_GOT_ALC_SYNC; + } + else + { + this->_is_time_sync = false; + return NETWORK_CONNECTIVITY_STATUS_LOST_ALC_SYNC; + } + } + default: + { + return NETWORK_CONNECTIVITY_STATUS_NO_CHANGE; + } + } + } + return NETWORK_CONNECTIVITY_STATUS_NO_CHANGE; +} + +bool ConnectivityManagerModem::IsConnectable( ) const { return true; } + +void ConnectivityManagerModem::Join( network_connectivity_settings_t* settings ) +{ + this->_settings.region = settings->region; + this->_settings.adr_profile = settings->adr_profile; + + const lr1110_modem_response_code_t set_class_response_code = + lr1110_modem_set_class( this->_device->GetRadio( ), LR1110_LORAWAN_CLASS_A ); + + this->SetRegion( this->_settings.region ); + + /* Set DM info field */ + lr1110_modem_dm_info_fields_t dm_info_fields; + dm_info_fields.dm_info_field[0] = LR1110_MODEM_DM_INFO_TYPE_GNSS_ALMANAC_STATUS; + dm_info_fields.dm_info_field[1] = LR1110_MODEM_DM_INFO_TYPE_CHARGE; + dm_info_fields.dm_info_field[2] = LR1110_MODEM_DM_INFO_TYPE_TEMPERATURE; + dm_info_fields.dm_info_field[3] = LR1110_MODEM_DM_INFO_TYPE_VOLTAGE; + dm_info_fields.dm_info_length = 4; + + const lr1110_modem_response_code_t set_dm_info_field_response_code = + lr1110_modem_set_dm_info_field( this->_device->GetRadio( ), &dm_info_fields ); + + const lr1110_modem_response_code_t set_dm_info_interval_response_code = + lr1110_modem_set_dm_info_interval( this->_device->GetRadio( ), LR1110_MODEM_REPORTING_INTERVAL_IN_HOUR, 1 ); + + lr1110_modem_alc_sync_mode_t alc_sync_mode; + lr1110_modem_get_alc_sync_mode( this->_device->GetRadio( ), &alc_sync_mode ); + + if( alc_sync_mode == LR1110_MODEM_ALC_SYNC_MODE_DISABLE ) + { + lr1110_modem_set_alc_sync_mode( this->_device->GetRadio( ), LR1110_MODEM_ALC_SYNC_MODE_ENABLE ); + } + + lr1110_modem_join( this->_device->GetRadio( ) ); +} + +void ConnectivityManagerModem::Leave( ) +{ + this->_is_joined = false; + lr1110_modem_leave_network( this->_device->GetRadio( ) ); +} + +network_connectivity_cmd_status_t ConnectivityManagerModem::Send( uint8_t* data, uint8_t length ) +{ + lr1110_modem_response_code_t rc; + lr1110_modem_stream_status_t stream_status; + + rc = lr1110_modem_stream_status( this->_device->GetRadio( ), CONNECTIVITY_MANAGER_INTERFACE_STREAM_APP_PORT, + &stream_status ); + + if( rc != LR1110_MODEM_RESPONSE_CODE_OK ) + { + return NETWORK_CONNECTIVITY_CMD_STATUS_ERROR; + } + + if( stream_status.free < length ) + { + return NETWORK_CONNECTIVITY_CMD_STATUS_BUFFER_TOO_SHORT; + } + + rc = lr1110_modem_send_stream_data( this->_device->GetRadio( ), CONNECTIVITY_MANAGER_INTERFACE_STREAM_APP_PORT, + data, length ); + + if( rc != LR1110_MODEM_RESPONSE_CODE_OK ) + { + return NETWORK_CONNECTIVITY_CMD_STATUS_ERROR; + } + + return NETWORK_CONNECTIVITY_CMD_STATUS_OK; +} + +void ConnectivityManagerModem::GetCurrentRegion( network_connectivity_region_t* region ) +{ + lr1110_modem_regions_t region_modem; + + lr1110_modem_get_region( this->_device->GetRadio( ), ®ion_modem ); + + switch( region_modem ) + { + case LR1110_LORAWAN_REGION_EU868: + { + *region = NETWORK_CONNECTIVITY_REGION_EU868; + break; + } + case LR1110_LORAWAN_REGION_US915: + { + *region = NETWORK_CONNECTIVITY_REGION_US915; + break; + } + default: + { + break; + } + } +} + +void ConnectivityManagerModem::SetRegion( network_connectivity_region_t region ) +{ + switch( region ) + { + case NETWORK_CONNECTIVITY_REGION_EU868: + { + lr1110_modem_set_region( this->_device->GetRadio( ), LR1110_LORAWAN_REGION_EU868 ); + break; + } + case NETWORK_CONNECTIVITY_REGION_US915: + { + lr1110_modem_set_region( this->_device->GetRadio( ), LR1110_LORAWAN_REGION_US915 ); + break; + } + default: + { + break; + } + } +} + +void ConnectivityManagerModem::SetAdrProfile( network_connectivity_adr_profile_t profile ) +{ + uint8_t adr_list[16] = { 0 }; + + switch( profile ) + { + case NETWORK_CONNECTIVITY_ADR_NETWORK_SERVER_CONTROLLED: + { + lr1110_modem_set_adr_profile( this->_device->GetRadio( ), LR1110_MODEM_ADR_PROFILE_NETWORK_SERVER_CONTROLLED, + adr_list ); + break; + } + case NETWORK_CONNECTIVITY_ADR_MOBILE_LONG_RANGE: + { + lr1110_modem_set_adr_profile( this->_device->GetRadio( ), LR1110_MODEM_ADR_PROFILE_MOBILE_LONG_RANGE, + adr_list ); + break; + } + case NETWORK_CONNECTIVITY_ADR_MOBILE_LOW_POWER: + { + lr1110_modem_set_adr_profile( this->_device->GetRadio( ), LR1110_MODEM_ADR_PROFILE_MOBILE_LOW_POWER, adr_list ); + break; + } + default: + { + break; + } + } +} + +void ConnectivityManagerModem::ResetCommissioningToSemtechJoinServer( ) +{ + // 1. Get the factory device EUI which is the chip EUI + lr1110_modem_chip_eui_t chip_eui = { 0 }; + lr1110_modem_get_chip_eui( this->_device->GetRadio( ), chip_eui ); + + // 2. Set the Device and App (Join) EUIs + lr1110_modem_set_dev_eui( this->_device->GetRadio( ), chip_eui ); + lr1110_modem_set_join_eui( this->_device->GetRadio( ), this->SEMTECH_DEFAULT_JOIN_EUI ); + + // 3. Re-compute the keys + lr1110_modem_derive_keys( this->_device->GetRadio( ) ); + + lr1110_modem_regions_t region_modem; + lr1110_modem_regions_t region_modem_fake; + lr1110_modem_get_region( this->_device->GetRadio( ), ®ion_modem ); + + region_modem_fake = + ( region_modem != LR1110_LORAWAN_REGION_EU868 ) ? LR1110_LORAWAN_REGION_EU868 : LR1110_LORAWAN_REGION_US915; + lr1110_modem_set_region( this->_device->GetRadio( ), region_modem_fake ); + lr1110_modem_set_region( this->_device->GetRadio( ), region_modem ); +} + +void ConnectivityManagerModem::InterruptHandler( const InterruptionInterface* interruption ) +{ + const InterruptionModem* interrupt = dynamic_cast< const InterruptionModem* >( interruption ); + + if( interrupt != 0 ) + { + this->_last_received_event = interrupt->GetEvent( ); + this->_has_received_event = true; + } +} diff --git a/embedded/connectivity/src/connectivity_manager_transceiver.cpp b/embedded/connectivity/src/connectivity_manager_transceiver.cpp new file mode 100644 index 0000000..72be6cd --- /dev/null +++ b/embedded/connectivity/src/connectivity_manager_transceiver.cpp @@ -0,0 +1,85 @@ +/** + * @file connectivity_manager_transceiver.cpp + * + * @brief Implementation of connectivity manager for transceiver. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "connectivity_manager_transceiver.h" + +ConnectivityManagerTransceiver::ConnectivityManagerTransceiver( ) {} + +ConnectivityManagerTransceiver::~ConnectivityManagerTransceiver( ) {} + +network_connectivity_status_t ConnectivityManagerTransceiver::Runtime( ) +{ + // Has of today there is no connectivity with the transceiver + return NETWORK_CONNECTIVITY_STATUS_NO_CHANGE; +} + +bool ConnectivityManagerTransceiver::IsConnectable( ) const { return false; } + +void ConnectivityManagerTransceiver::Join( network_connectivity_settings_t* settings ) +{ + ( void ) settings; + return; +} + +void ConnectivityManagerTransceiver::Leave( ) { return; } + +network_connectivity_cmd_status_t ConnectivityManagerTransceiver::Send( uint8_t* data, uint8_t length ) +{ + ( void ) data; + ( void ) length; + return NETWORK_CONNECTIVITY_CMD_STATUS_ERROR; +} + +void ConnectivityManagerTransceiver::GetCurrentRegion( network_connectivity_region_t* region ) +{ + ( void ) region; + return; +} + +void ConnectivityManagerTransceiver::SetRegion( network_connectivity_region_t region ) +{ + ( void ) region; + return; +} + +void ConnectivityManagerTransceiver::SetAdrProfile( network_connectivity_adr_profile_t profile ) +{ + ( void ) profile; + return; +} + +void ConnectivityManagerTransceiver::ResetCommissioningToSemtechJoinServer( ) {} + +void ConnectivityManagerTransceiver::InterruptHandler( const InterruptionInterface* interruption ) +{ + ( void ) interruption; + return; +} \ No newline at end of file diff --git a/embedded/demo/inc/demo_configuration.h b/embedded/demo/inc/demo_configuration.h index 3535496..ee92ac6 100644 --- a/embedded/demo/inc/demo_configuration.h +++ b/embedded/demo/inc/demo_configuration.h @@ -33,48 +33,63 @@ #define __DEMO_CONFIGURATION_H__ #include "lr1110_wifi.h" -#include "lr1110_gnss_types.h" #include "lr1110_radio_types.h" +#include "lr1110_modem_lorawan.h" +#include "demo_wifi_types.h" +#include "demo_gnss_types.h" + +typedef enum +{ + DEMO_SYSTEM_RFSW0_HIGH = ( 1 << 0 ), + DEMO_SYSTEM_RFSW1_HIGH = ( 1 << 1 ), + DEMO_SYSTEM_RFSW2_HIGH = ( 1 << 2 ), + DEMO_SYSTEM_RFSW3_HIGH = ( 1 << 3 ), + DEMO_SYSTEM_RFSW4_HIGH = ( 1 << 4 ), +} demo_system_rf_switch_t; + +#define DEMO_ASSISTANCE_LOCATION_LATITUDE ( 45.1 ) +#define DEMO_ASSISTANCE_LOCATION_LONGITUDE ( 5.7 ) +#define DEMO_ASSISTANCE_LOCATION_ALTITUDE ( 100 ) #define DEMO_COMMON_RF_SWITCH_ENABLE \ - ( LR1110_SYSTEM_RFSW0_HIGH | LR1110_SYSTEM_RFSW1_HIGH | LR1110_SYSTEM_RFSW2_HIGH | LR1110_SYSTEM_RFSW3_HIGH ) + ( DEMO_SYSTEM_RFSW0_HIGH | DEMO_SYSTEM_RFSW1_HIGH | DEMO_SYSTEM_RFSW2_HIGH | DEMO_SYSTEM_RFSW3_HIGH ) #define DEMO_COMMON_RF_SWITCH_STANDBY 0x00 -#define DEMO_COMMON_RF_SWITCH_RX ( LR1110_SYSTEM_RFSW0_HIGH ) -#define DEMO_COMMON_RF_SWITCH_TX ( LR1110_SYSTEM_RFSW0_HIGH | LR1110_SYSTEM_RFSW1_HIGH ) -#define DEMO_COMMON_RF_SWITCH_TX_HP ( LR1110_SYSTEM_RFSW1_HIGH ) -#define DEMO_COMMON_RF_SWITCH_WIFI ( LR1110_SYSTEM_RFSW3_HIGH ) -#define DEMO_COMMON_RF_SWITCH_GNSS ( LR1110_SYSTEM_RFSW2_HIGH ) +#define DEMO_COMMON_RF_SWITCH_RX ( DEMO_SYSTEM_RFSW0_HIGH ) +#define DEMO_COMMON_RF_SWITCH_TX ( DEMO_SYSTEM_RFSW0_HIGH | DEMO_SYSTEM_RFSW1_HIGH ) +#define DEMO_COMMON_RF_SWITCH_TX_HP ( DEMO_SYSTEM_RFSW1_HIGH ) +#define DEMO_COMMON_RF_SWITCH_WIFI ( DEMO_SYSTEM_RFSW3_HIGH ) +#define DEMO_COMMON_RF_SWITCH_GNSS ( DEMO_SYSTEM_RFSW2_HIGH ) #define DEMO_WIFI_CHANNELS_DEFAULT \ ( ( 1 << LR1110_WIFI_CHANNEL_11 ) + ( 1 << LR1110_WIFI_CHANNEL_6 ) + ( 1 << LR1110_WIFI_CHANNEL_1 ) ) -#define DEMO_WIFI_TYPE_SCAN_DEFAULT LR1110_WIFI_TYPE_SCAN_B -#define DEMO_WIFI_MODE_DEFAULT LR1110_WIFI_SCAN_MODE_BEACON_AND_PACKET +#define DEMO_WIFI_TYPE_SCAN_DEFAULT DEMO_WIFI_SETTING_TYPE_B +#define DEMO_WIFI_MODE_DEFAULT DEMO_WIFI_SCAN_MODE_BEACON_AND_PACKET #define DEMO_WIFI_NBR_RETRIALS_DEFAULT 5 #define DEMO_WIFI_MAX_RESULTS_DEFAULT 15 #define DEMO_WIFI_TIMEOUT_IN_MS_DEFAULT 110 #define DEMO_WIFI_RESULT_TYPE_DEFAULT ( DEMO_WIFI_RESULT_TYPE_BASIC_COMPLETE ) #define DEMO_WIFI_DOES_ABORT_ON_TIMEOUT_DEFAULT ( false ) -#define DEMO_GNSS_AUTONOMOUS_OPTION_DEFAULT ( LR1110_GNSS_OPTION_DEFAULT ) -#define DEMO_GNSS_AUTONOMOUS_CAPTURE_MODE_DEFAULT ( LR1110_GNSS_SINGLE_SCAN_MODE ) +#define DEMO_GNSS_AUTONOMOUS_OPTION_DEFAULT ( DEMO_GNSS_OPTION_DEFAULT ) +#define DEMO_GNSS_AUTONOMOUS_CAPTURE_MODE_DEFAULT ( DEMO_GNSS_SINGLE_SCAN_MODE ) #define DEMO_GNSS_AUTONOMOUS_N_SATELLLITE_DEFAULT ( 0 ) #define DEMO_GNSS_AUTONOMOUS_ANTENNA_SELECTION_DEFAULT ( DEMO_GNSS_NO_ANTENNA_SELECTION ) -#define DEMO_GNSS_AUTONOMOUS_CONSTELLATION_MASK_DEFAULT ( LR1110_GNSS_GPS_MASK | LR1110_GNSS_BEIDOU_MASK ) +#define DEMO_GNSS_AUTONOMOUS_CONSTELLATION_MASK_DEFAULT ( DEMO_GNSS_GPS_MASK | DEMO_GNSS_BEIDOU_MASK ) -#define DEMO_GNSS_ASSISTED_OPTION_DEFAULT ( LR1110_GNSS_OPTION_DEFAULT ) -#define DEMO_GNSS_ASSISTED_CAPTURE_MODE_DEFAULT ( LR1110_GNSS_SINGLE_SCAN_MODE ) +#define DEMO_GNSS_ASSISTED_OPTION_DEFAULT ( DEMO_GNSS_OPTION_DEFAULT ) +#define DEMO_GNSS_ASSISTED_CAPTURE_MODE_DEFAULT ( DEMO_GNSS_SINGLE_SCAN_MODE ) #define DEMO_GNSS_ASSISTED_N_SATELLLITE_DEFAULT ( 0 ) #define DEMO_GNSS_ASSISTED_ANTENNA_SELECTION_DEFAULT ( DEMO_GNSS_NO_ANTENNA_SELECTION ) -#define DEMO_GNSS_ASSISTED_CONSTELLATION_MASK_DEFAULT ( LR1110_GNSS_GPS_MASK | LR1110_GNSS_BEIDOU_MASK ) +#define DEMO_GNSS_ASSISTED_CONSTELLATION_MASK_DEFAULT ( DEMO_GNSS_GPS_MASK | DEMO_GNSS_BEIDOU_MASK ) #define DEMO_RADIO_RF_FREQUENCY_DEFAULT ( 868200000 ) #define DEMO_RADIO_TX_POWER_DEFAULT ( 14 ) #define DEMO_RADIO_PAYLOAD_LENGTH_DEFAULT ( 20 ) #define DEMO_RADIO_NB_OF_PACKET_DEFAULT ( 10 ) -#define DEMO_RADIO_PA_RAMP_TIME_DEFAULT ( LR1110_RADIO_RAMP_200_US ) +#define DEMO_RADIO_PA_RAMP_TIME_DEFAULT ( LR1110_RADIO_RAMP_240_US ) #define DEMO_RADIO_PA_DUTY_CYCLE_DEFAULT ( 4 ) #define DEMO_RADIO_PA_HP_SEL_DEFAULT ( 0 ) -#define DEMO_RADIO_PA_REG_SUPPLY_DEFAULT ( LR1110_RADIO_PA_REG_SUPPLY_DCDC ) +#define DEMO_RADIO_PA_REG_SUPPLY_DEFAULT ( LR1110_RADIO_PA_REG_SUPPLY_VREG ) #define DEMO_RADIO_PA_SEL_DEFAULT ( LR1110_RADIO_PA_SEL_LP ) #define DEMO_RADIO_PACKET_TYPE_DEFAULT ( LR1110_RADIO_PKT_TYPE_LORA ) #define DEMO_RADIO_LORA_BW_DEFAULT ( LR1110_RADIO_LORA_BW_250 ) @@ -113,48 +128,6 @@ typedef struct lr1110_radio_pkt_params_lora_t packet_lora; } demo_radio_settings_t; -typedef enum -{ - DEMO_WIFI_RESULT_TYPE_BASIC_COMPLETE, - DEMO_WIFI_RESULT_TYPE_BASIC_MAC_TYPE_CHANNEL, -} demo_wifi_result_type_t; - -typedef struct -{ - lr1110_wifi_channel_mask_t channels; - lr1110_wifi_signal_type_scan_t types; - lr1110_wifi_mode_t scan_mode; - uint8_t nbr_retrials; - uint8_t max_results; - uint16_t timeout; - demo_wifi_result_type_t result_type; -} demo_wifi_settings_t; - -typedef struct -{ - lr1110_wifi_channel_mask_t channels; - uint8_t nbr_retrials; - uint8_t max_results; - uint32_t timeout; - bool does_abort_on_timeout; -} demo_wifi_country_code_settings_t; - -typedef enum -{ - DEMO_GNSS_NO_ANTENNA_SELECTION = 0, - DEMO_GNSS_ANTENNA_SELECTION_1 = 1, - DEMO_GNSS_ANTENNA_SELECTION_2 = 2, -} demo_gnss_antenna_selection_t; - -typedef struct -{ - lr1110_gnss_search_mode_t option; - lr1110_gnss_scan_mode_t capture_mode; - uint8_t nb_satellites; - demo_gnss_antenna_selection_t antenna_selection; - uint8_t constellation_mask; -} demo_gnss_settings_t; - typedef struct { demo_wifi_settings_t wifi_settings; diff --git a/embedded/demo/inc/demo_gnss_types.h b/embedded/demo/inc/demo_gnss_types.h index 59ed7c6..ea16c02 100644 --- a/embedded/demo/inc/demo_gnss_types.h +++ b/embedded/demo/inc/demo_gnss_types.h @@ -2,7 +2,6 @@ #define __DEMO_GNSS_TYPES_H__ #include -#include "lr1110_gnss_types.h" #define GNSS_DEMO_MAX_RESULT_TOTAL ( 32 ) #define GNSS_DEMO_NAV_MESSAGE_MAX_LENGTH ( 259 ) @@ -20,6 +19,12 @@ typedef struct int16_t snr; } demo_gnss_single_result_t; +typedef struct +{ + uint32_t radio_ms; + uint32_t computation_ms; +} demo_gnss_timings_t; + typedef struct { uint8_t message[GNSS_DEMO_NAV_MESSAGE_MAX_LENGTH]; @@ -42,7 +47,7 @@ typedef struct demo_gnss_error_t error; uint8_t nb_result; uint32_t consumption_uas; - lr1110_gnss_timings_t timings; + demo_gnss_timings_t timings; demo_gnss_single_result_t result[GNSS_DEMO_MAX_RESULT_TOTAL]; demo_gnss_nav_result_t nav_message; uint32_t local_instant_measurement; @@ -51,4 +56,38 @@ typedef struct bool almanac_too_old; } demo_gnss_all_results_t; +typedef enum +{ + DEMO_GNSS_NO_ANTENNA_SELECTION = 0, + DEMO_GNSS_ANTENNA_SELECTION_1 = 1, + DEMO_GNSS_ANTENNA_SELECTION_2 = 2, +} demo_gnss_antenna_selection_t; + +typedef enum +{ + DEMO_GNSS_GPS_MASK = 0x01, + DEMO_GNSS_BEIDOU_MASK = 0x02, +} demo_gnss_constellation_mask_t; + +typedef enum +{ + DEMO_GNSS_OPTION_DEFAULT, + DEMO_GNSS_OPTION_BEST_EFFORT, +} demo_gnss_search_mode_t; + +typedef enum +{ + DEMO_GNSS_SINGLE_SCAN_MODE, + DEMO_GNSS_DOUBLE_SCAN_MODE, +} demo_gnss_scan_mode_t; + +typedef struct +{ + demo_gnss_search_mode_t option; + demo_gnss_scan_mode_t capture_mode; + uint8_t nb_satellites; + demo_gnss_antenna_selection_t antenna_selection; + uint8_t constellation_mask; +} demo_gnss_settings_t; + #endif // __DEMO_GNSS_TYPES_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_base.h b/embedded/demo/inc/demo_interface.h similarity index 75% rename from embedded/demo/inc/demo_base.h rename to embedded/demo/inc/demo_interface.h index e959a9c..d447e67 100644 --- a/embedded/demo/inc/demo_base.h +++ b/embedded/demo/inc/demo_interface.h @@ -1,5 +1,5 @@ /** - * @file demo_base.h + * @file demo_interface.h * * @brief Definition of the components shared by all demonstrations. * @@ -29,10 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_BASE_H__ -#define __DEMO_BASE_H__ +#ifndef __DEMO_INTERFACE_H__ +#define __DEMO_INTERFACE_H__ -#include "device_base.h" +#include "device_interface.h" #include "signaling_interface.h" #include "communication_interface.h" @@ -44,16 +44,17 @@ typedef enum DEMO_STATUS_SKIPPED, } demo_status_t; -class DemoBase +class DemoInterface { public: - DemoBase( DeviceBase* device, SignalingInterface* signaling, CommunicationInterface* communication_interface ); - virtual ~DemoBase( ); + DemoInterface( DeviceInterface* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ); + virtual ~DemoInterface( ); void Initialize( ); demo_status_t Runtime( ); - static void InterruptHandler( ); + void InterruptHandler( const InterruptionInterface* interruption ); void Start( ); void Stop( ); @@ -67,14 +68,14 @@ class DemoBase bool IsWaitingForInterrupt( ) const; protected: - virtual void SpecificRuntime( ) = 0; - virtual void SpecificStop( ) = 0; - virtual void SpecificInterruptHandler( ) = 0; - virtual void ClearRegisteredIrqs( ) const = 0; + virtual void SpecificRuntime( ) = 0; + virtual void SpecificStop( ) = 0; + virtual void SpecificInterruptHandler( const InterruptionInterface* interruption ) = 0; + virtual void ClearRegisteredIrqs( ) const = 0; void SetWaitingForInterrupt( ); bool InterruptHasRaised( ); void Terminate( ); - DeviceBase* device; + DeviceInterface* device; SignalingInterface* signaling; CommunicationInterface* communication_interface; @@ -82,8 +83,7 @@ class DemoBase static bool is_initialized; bool is_waiting_for_interrupt; volatile static bool has_received_interrupt; - static DemoBase* running_demo; demo_status_t status; }; -#endif +#endif // __DEMO_INTERFACE_H__ diff --git a/embedded/demo/inc/demo.h b/embedded/demo/inc/demo_manager_interface.h similarity index 76% rename from embedded/demo/inc/demo.h rename to embedded/demo/inc/demo_manager_interface.h index f34a1f2..5f7fa07 100644 --- a/embedded/demo/inc/demo.h +++ b/embedded/demo/inc/demo_manager_interface.h @@ -1,7 +1,7 @@ /** - * @file demo.h + * @file demo_manager_interface.h * - * @brief Definition of the demonstration handler. + * @brief Definition of the demonstration manager interface. * * Revised BSD License * Copyright Semtech Corporation 2020. All rights reserved. @@ -29,21 +29,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_H__ -#define __DEMO_H__ +#ifndef __DEMO_MANAGER_INTERFACE_H__ +#define __DEMO_MANAGER_INTERFACE_H__ -#include "demo_wifi_scan.h" -#include "demo_wifi_country_code.h" -#include "demo_gnss_autonomous.h" -#include "demo_gnss_assisted.h" -#include "demo_ping_pong.h" -#include "demo_tx_cw.h" -#include "demo_radio_per.h" #include -#include "lr1110_system.h" -#include "lr1110_bootloader.h" +#include "demo_transceiver_radio_ping_pong.h" +#include "demo_transceiver_radio_per.h" +#include "demo_configuration.h" +#include "demo_interface.h" +#include "antenna_selector_interface.h" #include "signaling_interface.h" +#include "environment_interface.h" #include "timer_interface.h" +#include "interruption_interface.h" typedef enum { @@ -58,12 +56,13 @@ typedef enum DEMO_TYPE_RADIO_PER_RX, } demo_type_t; -class Demo +class DemoManagerInterface { public: - Demo( DeviceTransceiver* device, EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, - SignalingInterface* signaling, TimerInterface* timer, CommunicationInterface* communication_interface ); - virtual ~Demo( ); + DemoManagerInterface( EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, + SignalingInterface* signaling, TimerInterface* timer, + CommunicationInterface* communication_interface ); + virtual ~DemoManagerInterface( ); void Init( ); @@ -80,23 +79,23 @@ class Demo void UpdateConfigAutonomousGnss( const demo_gnss_settings_t* gnss_autonomous_config ); void UpdateConfigAssistedGnss( const demo_gnss_settings_t* gnss_assisted_config ); - void Start( demo_type_t demo_type ); - void Stop( ); - void Reset( ); - bool HasIntermediateResults( ) const; + virtual void Start( demo_type_t demo_type ) = 0; + void Stop( ); + void Reset( ); + bool HasIntermediateResults( ) const; + void InterruptHandler( const InterruptionInterface* interruption ); demo_status_t Runtime( ); - demo_type_t GetType( ); - void* GetResults( ); + demo_type_t GetType( ); + virtual void* GetResults( ) = 0; - private: - DeviceTransceiver* device; + protected: EnvironmentInterface* environment; AntennaSelectorInterface* antenna_selector; SignalingInterface* signaling; TimerInterface* timer; - DemoBase* running_demo; + DemoInterface* running_demo; demo_type_t demo_type_current; demo_wifi_settings_t demo_wifi_settings; demo_wifi_settings_t demo_wifi_settings_default; @@ -111,4 +110,4 @@ class Demo CommunicationInterface* communication_interface; }; -#endif +#endif // __DEMO_MANAGER_INTERFACE_H__ diff --git a/embedded/demo/inc/demo_manager_modem.h b/embedded/demo/inc/demo_manager_modem.h new file mode 100644 index 0000000..6637dc6 --- /dev/null +++ b/embedded/demo/inc/demo_manager_modem.h @@ -0,0 +1,56 @@ +/** + * @file demo_manager_modem.h + * + * @brief Definition of the demonstration manager for a modem. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MANAGER_MODEM_H__ +#define __DEMO_MANAGER_MODEM_H__ + +#include +#include "demo_manager_interface.h" +#include "device_modem.h" +#include "signaling_interface.h" +#include "timer_interface.h" + +class DemoManagerModem : public DemoManagerInterface +{ + public: + DemoManagerModem( DeviceModem* device, EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, SignalingInterface* signaling, TimerInterface* timer, + CommunicationInterface* communication_interface ); + virtual ~DemoManagerModem( ); + + void Start( demo_type_t demo_type ) override; + void* GetResults( ) override; + + private: + DeviceModem* device; +}; + +#endif // __DEMO_MANAGER_MODEM_H__ diff --git a/embedded/demo/inc/demo_manager_transceiver.h b/embedded/demo/inc/demo_manager_transceiver.h new file mode 100644 index 0000000..2ccc875 --- /dev/null +++ b/embedded/demo/inc/demo_manager_transceiver.h @@ -0,0 +1,57 @@ +/** + * @file demo_manager_transceiver.h + * + * @brief Definition of the demonstration manager for a transceiver. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MANAGER_TRANSCEIVER_H__ +#define __DEMO_MANAGER_TRANSCEIVER_H__ + +#include +#include "demo_manager_interface.h" +#include "signaling_interface.h" +#include "timer_interface.h" +#include "lr1110_system.h" +#include "lr1110_bootloader.h" + +class DemoManagerTransceiver : public DemoManagerInterface +{ + public: + DemoManagerTransceiver( DeviceTransceiver* device, EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, SignalingInterface* signaling, + TimerInterface* timer, CommunicationInterface* communication_interface ); + virtual ~DemoManagerTransceiver( ); + + void Start( demo_type_t demo_type ) override; + void* GetResults( ) override; + + private: + DeviceTransceiver* device; +}; + +#endif // __DEMO_MANAGER_TRANSCEIVER_H__ diff --git a/embedded/demo/inc/demo_modem_gnss_assisted.h b/embedded/demo/inc/demo_modem_gnss_assisted.h new file mode 100644 index 0000000..e5e1fac --- /dev/null +++ b/embedded/demo/inc/demo_modem_gnss_assisted.h @@ -0,0 +1,52 @@ +/** + * @file demo_modem_gnss_assisted.h + * + * @brief Definition of the GNSS assisted demonstration for modem. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_GNSS_ASSISTED_H__ +#define __DEMO_MODEM_GNSS_ASSISTED_H__ + +#include "demo_modem_gnss_interface.h" +#include "demo_configuration.h" + +class DemoModemGnssAssisted : public DemoModemGnssInterface +{ + public: + DemoModemGnssAssisted( DeviceModem* device, SignalingInterface* signaling, EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, TimerInterface* timer, + CommunicationInterface* communication_interface ); + virtual ~DemoModemGnssAssisted( ); + + protected: + lr1110_modem_response_code_t CallScan( ) override; + static void GnssPositionFromEnvironment( const environment_location_t& location, + lr1110_modem_gnss_solver_assistance_position_t& gnss_position ); +}; + +#endif // __DEMO_MODEM_GNSS_ASSISTED_H__ diff --git a/embedded/demo/inc/demo_modem_gnss_autonomous.h b/embedded/demo/inc/demo_modem_gnss_autonomous.h new file mode 100644 index 0000000..dc6fdea --- /dev/null +++ b/embedded/demo/inc/demo_modem_gnss_autonomous.h @@ -0,0 +1,49 @@ +/** + * @file demo_modem_gnss_autonomous.h + * + * @brief Definition of the GNSS autonomous demonstration for modem. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_GNSS_AUTONOMOUS_H__ +#define __DEMO_MODEM_GNSS_AUTONOMOUS_H__ + +#include "demo_modem_gnss_interface.h" + +class DemoModemGnssAutonomous : public DemoModemGnssInterface +{ + public: + DemoModemGnssAutonomous( DeviceModem* device, SignalingInterface* signaling, EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, TimerInterface* timer, + CommunicationInterface* communication_interface ); + virtual ~DemoModemGnssAutonomous( ); + + protected: + lr1110_modem_response_code_t CallScan( ) override; +}; + +#endif // __DEMO_MODEM_GNSS_AUTONOMOUS_H__ diff --git a/embedded/demo/inc/demo_modem_gnss_interface.h b/embedded/demo/inc/demo_modem_gnss_interface.h new file mode 100644 index 0000000..4177109 --- /dev/null +++ b/embedded/demo/inc/demo_modem_gnss_interface.h @@ -0,0 +1,144 @@ +/** + * @file demo_modem_gnss_interface.h + * + * @brief Definition of the components shared by GNSS demonstrations. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_GNSS_INTERFACE_H__ +#define __DEMO_MODEM_GNSS_INTERFACE_H__ + +#include "demo_modem_interface.h" +#include "demo_configuration.h" +#include "environment_interface.h" +#include "antenna_selector_interface.h" +#include "timer_interface.h" +#include "demo_gnss_types.h" +#include "lr1110_modem_gnss.h" + +typedef enum +{ + DEMO_MODEM_GNSS_BASE_INIT, + DEMO_MODEM_GNSS_BASE_SCAN, + DEMO_MODEM_GNSS_BASE_WAIT_FOR_SCAN, + DEMO_MODEM_GNSS_BASE_TERMINATED, + DEMO_MODEM_GNSS_BASE_ERROR, +} demo_modem_gnss_state_t; + +class DemoModemGnssInterface : public DemoModemInterface +{ + public: + DemoModemGnssInterface( DeviceModem* device, SignalingInterface* signaling, EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, TimerInterface* timer, + CommunicationInterface* communication_interface ); + virtual ~DemoModemGnssInterface( ); + + virtual void Reset( ); + virtual void SpecificRuntime( ); + virtual void SpecificStop( ); + virtual void SpecificInterruptHandler( ); + + void Configure( demo_gnss_settings_t& config ); + const demo_gnss_all_results_t* GetResult( ) const; + + static const char* state2str( const demo_modem_gnss_state_t state ); + + protected: + void JumpToErrorState( const demo_gnss_error_t error_code ); + demo_gnss_settings_t GetSettings( ) const; + EnvironmentInterface* GetEnvironment( ); + void SetAntennaSwitch( const demo_gnss_antenna_selection_t antenna_selection ); + static bool IsResultToSolver( const demo_gnss_nav_result_t& nav_result ); + static bool IsResultToHost( const demo_gnss_nav_result_t& nav_result ); + static demo_gnss_error_t GetHostErrorFromResult( const demo_gnss_nav_result_t& nav_result ); + static bool CanFetchResults( demo_gnss_nav_result_t& nav_message ); + void FetchAndSaveResults( const uint8_t* buffer, uint16_t buffer_length ); + + static uint16_t GetAlmanacAgeFromGpsEpochInDays( const uint16_t almanac_age ); + + static lr1110_modem_gnss_search_mode_t ModemSearchModeFromDemo( const demo_gnss_search_mode_t& demo_search_mode ); + static demo_gnss_timings_t DemoTimingFromModem( const lr1110_modem_gnss_timings_t& modem_timings ); + void ConfigureEnvironmentTimeFromDevice( ); + + /*! + * \brief Check wether the almanac is too old or not + * + * \param [in] now_days Actual date in number of days elapsed since GPS + * epoch (January 6th 1980) + * + * \param [in] almanac_age_days Age of the almanac expressed in number of + * days since GPS epoch + * + * \param [in] days_limit The maximal number of days before considering the + * almanac too old + * + * \retval false The almanac is too old + * + * \retval true The almanac is not too old + */ + static bool IsAlmanacTooOld( uint16_t almanac_age_days, const uint16_t days_limit ); + + uint16_t GetAlmanacAgeDaysSinceToday( ) const; + + /*! + * \brief Check wether the almanac is too old or not + * + * Internally calls IsAlmanacTooOld and GetAlmanacAgeDaysSinceToday + * + * \param [in] days_limit The maximal number of days before considering the + * almanac too old + * + * \retval false The almanac is too old + * + * \retval true The almanac is not too old + */ + bool CheckAndStoreAlmanacAge( const uint16_t days_limit ); + + /*! + * \brief Execute scan call + * + * This method must be implemented in base class. It just needs to call + * the call scan driver function. + */ + virtual lr1110_modem_response_code_t CallScan( ) = 0; + demo_gnss_error_t ErrorCodeFromScanResponseCode( lr1110_modem_response_code_t scan_response_code ); + + void AskAndStoreLocation( void ); + TimerInterface* timer; + + private: + demo_modem_gnss_state_t state; + demo_gnss_all_results_t result; + EnvironmentInterface* environment; + demo_gnss_settings_t settings; + uint8_t inter_capture_delay_s; + uint16_t instant_start_capture_ms; + uint16_t instant_second_capture_ms; + AntennaSelectorInterface* antenna_selector; +}; + +#endif // __DEMO_MODEM_GNSS_INTERFACE_H__ diff --git a/embedded/demo/inc/demo_modem_interface.h b/embedded/demo/inc/demo_modem_interface.h new file mode 100644 index 0000000..24e8060 --- /dev/null +++ b/embedded/demo/inc/demo_modem_interface.h @@ -0,0 +1,51 @@ +/** + * @file demo_modem_base.h + * + * @brief Definition of modem demo class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_BASE_H__ +#define __DEMO_MODEM_BASE_H__ + +#include "demo_interface.h" +#include "device_modem.h" + +class DemoModemInterface : public DemoInterface +{ + public: + DemoModemInterface( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ); + + protected: + // The ClearRegisteredIrqs is redefinied here to do nothing as there is no IRQs with a modem + void ClearRegisteredIrqs( ) const final; + void SpecificInterruptHandler( const InterruptionInterface* interruption ) final; + lr1110_modem_event_fields_t last_received_event; +}; + +#endif // __DEMO_MODEM_BASE_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_radio_interface.h b/embedded/demo/inc/demo_modem_radio_converters.h similarity index 71% rename from embedded/demo/inc/demo_radio_interface.h rename to embedded/demo/inc/demo_modem_radio_converters.h index 3b5fa8b..8df32e7 100644 --- a/embedded/demo/inc/demo_radio_interface.h +++ b/embedded/demo/inc/demo_modem_radio_converters.h @@ -1,7 +1,7 @@ /** - * @file demo_radio_interface.h + * @file demo_modem_radio_converters.h * - * \brief Interface class for the definition of the radio demonstrations. + * @brief Declaration of the modem radio convertion methods. * * Revised BSD License * Copyright Semtech Corporation 2020. All rights reserved. @@ -29,25 +29,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_RADIO_INTERFACE_H__ -#define __DEMO_RADIO_INTERFACE_H__ +#ifndef __DEMO_MODEM_RADIO_CONVERTERS_H__ +#define __DEMO_MODEM_RADIO_CONVERTERS_H__ -#include -#include "demo_transceiver_base.h" -#include "demo_base.h" #include "demo_configuration.h" -class DemoRadioInterface : public DemoTransceiverBase +class DemoModemRadioConverters { public: - explicit DemoRadioInterface( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ); - virtual ~DemoRadioInterface( ); - - void Configure( demo_radio_settings_t& settings ); - - protected: - demo_radio_settings_t settings; + static bool convert_radio_setting_sf( lr1110_radio_lora_sf_t sf_setting, lr1110_modem_tst_mode_sf_t* sf_test ); + static bool convert_radio_setting_bw( lr1110_radio_lora_bw_t bw_setting, lr1110_modem_tst_mode_bw_t* bw_test ); + static bool convert_radio_setting_cr( lr1110_radio_lora_cr_t cr_setting, lr1110_modem_tst_mode_cr_t* cr_test ); }; -#endif // __DEMO_RADIO_INTERFACE_H__ +#endif // __DEMO_MODEM_RADIO_CONVERTERS_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_modem_radio_rx_continuous.h b/embedded/demo/inc/demo_modem_radio_rx_continuous.h new file mode 100644 index 0000000..874d04d --- /dev/null +++ b/embedded/demo/inc/demo_modem_radio_rx_continuous.h @@ -0,0 +1,75 @@ +/** + * @file demo_modem_radio_rx_continuous.h + * + * @brief Definition of the Continuous Packet Reception with Modem demonstration. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_RADIO_RX_CONTINUOUS_H__ +#define __DEMO_MODEM_RADIO_RX_CONTINUOUS_H__ + +#include "demo_modem_interface.h" +#include "demo_configuration.h" +#include "demo_per_results.h" + +typedef struct +{ + uint32_t frequency; + lr1110_modem_tst_mode_sf_t sf; + lr1110_modem_tst_mode_bw_t bw; + lr1110_modem_tst_mode_cr_t cr; +} demo_radio_rx_continuous_settings_t; + +typedef enum +{ + DEMO_MODEM_RADIO_RX_CONTINUOUS_STATE_INIT, + DEMO_MODEM_RADIO_RX_CONTINUOUS_STATE_RUNNING, +} demo_modem_raxdio_rx_continuous_state_t; + +class DemoModemRadioRxContinuous : public DemoModemInterface +{ + public: + DemoModemRadioRxContinuous( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ); + virtual ~DemoModemRadioRxContinuous( ); + + void SpecificRuntime( ) override; + void SpecificStop( ) override; + void Configure( demo_radio_settings_t& settings ); + bool HasIntermediateResults( ) const override; + demo_radio_per_results_t* GetResultsAndResetIntermediateFlag( ); + + protected: + static bool convert_radio_settings( const demo_radio_settings_t* radio_settings, + demo_radio_rx_continuous_settings_t* demo_radio_rx_continuous_settings ); + demo_radio_rx_continuous_settings_t settings; + demo_modem_raxdio_rx_continuous_state_t state; + bool has_intermediate_results; + demo_radio_per_results_t results; +}; + +#endif // __DEMO_MODEM_RADIO_RX_CONTINUOUS_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_modem_radio_tx_continuous.h b/embedded/demo/inc/demo_modem_radio_tx_continuous.h new file mode 100644 index 0000000..0614697 --- /dev/null +++ b/embedded/demo/inc/demo_modem_radio_tx_continuous.h @@ -0,0 +1,75 @@ +/** + * @file demo_modem_radio_tx_continuous.h + * + * @brief Definition of the Continuous Packet Transmit with Modem demonstration. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_RADIO_TX_CONTINUOUS_H__ +#define __DEMO_MODEM_RADIO_TX_CONTINUOUS_H__ + +#include "demo_modem_interface.h" +#include "demo_configuration.h" +#include "demo_per_results.h" + +typedef struct +{ + uint32_t frequency; + int8_t tx_power; + lr1110_modem_tst_mode_sf_t sf; + lr1110_modem_tst_mode_bw_t bw; + lr1110_modem_tst_mode_cr_t cr; + uint8_t payload_length; +} demo_radio_tx_continuous_settings_t; + +typedef enum +{ + DEMO_MODEM_RADIO_TX_CONTINUOUS_STATE_INIT, + DEMO_MODEM_RADIO_TX_CONTINUOUS_STATE_RUNNING, +} demo_modem_raxdio_tx_continuous_state_t; + +class DemoModemRadioTxContinuous : public DemoModemInterface +{ + public: + DemoModemRadioTxContinuous( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ); + virtual ~DemoModemRadioTxContinuous( ); + + void SpecificRuntime( ) override; + void SpecificStop( ) override; + void Configure( demo_radio_settings_t& settings ); + demo_radio_per_results_t* GetResults( ); + + protected: + static bool convert_radio_settings( const demo_radio_settings_t* radio_settings, + demo_radio_tx_continuous_settings_t* demo_radio_tx_continuous_settings ); + demo_radio_tx_continuous_settings_t settings; + demo_modem_raxdio_tx_continuous_state_t state; + demo_radio_per_results_t results; +}; + +#endif // __DEMO_MODEM_RADIO_TX_CONTINUOUS_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_modem_radio_tx_cw.h b/embedded/demo/inc/demo_modem_radio_tx_cw.h new file mode 100644 index 0000000..7b41e7c --- /dev/null +++ b/embedded/demo/inc/demo_modem_radio_tx_cw.h @@ -0,0 +1,72 @@ +/** + * @file demo_modem_radio_tx_cw.h + * + * @brief Definition of the Continuous Wave Transmit with Modem demonstration. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_RADIO_TX_CW_H__ +#define __DEMO_MODEM_RADIO_TX_CW_H__ + +#include "demo_modem_interface.h" +#include "demo_configuration.h" +#include "demo_per_results.h" + +typedef struct +{ + uint32_t frequency; + int8_t tx_power; +} demo_modem_radio_tx_cw_settings_t; + +typedef enum +{ + DEMO_MODEM_RADIO_TX_CONTINUOUS_WAVE_STATE_INIT, + DEMO_MODEM_RADIO_TX_CONTINUOUS_WAVE_STATE_RUNNING, +} demo_modem_raxdio_tx_continuous_wave_state_t; + +class DemoModemRadioTxCw : public DemoModemInterface +{ + public: + DemoModemRadioTxCw( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ); + virtual ~DemoModemRadioTxCw( ); + + void SpecificRuntime( ) override; + void SpecificStop( ) override; + void Configure( demo_radio_settings_t& settings ); + + // There is no really result from a TX CW demo. Here we'll just return dummy results + demo_radio_per_results_t* GetResults( ); + + protected: + static bool convert_radio_settings( const demo_radio_settings_t* radio_settings, + demo_modem_radio_tx_cw_settings_t* demo_radio_tx_continuous_wave_settings ); + demo_modem_raxdio_tx_continuous_wave_state_t state; + demo_modem_radio_tx_cw_settings_t settings; +}; + +#endif // __DEMO_MODEM_RADIO_TX_CW_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_modem_wifi.h b/embedded/demo/inc/demo_modem_wifi.h new file mode 100644 index 0000000..d89cb6d --- /dev/null +++ b/embedded/demo/inc/demo_modem_wifi.h @@ -0,0 +1,98 @@ +/** + * @file demo_modem_wifi.h + * + * @brief Definition of the demo modem wifi class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_MODEM_WIFI_H__ +#define __DEMO_MODEM_WIFI_H__ + +#include "demo_configuration.h" +#include "demo_modem_interface.h" +#include "lr1110_modem_system.h" +#include "lr1110_modem_wifi.h" +#include "demo_wifi_types.h" + +typedef enum +{ + DEMO_MODEM_WIFI_INIT, + DEMO_MODEM_WIFI_SCAN, + DEMO_MODEM_WIFI_WAIT_FOR_SCAN, + DEMO_MODEM_WIFI_TERMINATED, +} demo_modem_wifi_state_t; + +class DemoModemWifi : public DemoModemInterface +{ + public: + DemoModemWifi( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ); + + void Reset( ) override; + void SpecificRuntime( ) override; + void SpecificStop( ) override; + + void Configure( demo_wifi_settings_t& config ); + + const demo_wifi_scan_all_results_t* GetResult( ) const; + + protected: + virtual void ExecuteScan( radio_t* radio ); + virtual void FetchAndSaveResults( const uint8_t* buffer, uint16_t buffer_length ); + virtual void ParseAndSaveBasicCompleteResults( const uint8_t* buffer, uint16_t buffer_length ); + virtual void ParseAndSaveBasicMacChannelTypeResults( const uint8_t* buffer, uint16_t buffer_length ); + static void AddScanToResults( const lr1110_modem_system_reg_mode_t regMode, demo_wifi_scan_all_results_t& results, + const lr1110_modem_wifi_basic_complete_result_t* scan_result, + const uint8_t nbr_results ); + static void AddScanToResults( const lr1110_modem_system_reg_mode_t regMode, demo_wifi_scan_all_results_t& results, + const lr1110_modem_wifi_basic_mac_type_channel_result_t* scan_result, + const uint8_t nbr_results ); + + /*! + * \brief Compute consumption based on cumulative timings + * + * \return Consumption in micro ampere second (uas) + */ + static uint32_t ComputeConsumption( const lr1110_modem_system_reg_mode_t regMode, + const lr1110_modem_wifi_cumulative_timings_t& timing ); + demo_wifi_scan_all_results_t results; + + static lr1110_modem_wifi_result_format_t ResultFormatFromSetting( demo_wifi_result_type_t result_setting ); + static demo_wifi_timings_t demo_wifi_timing_from_modem( + const lr1110_modem_wifi_cumulative_timings_t& modem_timings ); + static lr1110_modem_wifi_mode_t modem_wifi_mode_from_demo( const demo_wifi_mode_t& demo_wifi_mode ); + static lr1110_modem_wifi_signal_type_scan_t modem_wifi_scan_type_from_demo( + const demo_wifi_signal_type_scan_t& demo_wifi_scan_type ); + static demo_wifi_signal_type_t demo_wifi_types_from_modem( + lr1110_modem_wifi_signal_type_result_t wifi_type_result ); + + private: + demo_wifi_settings_t settings; + demo_modem_wifi_state_t state; +}; + +#endif // __DEMO_MODEM_WIFI_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_per_results.h b/embedded/demo/inc/demo_per_results.h new file mode 100644 index 0000000..08a3f4e --- /dev/null +++ b/embedded/demo/inc/demo_per_results.h @@ -0,0 +1,45 @@ +/** + * @file demo_per_results.h + * + * @brief Definition of the PER result structure for demonstrations. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_PER_INTERFACE_H__ +#define __DEMO_PER_INTERFACE_H__ + +#include +typedef struct +{ + uint32_t count_rx_correct_packet; + uint32_t count_rx_wrong_packet; + uint32_t count_tx; + uint32_t count_rx_timeout; + int8_t last_rssi; +} demo_radio_per_results_t; + +#endif // __DEMO_PER_INTERFACE_H__ \ No newline at end of file diff --git a/embedded/demo/inc/demo_gnss_assisted.h b/embedded/demo/inc/demo_transceiver_gnss_assisted.h similarity index 76% rename from embedded/demo/inc/demo_gnss_assisted.h rename to embedded/demo/inc/demo_transceiver_gnss_assisted.h index 1c09648..3d354ad 100644 --- a/embedded/demo/inc/demo_gnss_assisted.h +++ b/embedded/demo/inc/demo_transceiver_gnss_assisted.h @@ -1,5 +1,5 @@ /** - * @file demo_gnss_assisted.h + * @file demo_transceiver_gnss_assisted.h * * @brief Definition of the GNSS assisted demonstration. * @@ -29,19 +29,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_GNSS_ASSISTED_H__ -#define __DEMO_GNSS_ASSISTED_H__ +#ifndef __DEMO_TRANSCEIVER_GNSS_ASSISTED_H__ +#define __DEMO_TRANSCEIVER_GNSS_ASSISTED_H__ -#include "demo_gnss_base.h" +#include "demo_transceiver_gnss_interface.h" #include "demo_configuration.h" -class DemoGnssAssisted : public DemoGnssBase +class DemoTransceiverGnssAssisted : public DemoTransceiverGnssInterface { public: - DemoGnssAssisted( DeviceTransceiver* device, SignalingInterface* signaling, EnvironmentInterface* environment, - AntennaSelectorInterface* antenna_selector, TimerInterface* timer, - CommunicationInterface* communication_interface ); - virtual ~DemoGnssAssisted( ); + DemoTransceiverGnssAssisted( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, + TimerInterface* timer, CommunicationInterface* communication_interface ); + virtual ~DemoTransceiverGnssAssisted( ); protected: virtual void CallScan( ); diff --git a/embedded/demo/inc/demo_gnss_autonomous.h b/embedded/demo/inc/demo_transceiver_gnss_autonomous.h similarity index 72% rename from embedded/demo/inc/demo_gnss_autonomous.h rename to embedded/demo/inc/demo_transceiver_gnss_autonomous.h index 18ebfc5..4675369 100644 --- a/embedded/demo/inc/demo_gnss_autonomous.h +++ b/embedded/demo/inc/demo_transceiver_gnss_autonomous.h @@ -1,5 +1,5 @@ /** - * @file demo_gnss_autonomous.h + * @file demo_transceiver_gnss_autonomous.h * * @brief Definition of the GNSS autonomous demonstration. * @@ -29,21 +29,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_GNSS_AUTONOMOUS_H__ -#define __DEMO_GNSS_AUTONOMOUS_H__ +#ifndef __DEMO_TRANSCEIVER_GNSS_AUTONOMOUS_H__ +#define __DEMO_TRANSCEIVER_GNSS_AUTONOMOUS_H__ -#include "demo_gnss_base.h" +#include "demo_transceiver_gnss_interface.h" -class DemoGnssAutonomous : public DemoGnssBase +class DemoTransceiverGnssAutonomous : public DemoTransceiverGnssInterface { public: - explicit DemoGnssAutonomous( DeviceTransceiver* device, SignalingInterface* signaling, - EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, - TimerInterface* timer, CommunicationInterface* communication_interface ); - virtual ~DemoGnssAutonomous( ); + DemoTransceiverGnssAutonomous( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, + TimerInterface* timer, CommunicationInterface* communication_interface ); + virtual ~DemoTransceiverGnssAutonomous( ); protected: virtual void CallScan( ); }; -#endif // __DEMO_GNSS_AUTONOMOUS_H__ +#endif // __DEMO_TRANSCEIVER_GNSS_AUTONOMOUS_H__ diff --git a/embedded/demo/inc/demo_gnss_base.h b/embedded/demo/inc/demo_transceiver_gnss_interface.h similarity index 80% rename from embedded/demo/inc/demo_gnss_base.h rename to embedded/demo/inc/demo_transceiver_gnss_interface.h index 6160a96..799ad88 100644 --- a/embedded/demo/inc/demo_gnss_base.h +++ b/embedded/demo/inc/demo_transceiver_gnss_interface.h @@ -1,5 +1,5 @@ /** - * @file demo_gnss_base.h + * @file demo_transceiver_gnss_interface.h * * @brief Definition of the components shared by GNSS demonstrations. * @@ -29,15 +29,16 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_GNSS_BASE_H__ -#define __DEMO_GNSS_BASE_H__ +#ifndef __DEMO_TRANSCEIVER_GNSS_INTERFACE_H__ +#define __DEMO_TRANSCEIVER_GNSS_INTERFACE_H__ -#include "demo_transceiver_base.h" +#include "demo_transceiver_interface.h" #include "demo_configuration.h" #include "environment_interface.h" #include "antenna_selector_interface.h" #include "timer_interface.h" #include "demo_gnss_types.h" +#include "lr1110_gnss_types.h" typedef enum { @@ -51,18 +52,17 @@ typedef enum DEMO_GNSS_BASE_ERROR, } demo_gnss_state_t; -class DemoGnssBase : public DemoTransceiverBase +class DemoTransceiverGnssInterface : public DemoTransceiverInterface { public: - DemoGnssBase( DeviceTransceiver* device, SignalingInterface* signaling, EnvironmentInterface* environment, - AntennaSelectorInterface* antenna_selector, TimerInterface* timer, - CommunicationInterface* communication_interface ); - virtual ~DemoGnssBase( ); + DemoTransceiverGnssInterface( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, + TimerInterface* timer, CommunicationInterface* communication_interface ); + virtual ~DemoTransceiverGnssInterface( ); - virtual void Reset( ); - virtual void SpecificRuntime( ); - virtual void SpecificStop( ); - virtual void SpecificInterruptHandler( ); + void Reset( ) override; + void SpecificRuntime( ) override; + void SpecificStop( ) override; void Configure( demo_gnss_settings_t& config ); const demo_gnss_all_results_t* GetResult( ) const; @@ -70,7 +70,7 @@ class DemoGnssBase : public DemoTransceiverBase static const char* state2str( const demo_gnss_state_t state ); protected: - virtual void ClearRegisteredIrqs( ) const; + void ClearRegisteredIrqs( ) const override; void JumpToErrorState( const demo_gnss_error_t error_code ); demo_gnss_settings_t GetSettings( ) const; @@ -83,6 +83,10 @@ class DemoGnssBase : public DemoTransceiverBase static uint16_t GetAlmanacAgeFromGpsEpochInDays( const uint16_t almanac_age ); + static lr1110_gnss_search_mode_t TransceiverSearchModeFromDemo( const demo_gnss_search_mode_t& demo_search_mode ); + static lr1110_gnss_scan_mode_t TransceiverScanModeFromDemo( const demo_gnss_scan_mode_t& demo_scan_mode ); + static demo_gnss_timings_t DemoTimingFromTransceiver( const lr1110_gnss_timings_s& transceiver_timings ); + /*! * \brief Check wether the almanac is too old or not * @@ -133,7 +137,6 @@ class DemoGnssBase : public DemoTransceiverBase uint32_t gnss_irq; demo_gnss_state_t state; demo_gnss_all_results_t result; - EnvironmentInterface* environment; demo_gnss_settings_t settings; uint8_t inter_capture_delay_s; uint16_t instant_start_capture_ms; @@ -141,4 +144,4 @@ class DemoGnssBase : public DemoTransceiverBase AntennaSelectorInterface* antenna_selector; }; -#endif // __DEMO_GNSS_BASE_H__ +#endif // __DEMO_TRANSCEIVER_GNSS_INTERFACE_H__ diff --git a/embedded/demo/inc/demo_transceiver_interface.h b/embedded/demo/inc/demo_transceiver_interface.h new file mode 100644 index 0000000..a28dfe4 --- /dev/null +++ b/embedded/demo/inc/demo_transceiver_interface.h @@ -0,0 +1,55 @@ +/** + * @file demo_transceiver_interface.h + * + * @brief Definition of transceiver device class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_TRANSCEIVER_INTERFACE_H__ +#define __DEMO_TRANSCEIVER_INTERFACE_H__ + +#include "demo_interface.h" +#include "device_transceiver.h" +#include "lr1110_system.h" +#include "environment_interface.h" + +class DemoTransceiverInterface : public DemoInterface +{ + public: + DemoTransceiverInterface( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, EnvironmentInterface* environment ); + + void SpecificInterruptHandler( const InterruptionInterface* interruption ) final; + + protected: + EnvironmentInterface* environment; + lr1110_system_irq_mask_t last_received_irq_mask; + lr1110_system_stat1_t last_received_stat_1; + uint32_t last_irq_received_instant_ms; +}; + +#endif // __DEMO_TRANSCEIVER_INTERFACE_H__ diff --git a/embedded/demo/inc/demo_transceiver_radio_interface.h b/embedded/demo/inc/demo_transceiver_radio_interface.h new file mode 100644 index 0000000..37f3e97 --- /dev/null +++ b/embedded/demo/inc/demo_transceiver_radio_interface.h @@ -0,0 +1,54 @@ +/** + * @file demo_transceiver_radio_interface.h + * + * @brief Interface class for the definition of the radio demonstrations. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEMO_TRANSCEIVER_RADIO_INTERFACE_H__ +#define __DEMO_TRANSCEIVER_RADIO_INTERFACE_H__ + +#include +#include "demo_transceiver_interface.h" +#include "demo_interface.h" +#include "demo_configuration.h" + +class DemoTransceiverRadioInterface : public DemoTransceiverInterface +{ + public: + explicit DemoTransceiverRadioInterface( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ); + virtual ~DemoTransceiverRadioInterface( ); + + void Configure( demo_radio_settings_t& settings ); + + protected: + demo_radio_settings_t settings; +}; + +#endif // __DEMO_TRANSCEIVER_RADIO_INTERFACE_H__ diff --git a/embedded/demo/inc/demo_radio_per.h b/embedded/demo/inc/demo_transceiver_radio_per.h similarity index 74% rename from embedded/demo/inc/demo_radio_per.h rename to embedded/demo/inc/demo_transceiver_radio_per.h index a41cee7..9ee4458 100644 --- a/embedded/demo/inc/demo_radio_per.h +++ b/embedded/demo/inc/demo_transceiver_radio_per.h @@ -1,5 +1,5 @@ /** - * @file demo_radio_per.h + * @file demo_transceiver_radio_per.h * * @brief Definition of Packet Error Rate demo. * @@ -29,13 +29,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_RADIO_PER_H__ -#define __DEMO_RADIO_PER_H__ +#ifndef __DEMO_TRANSCEIVER_RADIO_PER_H__ +#define __DEMO_TRANSCEIVER_RADIO_PER_H__ #include "demo_configuration.h" -#include "demo_radio_interface.h" +#include "demo_transceiver_radio_interface.h" #include "configuration.h" #include "environment_interface.h" +#include "demo_per_results.h" typedef enum { @@ -53,34 +54,24 @@ typedef enum DEMO_RADIO_PER_MODE_RX, } demo_radio_per_mode_t; -typedef struct -{ - uint32_t count_rx_correct_packet; - uint32_t count_rx_wrong_packet; - uint32_t count_tx; - uint32_t count_rx_timeout; - int8_t last_rssi; -} demo_radio_per_results_t; - -class DemoRadioPer : public DemoRadioInterface +class DemoTransceiverRadioPer : public DemoTransceiverRadioInterface { public: - DemoRadioPer( DeviceTransceiver* device, SignalingInterface* signaling, EnvironmentInterface* environment, - CommunicationInterface* communication_interface, demo_radio_per_mode_t mode ); - virtual ~DemoRadioPer( ); + DemoTransceiverRadioPer( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, CommunicationInterface* communication_interface, + demo_radio_per_mode_t mode ); + virtual ~DemoTransceiverRadioPer( ); - bool HasIntermediateResults( ) const; + bool HasIntermediateResults( ) const override; const demo_radio_per_results_t* GetResult( ) const; protected: - virtual void SpecificRuntime( ); - virtual void SpecificStop( ); - virtual void SpecificInterruptHandler( ); - void LogInfo( ) const; - void ClearRegisteredIrqs( ) const; + void SpecificRuntime( ) override; + void SpecificStop( ) override; + void LogInfo( ) const; + void ClearRegisteredIrqs( ) const override; private: - EnvironmentInterface* environment; demo_radio_per_state_t state; demo_radio_per_results_t results; uint8_t buffer[255]; @@ -90,4 +81,4 @@ class DemoRadioPer : public DemoRadioInterface demo_radio_per_mode_t mode; }; -#endif // __DEMO_RADIO_PER_H__ +#endif // __DEMO_TRANSCEIVER_RADIO_PER_H__ diff --git a/embedded/demo/inc/demo_ping_pong.h b/embedded/demo/inc/demo_transceiver_radio_ping_pong.h similarity index 81% rename from embedded/demo/inc/demo_ping_pong.h rename to embedded/demo/inc/demo_transceiver_radio_ping_pong.h index 8972ff5..5532d8d 100644 --- a/embedded/demo/inc/demo_ping_pong.h +++ b/embedded/demo/inc/demo_transceiver_radio_ping_pong.h @@ -1,5 +1,5 @@ /** - * @file demo_ping_pong.h + * @file demo_transceiver_radio_ping_pong.h * * @brief Definition of Ping-Pong demo. * @@ -29,10 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_PING_PONG_H__ -#define __DEMO_PING_PONG_H__ +#ifndef __DEMO_TRANSCEIVER_RADIO_PING_PONG_H__ +#define __DEMO_TRANSCEIVER_RADIO_PING_PONG_H__ -#include "demo_radio_interface.h" +#include "demo_transceiver_radio_interface.h" #include "demo_configuration.h" #include "configuration.h" #include "environment_interface.h" @@ -92,21 +92,20 @@ typedef struct int8_t last_rssi; } demo_ping_pong_results_t; -class DemoPingPong : public DemoRadioInterface +class DemoTransceiverRadioPingPong : public DemoTransceiverRadioInterface { public: - DemoPingPong( DeviceTransceiver* device, SignalingInterface* signaling, EnvironmentInterface* environment, - CommunicationInterface* communication_interface ); - virtual ~DemoPingPong( ); + DemoTransceiverRadioPingPong( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, CommunicationInterface* communication_interface ); + virtual ~DemoTransceiverRadioPingPong( ); const demo_ping_pong_results_t* GetResult( ) const; protected: - virtual void SpecificRuntime( ); - virtual void SpecificStop( ); - virtual void SpecificInterruptHandler( ); - virtual void ClearRegisteredIrqs( ) const; - void LogInfo( ) const; + void SpecificRuntime( ) override; + void SpecificStop( ) override; + void ClearRegisteredIrqs( ) const override; + void LogInfo( ) const; demo_ping_pong_status_t ConfigureRadio( ) const; void StartSendMessage( ) const; @@ -116,9 +115,9 @@ class DemoPingPong : public DemoRadioInterface void FetchStatisticToResults( ); bool IsPongPayload( const demo_ping_pong_rf_payload_t& payload ) const; bool IsPingPayload( const demo_ping_pong_rf_payload_t& payload ) const; - bool HasIntermediateResults( ) const; + bool HasIntermediateResults( ) const override; - static void TransmitPayload( const void* radio, const uint8_t* payload, const uint8_t payload_size, + static void TransmitPayload( const void* radio, const demo_ping_pong_rf_payload_t* payload, const uint32_t timeout ); static bool ArePayloadEquals( const demo_ping_pong_rf_payload_t& expected, @@ -127,18 +126,16 @@ class DemoPingPong : public DemoRadioInterface static const char* ModeToString( const demo_ping_pong_mode_t mode ); private: - EnvironmentInterface* environment; demo_ping_pong_mode_t mode; demo_ping_pong_state_t state; - volatile uint32_t last_irq_received_instant_ms; uint32_t last_tx_done_instant_ms; uint32_t last_rx_done_instant_ms; demo_ping_pong_results_t results; - uint8_t payload_ping[DEMO_PING_PONG_MAX_PAYLOAD_SIZE]; - uint8_t payload_pong[DEMO_PING_PONG_MAX_PAYLOAD_SIZE]; + demo_ping_pong_rf_payload_t payload_ping; + demo_ping_pong_rf_payload_t payload_pong; demo_ping_pong_fetched_payload_t received_payload; uint32_t radio_interrupt_mask; bool has_intermediate_results; }; -#endif // __DEMO_PING_PONG_H__ +#endif // __DEMO_TRANSCEIVER_RADIO_PING_PONG_H__ diff --git a/embedded/demo/inc/demo_tx_cw.h b/embedded/demo/inc/demo_transceiver_radio_tx_cw.h similarity index 75% rename from embedded/demo/inc/demo_tx_cw.h rename to embedded/demo/inc/demo_transceiver_radio_tx_cw.h index 1b6a81d..99d4006 100644 --- a/embedded/demo/inc/demo_tx_cw.h +++ b/embedded/demo/inc/demo_transceiver_radio_tx_cw.h @@ -1,5 +1,5 @@ /** - * @file demo_tx_cw.h + * @file demo_transceiver_radio_tx_cw.h * * @brief Definition of Continuous Wave Transmit demo. * @@ -29,11 +29,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_TX_CW_H__ -#define __DEMO_TX_CW_H__ +#ifndef __DEMO_TRANSCEIVER_RADIO_TX_CW_H__ +#define __DEMO_TRANSCEIVER_RADIO_TX_CW_H__ #include "demo_configuration.h" -#include "demo_radio_interface.h" +#include "demo_transceiver_radio_interface.h" typedef enum { @@ -41,18 +41,17 @@ typedef enum DEMO_TX_CW_STATE_RUNNING, } demo_tx_cw_state_t; -class DemoTxCw : public DemoRadioInterface +class DemoTransceiverRadioTxCw : public DemoTransceiverRadioInterface { public: - DemoTxCw( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ); - virtual ~DemoTxCw( ); + DemoTransceiverRadioTxCw( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, EnvironmentInterface* environment ); + virtual ~DemoTransceiverRadioTxCw( ); protected: - virtual void SpecificRuntime( ); - virtual void SpecificStop( ); - virtual void SpecificInterruptHandler( ); - virtual void ClearRegisteredIrqs( ) const; + void SpecificRuntime( ) override; + void SpecificStop( ) override; + void ClearRegisteredIrqs( ) const override; void ConfigureRadio( ) const; void StartSendMessage( ) const; @@ -62,4 +61,4 @@ class DemoTxCw : public DemoRadioInterface demo_tx_cw_state_t state; }; -#endif // __DEMO_TX_CW_H__ +#endif // __DEMO_TRANSCEIVER_RADIO_TX_CW_H__ diff --git a/embedded/demo/inc/demo_wifi_country_code.h b/embedded/demo/inc/demo_transceiver_wifi_country_code.h similarity index 78% rename from embedded/demo/inc/demo_wifi_country_code.h rename to embedded/demo/inc/demo_transceiver_wifi_country_code.h index 41f2dbf..beca242 100644 --- a/embedded/demo/inc/demo_wifi_country_code.h +++ b/embedded/demo/inc/demo_transceiver_wifi_country_code.h @@ -1,5 +1,5 @@ /** - * @file demo_wifi_country_code.h + * @file demo_transceiver_wifi_country_code.h * * @brief Definition of Wi-Fi country code scan demo. * @@ -29,18 +29,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_WIFI_COUNTRY_CODE_H__ -#define __DEMO_WIFI_COUNTRY_CODE_H__ +#ifndef __DEMO_TRANSCEIVER_WIFI_COUNTRY_CODE_H__ +#define __DEMO_TRANSCEIVER_WIFI_COUNTRY_CODE_H__ -#include "demo_wifi_interface.h" +#include "demo_transceiver_wifi_interface.h" #include "demo_configuration.h" -class DemoWifiCountryCode : public DemoWifiInterface +class DemoTransceiverWifiCountryCode : public DemoTransceiverWifiInterface { public: - DemoWifiCountryCode( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ); - virtual ~DemoWifiCountryCode( ); + DemoTransceiverWifiCountryCode( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ); + virtual ~DemoTransceiverWifiCountryCode( ); void Configure( demo_wifi_country_code_settings_t& config ); @@ -55,4 +56,4 @@ class DemoWifiCountryCode : public DemoWifiInterface demo_wifi_country_code_settings_t settings; }; -#endif // __DEMO_WIFI_COUNTRY_CODE_H__ \ No newline at end of file +#endif // __DEMO_TRANSCEIVER_WIFI_COUNTRY_CODE_H__ diff --git a/embedded/demo/inc/demo_wifi_interface.h b/embedded/demo/inc/demo_transceiver_wifi_interface.h similarity index 65% rename from embedded/demo/inc/demo_wifi_interface.h rename to embedded/demo/inc/demo_transceiver_wifi_interface.h index 5c419bd..c0118b6 100644 --- a/embedded/demo/inc/demo_wifi_interface.h +++ b/embedded/demo/inc/demo_transceiver_wifi_interface.h @@ -1,7 +1,7 @@ /** - * @file demo_wifi_interface.h + * @file demo_transceiver_wifi_interface.h * - * \brief Interface class for the definition of the Wi-Fi demonstrations. + * @brief Interface class for the definition of the Wi-Fi demonstrations. * * Revised BSD License * Copyright Semtech Corporation 2020. All rights reserved. @@ -29,12 +29,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_WIFI_INTERFACE_H__ -#define __DEMO_WIFI_INTERFACE_H__ +#ifndef __DEMO_TRANSCEIVER_WIFI_INTERFACE_H__ +#define __DEMO_TRANSCEIVER_WIFI_INTERFACE_H__ -#include "demo_transceiver_base.h" +#include "demo_transceiver_interface.h" #include -#include "demo_base.h" +#include "demo_interface.h" #include "lr1110_wifi_types.h" #include "demo_wifi_types.h" @@ -47,27 +47,32 @@ typedef enum DEMO_WIFI_TERMINATED, } demo_wifi_state_t; -class DemoWifiInterface : public DemoTransceiverBase +class DemoTransceiverWifiInterface : public DemoTransceiverInterface { public: - explicit DemoWifiInterface( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ); - virtual ~DemoWifiInterface( ); + explicit DemoTransceiverWifiInterface( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ); + virtual ~DemoTransceiverWifiInterface( ); - virtual void Reset( ); - virtual void SpecificRuntime( ); - virtual void SpecificStop( ); - virtual void SpecificInterruptHandler( ); + void Reset( ) override; + void SpecificRuntime( ) override; + void SpecificStop( ) override; const demo_wifi_scan_all_results_t* GetResult( ) const; static const char* state2str( const demo_wifi_state_t state ); protected: - virtual void ClearRegisteredIrqs( ) const; + void ClearRegisteredIrqs( ) const override; virtual void ExecuteScan( radio_t* radio ) = 0; virtual void FetchAndSaveResults( radio_t* radio ) = 0; + static demo_wifi_timings_t demo_wifi_timing_from_transceiver( + const lr1110_wifi_cumulative_timings_t& transceiver_timings ); + static demo_wifi_signal_type_t demo_wifi_types_from_transceiver( + lr1110_wifi_signal_type_result_t wifi_type_result ); + /*! * \brief Compute consumption based on cumulative timings * @@ -77,9 +82,13 @@ class DemoWifiInterface : public DemoTransceiverBase const lr1110_wifi_cumulative_timings_t& timing ); demo_wifi_scan_all_results_t results; + static lr1110_wifi_mode_t transceiver_wifi_mode_from_demo( const demo_wifi_mode_t& demo_wifi_mode ); + static lr1110_wifi_signal_type_scan_t transceiver_wifi_scan_type_from_demo( + const demo_wifi_signal_type_scan_t& demo_wifi_scan_type ); + private: demo_wifi_state_t state; uint32_t wifi_irq; }; -#endif // __DEMO_WIFI_INTERFACE_H__ +#endif // __DEMO_TRANSCEIVER_WIFI_INTERFACE_H__ diff --git a/embedded/demo/inc/demo_wifi_scan.h b/embedded/demo/inc/demo_transceiver_wifi_scan.h similarity index 83% rename from embedded/demo/inc/demo_wifi_scan.h rename to embedded/demo/inc/demo_transceiver_wifi_scan.h index 64fd738..f2d8f57 100644 --- a/embedded/demo/inc/demo_wifi_scan.h +++ b/embedded/demo/inc/demo_transceiver_wifi_scan.h @@ -1,5 +1,5 @@ /** - * @file demo_wifi_scan.h + * @file demo_transceiver_wifi_scan.h * * @brief Definition of Wi-Fi MAC address scan demo. * @@ -29,18 +29,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_WIFI_SCAN_H__ -#define __DEMO_WIFI_SCAN_H__ +#ifndef __DEMO_TRANSCEIVER_WIFI_SCAN_H__ +#define __DEMO_TRANSCEIVER_WIFI_SCAN_H__ #include "demo_configuration.h" -#include "demo_wifi_interface.h" +#include "demo_transceiver_wifi_interface.h" -class DemoWifiScan : public DemoWifiInterface +class DemoTransceiverWifiScan : public DemoTransceiverWifiInterface { public: - DemoWifiScan( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ); - virtual ~DemoWifiScan( ); + DemoTransceiverWifiScan( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, EnvironmentInterface* environment ); + virtual ~DemoTransceiverWifiScan( ); void Configure( demo_wifi_settings_t& config ); @@ -59,4 +59,4 @@ class DemoWifiScan : public DemoWifiInterface demo_wifi_settings_t settings; }; -#endif //__DEMO_WIFI_SCAN_H__ \ No newline at end of file +#endif //__DEMO_TRANSCEIVER_WIFI_SCAN_H__ diff --git a/embedded/demo/inc/demo_wifi_types.h b/embedded/demo/inc/demo_wifi_types.h index 86ebb4a..3dabab5 100644 --- a/embedded/demo/inc/demo_wifi_types.h +++ b/embedded/demo/inc/demo_wifi_types.h @@ -1,22 +1,14 @@ #ifndef __DEMO_WIFI_TYPES_H__ #define __DEMO_WIFI_TYPES_H__ -#include "lr1110_wifi_types.h" +#include -#define DEMO_WIFI_MAX_RESULT_TOTAL 32 +#define DEMO_WIFI_STR_COUNTRY_CODE_SIZE ( 2 ) +#define DEMO_WIFI_MAX_RESULT_TOTAL ( 32 ) #define DEMO_TYPE_WIFI_MAC_ADDRESS_LENGTH ( 6 ) typedef struct DemoWifiTimings { - DemoWifiTimings( ) : rx_detection_us( 0 ), rx_correlation_us( 0 ), rx_capture_us( 0 ), demodulation_us( 0 ) {} - DemoWifiTimings( const lr1110_wifi_cumulative_timings_t& transceiver_timings ) - : rx_detection_us( transceiver_timings.rx_detection_us ), - rx_correlation_us( transceiver_timings.rx_correlation_us ), - rx_capture_us( transceiver_timings.rx_capture_us ), - demodulation_us( transceiver_timings.demodulation_us ) - { - } - uint32_t rx_detection_us; uint32_t rx_correlation_us; uint32_t rx_capture_us; @@ -32,15 +24,13 @@ typedef enum DEMO_WIFI_TYPE_N, //!< WiFi N } demo_wifi_signal_type_t; -demo_wifi_signal_type_t demo_wifi_types_from_transceiver( lr1110_wifi_signal_type_result_t wifi_type_result ); - typedef struct { demo_wifi_mac_address_t mac_address; demo_wifi_channel_t channel; demo_wifi_signal_type_t type; int8_t rssi; - uint8_t country_code[LR1110_WIFI_STR_COUNTRY_CODE_SIZE]; + uint8_t country_code[DEMO_WIFI_STR_COUNTRY_CODE_SIZE]; } demo_wifi_scan_single_result_t; typedef struct @@ -52,4 +42,46 @@ typedef struct bool error; } demo_wifi_scan_all_results_t; +typedef enum +{ + DEMO_WIFI_RESULT_TYPE_BASIC_COMPLETE, + DEMO_WIFI_RESULT_TYPE_BASIC_MAC_TYPE_CHANNEL, +} demo_wifi_result_type_t; + +typedef uint16_t demo_wifi_channel_mask_t; + +typedef enum +{ + DEMO_WIFI_SETTING_TYPE_B, + DEMO_WIFI_SETTING_TYPE_G, + DEMO_WIFI_SETTING_TYPE_N, + DEMO_WIFI_SETTING_TYPE_B_G_N, +} demo_wifi_signal_type_scan_t; + +typedef enum +{ + DEMO_WIFI_SCAN_MODE_BEACON, + DEMO_WIFI_SCAN_MODE_BEACON_AND_PACKET, +} demo_wifi_mode_t; + +typedef struct +{ + demo_wifi_channel_mask_t channels; + demo_wifi_signal_type_scan_t types; + demo_wifi_mode_t scan_mode; + uint8_t nbr_retrials; + uint8_t max_results; + uint16_t timeout; + demo_wifi_result_type_t result_type; +} demo_wifi_settings_t; + +typedef struct +{ + demo_wifi_channel_mask_t channels; + uint8_t nbr_retrials; + uint8_t max_results; + uint32_t timeout; + bool does_abort_on_timeout; +} demo_wifi_country_code_settings_t; + #endif // __DEMO_WIFI_TYPES_H__ \ No newline at end of file diff --git a/embedded/demo/src/demo_transceiver_base.cpp b/embedded/demo/inc/interruption_interface.h similarity index 79% rename from embedded/demo/src/demo_transceiver_base.cpp rename to embedded/demo/inc/interruption_interface.h index 5f79dbd..0a91e94 100644 --- a/embedded/demo/src/demo_transceiver_base.cpp +++ b/embedded/demo/inc/interruption_interface.h @@ -1,7 +1,7 @@ /** - * @file demo_transceiver_base.cpp + * @file interruption_interface.h * - * @brief Implementation of transceiver demo class. + * @brief Definition of the interruption interface class. * * Revised BSD License * Copyright Semtech Corporation 2020. All rights reserved. @@ -29,10 +29,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_transceiver_base.h" +#ifndef __INTERRUPTION_INTERFACE_H__ +#define __INTERRUPTION_INTERFACE_H__ -DemoTransceiverBase::DemoTransceiverBase( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ) - : DemoBase( device, signaling, communication_interface ) +class InterruptionInterface { -} \ No newline at end of file + public: + virtual bool is_wifi_interruption( ) const = 0; + virtual bool is_gnss_interruption( ) const = 0; + virtual bool is_radio_interruption( ) const = 0; +}; + +#endif // __INTERRUPTION_INTERFACE_H__ \ No newline at end of file diff --git a/embedded/demo/inc/interruption_irq.h b/embedded/demo/inc/interruption_irq.h new file mode 100644 index 0000000..77f467c --- /dev/null +++ b/embedded/demo/inc/interruption_irq.h @@ -0,0 +1,61 @@ +/** + * @file interruption_irq.h + * + * @brief Definition of the interruption for transceiver class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INTERRUPTION_IRQ_H__ +#define __INTERRUPTION_IRQ_H__ + +#include "interruption_interface.h" +#include "lr1110_system.h" + +class InterruptionIrq : public InterruptionInterface +{ + public: + InterruptionIrq( ); + virtual ~InterruptionIrq( ); + bool is_wifi_interruption( ) const override; + bool is_gnss_interruption( ) const override; + bool is_radio_interruption( ) const override; + + lr1110_system_irq_mask_t get_irq_mask( ) const; + lr1110_system_stat1_t get_stat_1( ) const; + lr1110_system_stat2_t get_stat_2( ) const; + + void set_irq_mask( uint32_t irq_mask ); + void set_stat_1( lr1110_system_stat1_t stat_1 ); + void set_stat_2( lr1110_system_stat2_t stat_2 ); + + private: + uint32_t irq_mask; + lr1110_system_stat1_t stat_1; + lr1110_system_stat2_t stat_2; +}; + +#endif // __INTERRUPTION_IRQ_H__ \ No newline at end of file diff --git a/embedded/demo/inc/interruption_modem.h b/embedded/demo/inc/interruption_modem.h new file mode 100644 index 0000000..4273fe2 --- /dev/null +++ b/embedded/demo/inc/interruption_modem.h @@ -0,0 +1,22 @@ +#ifndef __INTERRUPTION_MODEM_H__ +#define __INTERRUPTION_MODEM_H__ + +#include "interruption_interface.h" +#include "lr1110_modem_lorawan.h" + +class InterruptionModem : public InterruptionInterface +{ + public: + InterruptionModem( ); + bool is_wifi_interruption( ) const override; + bool is_gnss_interruption( ) const override; + bool is_radio_interruption( ) const override; + + lr1110_modem_event_fields_t GetEvent( ) const; + void SetEvent( const lr1110_modem_event_fields_t& _event ); + + private: + lr1110_modem_event_fields_t event; +}; + +#endif // __INTERRUPTION_MODEM_H__ \ No newline at end of file diff --git a/embedded/demo/src/demo_base.cpp b/embedded/demo/src/demo_interface.cpp similarity index 62% rename from embedded/demo/src/demo_base.cpp rename to embedded/demo/src/demo_interface.cpp index 4bbffff..a4a1604 100644 --- a/embedded/demo/src/demo_base.cpp +++ b/embedded/demo/src/demo_interface.cpp @@ -29,63 +29,53 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_base.h" +#include "demo_interface.h" -#ifdef __cplusplus -extern "C" { -#endif -extern void DemoBaseInterruptHandler( void ) { DemoBase::InterruptHandler( ); } -#ifdef __cplusplus -} -#endif - -volatile bool DemoBase::has_received_interrupt = false; -bool DemoBase::is_initialized = false; -DemoBase* DemoBase::running_demo = nullptr; +volatile bool DemoInterface::has_received_interrupt = false; +bool DemoInterface::is_initialized = false; -DemoBase::DemoBase( DeviceBase* device, SignalingInterface* signaling, CommunicationInterface* communication_interface ) +DemoInterface::DemoInterface( DeviceInterface* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ) : device( device ), signaling( signaling ), + communication_interface( communication_interface ), is_waiting_for_interrupt( false ), - status( DEMO_STATUS_SKIPPED ), - communication_interface( communication_interface ) + status( DEMO_STATUS_SKIPPED ) { } -void DemoBase::ResetAndInitLr1110( ) { this->device->ResetAndInit( ); } +void DemoInterface::ResetAndInitLr1110( ) { this->device->Init( ); } -bool DemoBase::HasIntermediateResults( ) const { return false; } +bool DemoInterface::HasIntermediateResults( ) const { return false; } -DemoBase::~DemoBase( ) {} +DemoInterface::~DemoInterface( ) {} -void DemoBase::Initialize( ) +void DemoInterface::Initialize( ) { if( is_initialized == false ) { - DemoBase::ResetAndInitLr1110( ); + DemoInterface::ResetAndInitLr1110( ); is_initialized = true; } } -demo_status_t DemoBase::GetStatus( ) const { return this->status; } +demo_status_t DemoInterface::GetStatus( ) const { return this->status; } -void DemoBase::Start( ) +void DemoInterface::Start( ) { this->Reset( ); - this->status = DEMO_STATUS_RUNNING; - DemoBase::running_demo = this; + this->status = DEMO_STATUS_RUNNING; } -void DemoBase::Stop( ) +void DemoInterface::Stop( ) { this->status = DEMO_STATUS_STOPPED; this->SpecificStop( ); - DemoBase::running_demo = nullptr; } -bool DemoBase::IsStarted( ) const { return this->status == DEMO_STATUS_RUNNING; } +bool DemoInterface::IsStarted( ) const { return this->status == DEMO_STATUS_RUNNING; } -demo_status_t DemoBase::Runtime( ) +demo_status_t DemoInterface::Runtime( ) { this->is_waiting_for_interrupt = false; if( this->IsStarted( ) ) @@ -95,20 +85,17 @@ demo_status_t DemoBase::Runtime( ) return this->status; } -void DemoBase::InterruptHandler( ) +void DemoInterface::InterruptHandler( const InterruptionInterface* interruption ) { - if( running_demo ) - { - running_demo->SpecificInterruptHandler( ); - } + this->SpecificInterruptHandler( interruption ); has_received_interrupt = true; } -void DemoBase::SetWaitingForInterrupt( ) { this->is_waiting_for_interrupt = true; } +void DemoInterface::SetWaitingForInterrupt( ) { this->is_waiting_for_interrupt = true; } -bool DemoBase::IsWaitingForInterrupt( ) const { return this->is_waiting_for_interrupt; } +bool DemoInterface::IsWaitingForInterrupt( ) const { return this->is_waiting_for_interrupt; } -bool DemoBase::InterruptHasRaised( ) +bool DemoInterface::InterruptHasRaised( ) { __disable_irq( ); bool interrupt_flag = this->has_received_interrupt; @@ -117,7 +104,7 @@ bool DemoBase::InterruptHasRaised( ) return interrupt_flag; } -void DemoBase::Reset( ) +void DemoInterface::Reset( ) { this->is_waiting_for_interrupt = false; if( this->has_received_interrupt ) @@ -128,4 +115,4 @@ void DemoBase::Reset( ) this->status = DEMO_STATUS_SKIPPED; } -void DemoBase::Terminate( ) { this->status = DEMO_STATUS_TERMINATED; } +void DemoInterface::Terminate( ) { this->status = DEMO_STATUS_TERMINATED; } diff --git a/embedded/demo/src/demo.cpp b/embedded/demo/src/demo_manager_interface.cpp similarity index 65% rename from embedded/demo/src/demo.cpp rename to embedded/demo/src/demo_manager_interface.cpp index 0b565a2..1848e1a 100644 --- a/embedded/demo/src/demo.cpp +++ b/embedded/demo/src/demo_manager_interface.cpp @@ -1,7 +1,7 @@ /** * @file demo.cpp * - * @brief Implementation of the demonstration handler. + * @brief Implementation of the demonstration manager interface. * * Revised BSD License * Copyright Semtech Corporation 2020. All rights reserved. @@ -29,12 +29,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo.h" +#include "demo_manager_interface.h" -Demo::Demo( DeviceTransceiver* device, EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, - SignalingInterface* signaling, TimerInterface* timer, CommunicationInterface* communication_interface ) - : device( device ), - environment( environment ), +DemoManagerInterface::DemoManagerInterface( EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, SignalingInterface* signaling, + TimerInterface* timer, CommunicationInterface* communication_interface ) + : environment( environment ), antenna_selector( antenna_selector ), signaling( signaling ), timer( timer ), @@ -99,9 +99,9 @@ Demo::Demo( DeviceTransceiver* device, EnvironmentInterface* environment, Antenn this->demo_radio_settings_default.packet_gfsk.sync_word_len_in_bits = DEMO_RADIO_GFSK_SW_LENGTH_DEFAULT; } -Demo::~Demo( ) {} +DemoManagerInterface::~DemoManagerInterface( ) {} -void Demo::Init( ) +void DemoManagerInterface::Init( ) { this->SetConfigToDefault( DEMO_TYPE_WIFI ); this->SetConfigToDefault( DEMO_TYPE_WIFI_COUNTRY_CODE ); @@ -113,7 +113,7 @@ void Demo::Init( ) this->SetConfigToDefault( DEMO_TYPE_TX_CW ); } -void Demo::SetConfigToDefault( demo_type_t demo_type ) +void DemoManagerInterface::SetConfigToDefault( demo_type_t demo_type ) { switch( demo_type ) { @@ -154,7 +154,7 @@ void Demo::SetConfigToDefault( demo_type_t demo_type ) } } -void Demo::GetConfigDefault( demo_all_settings_t* settings ) +void DemoManagerInterface::GetConfigDefault( demo_all_settings_t* settings ) { settings->wifi_settings = this->demo_wifi_settings_default; settings->wifi_country_code_settings = this->demo_wifi_country_code_settings_default; @@ -163,7 +163,7 @@ void Demo::GetConfigDefault( demo_all_settings_t* settings ) settings->radio_settings = this->demo_radio_settings_default; } -void Demo::GetConfig( demo_all_settings_t* settings ) +void DemoManagerInterface::GetConfig( demo_all_settings_t* settings ) { settings->wifi_settings = this->demo_wifi_settings; settings->wifi_country_code_settings = this->demo_wifi_country_code_settings; @@ -172,111 +172,46 @@ void Demo::GetConfig( demo_all_settings_t* settings ) settings->radio_settings = this->demo_radio_settings; } -void Demo::GetConfigRadio( demo_radio_settings_t* settings ) { *settings = this->demo_radio_settings; } +void DemoManagerInterface::GetConfigRadio( demo_radio_settings_t* settings ) { *settings = this->demo_radio_settings; } -void Demo::GetConfigWifi( demo_wifi_settings_t* settings ) { *settings = this->demo_wifi_settings; } +void DemoManagerInterface::GetConfigWifi( demo_wifi_settings_t* settings ) { *settings = this->demo_wifi_settings; } -void Demo::GetConfigAutonomousGnss( demo_gnss_settings_t* settings ) +void DemoManagerInterface::GetConfigAutonomousGnss( demo_gnss_settings_t* settings ) { *settings = this->demo_gnss_autonomous_settings; } -void Demo::GetConfigAssistedGnss( demo_gnss_settings_t* settings ) { *settings = this->demo_gnss_assisted_settings; } +void DemoManagerInterface::GetConfigAssistedGnss( demo_gnss_settings_t* settings ) +{ + *settings = this->demo_gnss_assisted_settings; +} -void Demo::UpdateConfigRadio( demo_radio_settings_t* radio_config ) { this->demo_radio_settings = *radio_config; } +void DemoManagerInterface::UpdateConfigRadio( demo_radio_settings_t* radio_config ) +{ + this->demo_radio_settings = *radio_config; +} -void Demo::UpdateConfigWifiScan( const demo_wifi_settings_t* wifi_config ) { this->demo_wifi_settings = *wifi_config; } +void DemoManagerInterface::UpdateConfigWifiScan( const demo_wifi_settings_t* wifi_config ) +{ + this->demo_wifi_settings = *wifi_config; +} -void Demo::UpdateConfigWifiCountryCode( const demo_wifi_country_code_settings_t* wifi_config ) +void DemoManagerInterface::UpdateConfigWifiCountryCode( const demo_wifi_country_code_settings_t* wifi_config ) { this->demo_wifi_country_code_settings = *wifi_config; } -void Demo::UpdateConfigAutonomousGnss( const demo_gnss_settings_t* gnss_autonomous_config ) +void DemoManagerInterface::UpdateConfigAutonomousGnss( const demo_gnss_settings_t* gnss_autonomous_config ) { this->demo_gnss_autonomous_settings = *gnss_autonomous_config; } -void Demo::UpdateConfigAssistedGnss( const demo_gnss_settings_t* gnss_assisted_config ) +void DemoManagerInterface::UpdateConfigAssistedGnss( const demo_gnss_settings_t* gnss_assisted_config ) { this->demo_gnss_assisted_settings = *gnss_assisted_config; } -void Demo::Start( demo_type_t demo_type ) -{ - if( demo_type != this->demo_type_current ) - { - delete this->running_demo; - this->running_demo = NULL; - - switch( demo_type ) - { - case DEMO_TYPE_WIFI: - this->running_demo = new DemoWifiScan( device, signaling, this->communication_interface ); - break; - case DEMO_TYPE_WIFI_COUNTRY_CODE: - this->running_demo = new DemoWifiCountryCode( device, signaling, this->communication_interface ); - break; - case DEMO_TYPE_GNSS_AUTONOMOUS: - this->running_demo = new DemoGnssAutonomous( device, signaling, environment, antenna_selector, timer, - this->communication_interface ); - break; - case DEMO_TYPE_GNSS_ASSISTED: - this->running_demo = new DemoGnssAssisted( device, signaling, environment, antenna_selector, timer, - this->communication_interface ); - break; - case DEMO_TYPE_RADIO_PING_PONG: - this->running_demo = new DemoPingPong( device, signaling, environment, this->communication_interface ); - break; - case DEMO_TYPE_TX_CW: - this->running_demo = new DemoTxCw( device, signaling, this->communication_interface ); - break; - case DEMO_TYPE_RADIO_PER_TX: - this->running_demo = new DemoRadioPer( device, signaling, environment, this->communication_interface, - DEMO_RADIO_PER_MODE_TX ); - break; - case DEMO_TYPE_RADIO_PER_RX: - this->running_demo = new DemoRadioPer( device, signaling, environment, this->communication_interface, - DEMO_RADIO_PER_MODE_RX ); - break; - default: - break; - } - - this->demo_type_current = demo_type; - } - - this->running_demo->Initialize( ); - this->running_demo->Reset( ); - - switch( demo_type ) - { - case DEMO_TYPE_WIFI: - ( ( DemoWifiScan* ) this->running_demo )->Configure( this->demo_wifi_settings ); - break; - case DEMO_TYPE_WIFI_COUNTRY_CODE: - ( ( DemoWifiCountryCode* ) this->running_demo )->Configure( this->demo_wifi_country_code_settings ); - break; - case DEMO_TYPE_GNSS_AUTONOMOUS: - ( ( DemoGnssAutonomous* ) this->running_demo )->Configure( this->demo_gnss_autonomous_settings ); - break; - case DEMO_TYPE_GNSS_ASSISTED: - ( ( DemoGnssAssisted* ) this->running_demo )->Configure( this->demo_gnss_assisted_settings ); - break; - case DEMO_TYPE_RADIO_PING_PONG: - case DEMO_TYPE_RADIO_PER_TX: - case DEMO_TYPE_RADIO_PER_RX: - case DEMO_TYPE_TX_CW: - ( ( DemoRadioInterface* ) this->running_demo )->Configure( this->demo_radio_settings ); - break; - default: - break; - } - - this->running_demo->Start( ); -} - -void Demo::Stop( ) +void DemoManagerInterface::Stop( ) { if( this->running_demo ) { @@ -284,7 +219,7 @@ void Demo::Stop( ) } } -void Demo::Reset( ) +void DemoManagerInterface::Reset( ) { if( this->running_demo ) { @@ -292,7 +227,7 @@ void Demo::Reset( ) } } -bool Demo::HasIntermediateResults( ) const +bool DemoManagerInterface::HasIntermediateResults( ) const { if( this->running_demo ) { @@ -304,28 +239,14 @@ bool Demo::HasIntermediateResults( ) const } } -demo_status_t Demo::Runtime( ) { return this->running_demo->Runtime( ); } - -demo_type_t Demo::GetType( ) { return this->demo_type_current; } - -void* Demo::GetResults( ) +void DemoManagerInterface::InterruptHandler( const InterruptionInterface* interruption ) { - switch( demo_type_current ) + if( this->running_demo ) { - case DEMO_TYPE_WIFI: - return ( void* ) ( ( DemoWifiScan* ) this->running_demo )->GetResult( ); - case DEMO_TYPE_WIFI_COUNTRY_CODE: - return ( void* ) ( ( DemoWifiCountryCode* ) this->running_demo )->GetResult( ); - case DEMO_TYPE_GNSS_AUTONOMOUS: - return ( void* ) ( ( DemoGnssAutonomous* ) this->running_demo )->GetResult( ); - case DEMO_TYPE_GNSS_ASSISTED: - return ( void* ) ( ( DemoGnssAssisted* ) this->running_demo )->GetResult( ); - case DEMO_TYPE_RADIO_PING_PONG: - return ( void* ) ( ( DemoPingPong* ) this->running_demo )->GetResult( ); - case DEMO_TYPE_RADIO_PER_TX: - case DEMO_TYPE_RADIO_PER_RX: - return ( void* ) ( ( DemoRadioPer* ) this->running_demo )->GetResult( ); - default: - return NULL; + this->running_demo->InterruptHandler( interruption ); } } + +demo_status_t DemoManagerInterface::Runtime( ) { return this->running_demo->Runtime( ); } + +demo_type_t DemoManagerInterface::GetType( ) { return this->demo_type_current; } diff --git a/embedded/demo/src/demo_manager_modem.cpp b/embedded/demo/src/demo_manager_modem.cpp new file mode 100644 index 0000000..17672be --- /dev/null +++ b/embedded/demo/src/demo_manager_modem.cpp @@ -0,0 +1,153 @@ +/** + * @file demo_manager_modem.cpp + * + * @brief Implementation of the demonstration manager for a modem. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_manager_modem.h" +#include "demo_modem_wifi.h" +#include "demo_modem_gnss_autonomous.h" +#include "demo_modem_gnss_assisted.h" +#include "demo_modem_radio_tx_continuous.h" +#include "demo_modem_radio_tx_cw.h" +#include "demo_modem_radio_rx_continuous.h" + +DemoManagerModem::DemoManagerModem( DeviceModem* device, EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, SignalingInterface* signaling, + TimerInterface* timer, CommunicationInterface* communication_interface ) + : DemoManagerInterface( environment, antenna_selector, signaling, timer, communication_interface ), device( device ) +{ +} + +DemoManagerModem::~DemoManagerModem( ) {} + +void DemoManagerModem::Start( demo_type_t demo_type ) +{ + if( demo_type != this->demo_type_current ) + { + delete this->running_demo; + this->running_demo = NULL; + + switch( demo_type ) + { + case DEMO_TYPE_WIFI: + this->running_demo = new DemoModemWifi( device, signaling, this->communication_interface ); + break; + case DEMO_TYPE_GNSS_AUTONOMOUS: + this->running_demo = new DemoModemGnssAutonomous( device, signaling, environment, antenna_selector, timer, + this->communication_interface ); + break; + case DEMO_TYPE_GNSS_ASSISTED: + this->running_demo = new DemoModemGnssAssisted( device, signaling, environment, antenna_selector, timer, + this->communication_interface ); + break; + case DEMO_TYPE_RADIO_PER_TX: + { + this->running_demo = new DemoModemRadioTxContinuous( device, signaling, this->communication_interface ); + break; + } + case DEMO_TYPE_RADIO_PER_RX: + { + this->running_demo = new DemoModemRadioRxContinuous( device, signaling, this->communication_interface ); + break; + } + case DEMO_TYPE_TX_CW: + { + this->running_demo = new DemoModemRadioTxCw( device, signaling, this->communication_interface ); + break; + } + default: + break; + } + + this->demo_type_current = demo_type; + } + + this->running_demo->Initialize( ); + this->running_demo->Reset( ); + + switch( demo_type ) + { + case DEMO_TYPE_WIFI: + ( ( DemoModemWifi* ) this->running_demo )->Configure( this->demo_wifi_settings ); + break; + case DEMO_TYPE_GNSS_AUTONOMOUS: + ( ( DemoModemGnssAutonomous* ) this->running_demo )->Configure( this->demo_gnss_autonomous_settings ); + break; + case DEMO_TYPE_GNSS_ASSISTED: + ( ( DemoModemGnssAssisted* ) this->running_demo )->Configure( this->demo_gnss_assisted_settings ); + break; + case DEMO_TYPE_RADIO_PER_TX: + { + ( ( DemoModemRadioTxContinuous* ) this->running_demo )->Configure( this->demo_radio_settings ); + break; + } + case DEMO_TYPE_RADIO_PER_RX: + { + ( ( DemoModemRadioRxContinuous* ) this->running_demo )->Configure( this->demo_radio_settings ); + break; + } + case DEMO_TYPE_TX_CW: + { + ( ( DemoModemRadioTxCw* ) this->running_demo )->Configure( this->demo_radio_settings ); + break; + } + default: + break; + } + + this->running_demo->Start( ); +} + +void* DemoManagerModem::GetResults( ) +{ + switch( demo_type_current ) + { + case DEMO_TYPE_WIFI: + return ( void* ) ( ( DemoModemWifi* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_GNSS_AUTONOMOUS: + return ( void* ) ( ( DemoModemGnssAutonomous* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_GNSS_ASSISTED: + return ( void* ) ( ( DemoModemGnssAssisted* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_RADIO_PER_RX: + { + return ( void* ) ( ( DemoModemRadioRxContinuous* ) this->running_demo )->GetResultsAndResetIntermediateFlag( ); + } + case DEMO_TYPE_RADIO_PER_TX: + { + return ( void* ) ( ( DemoModemRadioTxContinuous* ) this->running_demo )->GetResults( ); + } + case DEMO_TYPE_TX_CW: + { + return ( void* ) ( ( DemoModemRadioTxCw* ) this->running_demo )->GetResults( ); + break; + } + default: + return NULL; + } +} diff --git a/embedded/demo/src/demo_manager_transceiver.cpp b/embedded/demo/src/demo_manager_transceiver.cpp new file mode 100644 index 0000000..b5c358a --- /dev/null +++ b/embedded/demo/src/demo_manager_transceiver.cpp @@ -0,0 +1,149 @@ +/** + * @file demo_manager_transceiver.cpp + * + * @brief Implementation of the demonstration manager for a transceiver. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_manager_transceiver.h" +#include "demo_transceiver_wifi_scan.h" +#include "demo_transceiver_wifi_country_code.h" +#include "demo_transceiver_gnss_autonomous.h" +#include "demo_transceiver_gnss_assisted.h" +#include "demo_transceiver_radio_ping_pong.h" +#include "demo_transceiver_radio_tx_cw.h" +#include "demo_transceiver_radio_per.h" + +DemoManagerTransceiver::DemoManagerTransceiver( DeviceTransceiver* device, EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, + SignalingInterface* signaling, TimerInterface* timer, + CommunicationInterface* communication_interface ) + : DemoManagerInterface( environment, antenna_selector, signaling, timer, communication_interface ), device( device ) +{ +} + +DemoManagerTransceiver::~DemoManagerTransceiver( ) {} + +void DemoManagerTransceiver::Start( demo_type_t demo_type ) +{ + if( demo_type != this->demo_type_current ) + { + delete this->running_demo; + this->running_demo = NULL; + + switch( demo_type ) + { + case DEMO_TYPE_WIFI: + this->running_demo = + new DemoTransceiverWifiScan( device, signaling, this->communication_interface, this->environment ); + break; + case DEMO_TYPE_WIFI_COUNTRY_CODE: + this->running_demo = new DemoTransceiverWifiCountryCode( device, signaling, this->communication_interface, + this->environment ); + break; + case DEMO_TYPE_GNSS_AUTONOMOUS: + this->running_demo = new DemoTransceiverGnssAutonomous( device, signaling, environment, antenna_selector, + timer, this->communication_interface ); + break; + case DEMO_TYPE_GNSS_ASSISTED: + this->running_demo = new DemoTransceiverGnssAssisted( device, signaling, environment, antenna_selector, + timer, this->communication_interface ); + break; + case DEMO_TYPE_RADIO_PING_PONG: + this->running_demo = + new DemoTransceiverRadioPingPong( device, signaling, environment, this->communication_interface ); + break; + case DEMO_TYPE_TX_CW: + this->running_demo = + new DemoTransceiverRadioTxCw( device, signaling, this->communication_interface, this->environment ); + break; + case DEMO_TYPE_RADIO_PER_TX: + this->running_demo = new DemoTransceiverRadioPer( device, signaling, environment, + this->communication_interface, DEMO_RADIO_PER_MODE_TX ); + break; + case DEMO_TYPE_RADIO_PER_RX: + this->running_demo = new DemoTransceiverRadioPer( device, signaling, environment, + this->communication_interface, DEMO_RADIO_PER_MODE_RX ); + break; + default: + break; + } + + this->demo_type_current = demo_type; + } + + this->running_demo->Initialize( ); + this->running_demo->Reset( ); + + switch( demo_type ) + { + case DEMO_TYPE_WIFI: + ( ( DemoTransceiverWifiScan* ) this->running_demo )->Configure( this->demo_wifi_settings ); + break; + case DEMO_TYPE_WIFI_COUNTRY_CODE: + ( ( DemoTransceiverWifiCountryCode* ) this->running_demo )->Configure( this->demo_wifi_country_code_settings ); + break; + case DEMO_TYPE_GNSS_AUTONOMOUS: + ( ( DemoTransceiverGnssAutonomous* ) this->running_demo )->Configure( this->demo_gnss_autonomous_settings ); + break; + case DEMO_TYPE_GNSS_ASSISTED: + ( ( DemoTransceiverGnssAssisted* ) this->running_demo )->Configure( this->demo_gnss_assisted_settings ); + break; + case DEMO_TYPE_RADIO_PING_PONG: + case DEMO_TYPE_RADIO_PER_TX: + case DEMO_TYPE_RADIO_PER_RX: + case DEMO_TYPE_TX_CW: + ( ( DemoTransceiverRadioInterface* ) this->running_demo )->Configure( this->demo_radio_settings ); + break; + default: + break; + } + + this->running_demo->Start( ); +} + +void* DemoManagerTransceiver::GetResults( ) +{ + switch( demo_type_current ) + { + case DEMO_TYPE_WIFI: + return ( void* ) ( ( DemoTransceiverWifiScan* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_WIFI_COUNTRY_CODE: + return ( void* ) ( ( DemoTransceiverWifiCountryCode* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_GNSS_AUTONOMOUS: + return ( void* ) ( ( DemoTransceiverGnssAutonomous* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_GNSS_ASSISTED: + return ( void* ) ( ( DemoTransceiverGnssAssisted* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_RADIO_PING_PONG: + return ( void* ) ( ( DemoTransceiverRadioPingPong* ) this->running_demo )->GetResult( ); + case DEMO_TYPE_RADIO_PER_TX: + case DEMO_TYPE_RADIO_PER_RX: + return ( void* ) ( ( DemoTransceiverRadioPer* ) this->running_demo )->GetResult( ); + default: + return NULL; + } +} diff --git a/embedded/demo/src/demo_modem_gnss_assisted.cpp b/embedded/demo/src/demo_modem_gnss_assisted.cpp new file mode 100644 index 0000000..5d88549 --- /dev/null +++ b/embedded/demo/src/demo_modem_gnss_assisted.cpp @@ -0,0 +1,71 @@ +/** + * @file demo_modem_gnss_assisted.cpp + * + * @brief Implementation of the GNSS assisted demonstration for modem. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_modem_gnss_assisted.h" +#include "lr1110_modem_gnss.h" +#define DEMO_GNSS_LIMIT_ALMANAC_AGE_DAYS ( 31 ) + +DemoModemGnssAssisted::DemoModemGnssAssisted( DeviceModem* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, TimerInterface* timer, + CommunicationInterface* communication_interface ) + : DemoModemGnssInterface( device, signaling, environment, antenna_selector, timer, communication_interface ) +{ +} + +DemoModemGnssAssisted::~DemoModemGnssAssisted( ) {} + +lr1110_modem_response_code_t DemoModemGnssAssisted::CallScan( ) +{ + lr1110_modem_gnss_solver_assistance_position_t gnss_position = { 0 }; + DemoModemGnssAssisted::GnssPositionFromEnvironment( this->GetEnvironment( )->GetLocation( ), gnss_position ); + + if( !this->CheckAndStoreAlmanacAge( DEMO_GNSS_LIMIT_ALMANAC_AGE_DAYS ) ) + { + this->communication_interface->Log( "Almanac is too old ! (> %u days)\n", DEMO_GNSS_LIMIT_ALMANAC_AGE_DAYS ); + } + + lr1110_modem_gnss_set_assistance_position( this->device->GetRadio( ), &gnss_position ); + + const lr1110_modem_response_code_t scan_response_code = lr1110_modem_gnss_scan_assisted_md( + this->device->GetRadio( ), DemoModemGnssInterface::ModemSearchModeFromDemo( this->GetSettings( ).option ), + LR1110_MODEM_GNSS_BIT_CHANGE_MASK | LR1110_MODEM_GNSS_DOPPLER_MASK | LR1110_MODEM_GNSS_PSEUDO_RANGE_MASK, + this->GetSettings( ).nb_satellites ); + + return scan_response_code; +} + +void DemoModemGnssAssisted::GnssPositionFromEnvironment( const environment_location_t& location, + lr1110_modem_gnss_solver_assistance_position_t& gnss_position ) +{ + gnss_position.latitude = location.latitude; + gnss_position.longitude = location.longitude; +} \ No newline at end of file diff --git a/embedded/demo/src/demo_modem_gnss_autonomous.cpp b/embedded/demo/src/demo_modem_gnss_autonomous.cpp new file mode 100644 index 0000000..6a78e8b --- /dev/null +++ b/embedded/demo/src/demo_modem_gnss_autonomous.cpp @@ -0,0 +1,53 @@ +/** + * @file demo_modem_gnss_autonomous.cpp + * + * @brief Implementation of the GNSS autonomous demonstration for modem. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_modem_gnss_autonomous.h" +#include "lr1110_modem_gnss.h" + +DemoModemGnssAutonomous::DemoModemGnssAutonomous( DeviceModem* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, TimerInterface* timer, + CommunicationInterface* communication_interface ) + : DemoModemGnssInterface( device, signaling, environment, antenna_selector, timer, communication_interface ) +{ +} + +DemoModemGnssAutonomous::~DemoModemGnssAutonomous( ) {} + +lr1110_modem_response_code_t DemoModemGnssAutonomous::CallScan( ) +{ + const lr1110_modem_response_code_t call_response_code = lr1110_modem_gnss_scan_autonomous_md( + this->device->GetRadio( ), + LR1110_MODEM_GNSS_BIT_CHANGE_MASK | LR1110_MODEM_GNSS_DOPPLER_MASK | LR1110_MODEM_GNSS_PSEUDO_RANGE_MASK, + this->GetSettings( ).nb_satellites ); + + return call_response_code; +} diff --git a/embedded/demo/src/demo_modem_gnss_interface.cpp b/embedded/demo/src/demo_modem_gnss_interface.cpp new file mode 100644 index 0000000..54c57d8 --- /dev/null +++ b/embedded/demo/src/demo_modem_gnss_interface.cpp @@ -0,0 +1,453 @@ +/** + * @file demo_modem_gnss_interface.cpp + * + * @brief Implementation of the components shared by GNSS demonstrations. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "demo_modem_gnss_interface.h" +#include "system_lptim.h" +#include "lr1110_modem_lorawan.h" + +#define DEMO_GNSS_CONSUMPTION_DCDC_ACQUISITION_MA ( 11 ) +#define DEMO_GNSS_CONSUMPTION_DCDC_COMPUTATION_MA ( 6 ) + +DemoModemGnssInterface::DemoModemGnssInterface( DeviceModem* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, TimerInterface* timer, + CommunicationInterface* communication_interface ) + : DemoModemInterface( device, signaling, communication_interface ), + timer( timer ), + state( DEMO_MODEM_GNSS_BASE_INIT ), + environment( environment ), + inter_capture_delay_s( 0 ), + instant_start_capture_ms( 0 ), + instant_second_capture_ms( 0 ), + antenna_selector( antenna_selector ) +{ +} + +DemoModemGnssInterface::~DemoModemGnssInterface( ) {} + +void DemoModemGnssInterface::Reset( ) +{ + this->DemoInterface::Reset( ); + this->state = DEMO_MODEM_GNSS_BASE_INIT; + this->result.nb_result = 0; + this->result.nav_message.size = 0; + this->result.consumption_uas = 0; + this->result.error = DEMO_GNSS_BASE_NO_ERROR; + this->result.timings = { 0 }; + this->result.local_instant_measurement = 0; + this->result.local_instant_measurement_second_capture = 0; + this->result.almanac_too_old = false; + this->result.almanac_age_days = 0; + this->instant_start_capture_ms = 0; + this->instant_second_capture_ms = 0; +} + +void DemoModemGnssInterface::JumpToErrorState( const demo_gnss_error_t error_code ) +{ + this->result.error = error_code; + this->state = DEMO_MODEM_GNSS_BASE_ERROR; +} + +demo_gnss_settings_t DemoModemGnssInterface::GetSettings( ) const { return this->settings; } + +EnvironmentInterface* DemoModemGnssInterface::GetEnvironment( ) { return this->environment; } + +void DemoModemGnssInterface::SpecificRuntime( ) +{ + static uint32_t measurement_instant_s; + switch( this->state ) + { + case DEMO_MODEM_GNSS_BASE_INIT: + { + lr1110_modem_gnss_set_constellations_to_use( this->device->GetRadio( ), this->settings.constellation_mask ); + + this->SetAntennaSwitch( this->settings.antenna_selection ); + this->ConfigureEnvironmentTimeFromDevice( ); + + if( ( !this->GetEnvironment( )->HasLocation( ) ) ) + { + this->AskAndStoreLocation( ); + } + if( !this->GetEnvironment( )->HasLocation( ) ) + { + this->JumpToErrorState( DEMO_GNSS_BASE_ERROR_NO_LOCATION ); + this->communication_interface->Log( "No location available\n" ); + break; + } + this->state = DEMO_MODEM_GNSS_BASE_SCAN; + break; + } + + case DEMO_MODEM_GNSS_BASE_SCAN: + { + this->SetWaitingForInterrupt( ); + measurement_instant_s = this->environment->GetLocalTimeSeconds( ); + + const lr1110_modem_response_code_t scan_response_code = this->CallScan( ); + + if( scan_response_code != LR1110_MODEM_RESPONSE_CODE_OK ) + { + this->communication_interface->Log( "Error code when calling scan: 0x%x\r\n", scan_response_code ); + this->JumpToErrorState( DemoModemGnssInterface::ErrorCodeFromScanResponseCode( scan_response_code ) ); + } + else + { + this->instant_start_capture_ms = this->environment->GetLocalTimeMilliseconds( ); + + this->state = DEMO_MODEM_GNSS_BASE_WAIT_FOR_SCAN; + this->signaling->StartCapture( ); + } + + break; + } + + case DEMO_MODEM_GNSS_BASE_WAIT_FOR_SCAN: + { + if( this->InterruptHasRaised( ) ) + { + if( this->last_received_event.event_type == LR1110_MODEM_LORAWAN_EVENT_GNSS_SCAN_DONE ) + { + this->result.local_instant_measurement = measurement_instant_s; + this->FetchAndSaveResults( this->last_received_event.buffer, this->last_received_event.buffer_len ); + this->state = DEMO_MODEM_GNSS_BASE_TERMINATED; + } + else + { + this->SetWaitingForInterrupt( ); + this->state = DEMO_MODEM_GNSS_BASE_WAIT_FOR_SCAN; + } + } + else + { + this->SetWaitingForInterrupt( ); + this->state = DEMO_MODEM_GNSS_BASE_WAIT_FOR_SCAN; + } + break; + } + + case DEMO_MODEM_GNSS_BASE_TERMINATED: + { + this->state = DEMO_MODEM_GNSS_BASE_INIT; + this->Terminate( ); + break; + } + + case DEMO_MODEM_GNSS_BASE_ERROR: + { + this->state = DEMO_MODEM_GNSS_BASE_TERMINATED; + break; + } + } +} + +void DemoModemGnssInterface::SpecificStop( ) { signaling->StopCapture( ); } + +bool DemoModemGnssInterface::CanFetchResults( demo_gnss_nav_result_t& nav_message ) +{ + if( DemoModemGnssInterface::IsResultToSolver( nav_message ) ) + { + return true; + } + else + { + const demo_gnss_error_t error_code = DemoModemGnssInterface::GetHostErrorFromResult( nav_message ); + if( error_code == DEMO_GNSS_BASE_ERROR_NO_SATELLITE ) + { + // In the case where no satellite has been detected, it is still ok + // to fetch the results + return true; + } + else + { + return false; + } + } +} + +void DemoModemGnssInterface::FetchAndSaveResults( const uint8_t* buffer, uint16_t buffer_length ) +{ + this->result.nav_message.size = buffer_length; + if( this->result.nav_message.size <= GNSS_DEMO_NAV_MESSAGE_MAX_LENGTH ) + { + memcpy( this->result.nav_message.message, buffer, buffer_length ); + } + else + { + this->JumpToErrorState( DEMO_GNSS_BASE_NAV_MESSAGE_TOO_LONG ); + this->communication_interface->Log( + "Error when fetching NAV message: size too long (max is %u, " + "actual size is %u)\n", + GNSS_DEMO_NAV_MESSAGE_MAX_LENGTH, this->result.nav_message.size ); + } + + if( DemoModemGnssInterface::CanFetchResults( this->result.nav_message ) ) + { + uint8_t nb_sv_detected = 0; + lr1110_modem_gnss_detected_satellite_t list_of_sv[30] = { 0 }; + lr1110_modem_gnss_get_nb_detected_satellites( this->device->GetRadio( ), &nb_sv_detected ); + lr1110_modem_gnss_get_detected_satellites( this->device->GetRadio( ), nb_sv_detected, list_of_sv ); + lr1110_modem_gnss_timings_t modem_timings = {}; + lr1110_modem_gnss_get_timings( this->device->GetRadio( ), &modem_timings ); + this->result.timings = DemoModemGnssInterface::DemoTimingFromModem( modem_timings ); + + this->result.consumption_uas = + ( this->result.timings.radio_ms * DEMO_GNSS_CONSUMPTION_DCDC_ACQUISITION_MA + + this->result.timings.computation_ms * DEMO_GNSS_CONSUMPTION_DCDC_COMPUTATION_MA ); + + this->result.nb_result = nb_sv_detected; + + for( uint8_t index = 0; ( index < nb_sv_detected ) && ( index < GNSS_DEMO_MAX_RESULT_TOTAL ); index++ ) + { + if( list_of_sv[index].satellite_id < 64 ) + { + this->result.result[index].constellation = DEMO_GNSS_CONSTELLATION_GPS; + this->result.result[index].satellite_id = list_of_sv[index].satellite_id + 1; + } + else + { + this->result.result[index].constellation = DEMO_GNSS_CONSTELLATION_BEIDOU; + this->result.result[index].satellite_id = ( list_of_sv[index].satellite_id % 64 ) + 1; + } + this->result.result[index].snr = list_of_sv[index].cnr; + } + } +} + +void DemoModemGnssInterface::SpecificInterruptHandler( ) {} + +void DemoModemGnssInterface::Configure( demo_gnss_settings_t& config ) { this->settings = config; } + +const demo_gnss_all_results_t* DemoModemGnssInterface::GetResult( ) const { return &this->result; } + +void DemoModemGnssInterface::SetAntennaSwitch( const demo_gnss_antenna_selection_t antenna_selection ) +{ + switch( antenna_selection ) + { + case DEMO_GNSS_NO_ANTENNA_SELECTION: + { + break; + } + + case DEMO_GNSS_ANTENNA_SELECTION_1: + { + this->antenna_selector->SelectAntenna1( ); + break; + } + + case DEMO_GNSS_ANTENNA_SELECTION_2: + { + this->antenna_selector->SelectAntenna2( ); + break; + } + } +} + +void DemoModemGnssInterface::AskAndStoreLocation( ) +{ + environment_location_t initial_position; + uint32_t actual_time_gps_seconds; + + const bool success = this->communication_interface->GetDateAndApproximateLocation( + actual_time_gps_seconds, initial_position.latitude, initial_position.longitude, initial_position.altitude ); + + if( success == true ) + { + this->GetEnvironment( )->SetTimeFromGpsEpoch( actual_time_gps_seconds ); + this->GetEnvironment( )->SetLocation( initial_position ); + } +} + +bool DemoModemGnssInterface::IsResultToSolver( const demo_gnss_nav_result_t& nav_result ) +{ + if( nav_result.size >= 2 ) + { + return nav_result.message[0] == LR1110_MODEM_GNSS_DESTINATION_SOLVER; + } + else + { + return false; + } +} + +bool DemoModemGnssInterface::IsResultToHost( const demo_gnss_nav_result_t& nav_result ) +{ + if( nav_result.size >= 2 ) + { + return nav_result.message[0] == LR1110_MODEM_GNSS_DESTINATION_HOST; + } + else + { + return false; + } +} + +demo_gnss_error_t DemoModemGnssInterface::GetHostErrorFromResult( const demo_gnss_nav_result_t& nav_result ) +{ + demo_gnss_error_t error = DEMO_GNSS_BASE_ERROR_UNKNOWN; + if( DemoModemGnssInterface::IsResultToHost( nav_result ) ) + { + switch( nav_result.message[1] ) + { + case 0x06: + { + error = DEMO_GNSS_BASE_ERROR_NO_DATE; + break; + } + case 0x07: + { + error = DEMO_GNSS_BASE_ERROR_NO_SATELLITE; + break; + } + case 0x08: + { + error = DEMO_GNSS_BASE_ERROR_ALMANAC_TOO_OLD; + break; + } + default: + { + error = DEMO_GNSS_BASE_ERROR_UNKNOWN; + } + } + } + else + { + error = DEMO_GNSS_BASE_NO_ERROR; + } + return error; +} + +uint16_t DemoModemGnssInterface::GetAlmanacAgeFromGpsEpochInDays( const uint16_t almanac_age ) +{ + // The almanac_age is the number of days since last GPS week number rollover + // As we are in year 2020, our last rollover was on April 7th 2019. The next + // one will be around 2038. So if you are reading this code because you + // suspect mistake in the almanac age handling, and the current year is > + // 2038, consider revisiting this piece of code... + // (and now I'm a 50 year old guy... Greetings from the past ;) ) + + // Let's convert in the number of days elapsed since GPS epoch (January + // 6th 1970) + const uint16_t days_between_2019_rollover_to_epoch = 14336; + const uint16_t almanac_age_days_since_gps_epoch = almanac_age + days_between_2019_rollover_to_epoch; + return almanac_age_days_since_gps_epoch; +} + +lr1110_modem_gnss_search_mode_t DemoModemGnssInterface::ModemSearchModeFromDemo( + const demo_gnss_search_mode_t& demo_search_mode ) +{ + lr1110_modem_gnss_search_mode_t transceiver_search_mode = LR1110_MODEM_GNSS_OPTION_DEFAULT; + switch( demo_search_mode ) + { + case DEMO_GNSS_OPTION_DEFAULT: + { + transceiver_search_mode = LR1110_MODEM_GNSS_OPTION_DEFAULT; + break; + } + + case DEMO_GNSS_OPTION_BEST_EFFORT: + { + transceiver_search_mode = LR1110_MODEM_GNSS_OPTION_BEST_EFFORT; + break; + } + } + return transceiver_search_mode; +} + +demo_gnss_timings_t DemoModemGnssInterface::DemoTimingFromModem( + const lr1110_modem_gnss_timings_t& transceiver_timings ) +{ + demo_gnss_timings_t demo_timings = {}; + demo_timings.computation_ms = transceiver_timings.computation_ms; + demo_timings.radio_ms = transceiver_timings.radio_ms; + return demo_timings; +} + +uint16_t DemoModemGnssInterface::GetAlmanacAgeDaysSinceToday( ) const +{ + // First, we get the age of the almanac of a satellite (here sv_id 5) + uint16_t almanac_age = 0; + this->device->GetAlmanacAgesForSatelliteId( 5, &almanac_age ); + + // Then we convert the age from almanac into number of days elapsed since + // GPS epoch + const uint16_t almanac_age_since_epoch = DemoModemGnssInterface::GetAlmanacAgeFromGpsEpochInDays( almanac_age ); + + // We get the actual time in days + const time_t now_seconds = this->environment->GetDateTime( ); + const uint16_t now_days = now_seconds / 3600 / 24; + + const uint16_t almanac_age_since_update = now_days - almanac_age_since_epoch; + return almanac_age_since_update; +} + +bool DemoModemGnssInterface::IsAlmanacTooOld( uint16_t almanac_age_days, const uint16_t days_limit ) +{ + return almanac_age_days > days_limit; +} + +bool DemoModemGnssInterface::CheckAndStoreAlmanacAge( const uint16_t days_limit ) +{ + const uint16_t almanac_age_days = this->GetAlmanacAgeDaysSinceToday( ); + + const bool almanac_too_old = DemoModemGnssInterface::IsAlmanacTooOld( almanac_age_days, days_limit ); + + this->result.almanac_age_days = almanac_age_days; + this->result.almanac_too_old = almanac_too_old; + + return !almanac_too_old; +} + +demo_gnss_error_t DemoModemGnssInterface::ErrorCodeFromScanResponseCode( + lr1110_modem_response_code_t scan_response_code ) +{ + demo_gnss_error_t error_code = DEMO_GNSS_BASE_ERROR_UNKNOWN; + switch( scan_response_code ) + { + case LR1110_MODEM_RESPONSE_CODE_NO_TIME: + { + error_code = DEMO_GNSS_BASE_ERROR_NO_DATE; + break; + } + default: + { + error_code = DEMO_GNSS_BASE_ERROR_UNKNOWN; + } + } + return error_code; +} + +void DemoModemGnssInterface::ConfigureEnvironmentTimeFromDevice( ) +{ + uint32_t gps_time = 0; + lr1110_modem_get_gps_time( this->device->GetRadio( ), &gps_time ); + this->environment->SetTimeFromGpsEpoch( gps_time ); +} \ No newline at end of file diff --git a/embedded/demo/src/demo_modem_interface.cpp b/embedded/demo/src/demo_modem_interface.cpp new file mode 100644 index 0000000..aec0c4f --- /dev/null +++ b/embedded/demo/src/demo_modem_interface.cpp @@ -0,0 +1,51 @@ +/** + * @file demo_modem_interface.cpp + * + * @brief Implementation of modem demo class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_modem_interface.h" + +DemoModemInterface::DemoModemInterface( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ) + : DemoInterface( device, signaling, communication_interface ) +{ +} + +void DemoModemInterface::ClearRegisteredIrqs( ) const +{ /* Do nothing as there is no IRQs with a modem */ +} + +void DemoModemInterface::SpecificInterruptHandler( const InterruptionInterface* interruption ) +{ + const InterruptionModem* interrupt = dynamic_cast< const InterruptionModem* >( interruption ); + if( interrupt != 0 ) + { + this->last_received_event = interrupt->GetEvent( ); + } +} \ No newline at end of file diff --git a/embedded/demo/src/demo_modem_radio_converters.cpp b/embedded/demo/src/demo_modem_radio_converters.cpp new file mode 100644 index 0000000..08f5695 --- /dev/null +++ b/embedded/demo/src/demo_modem_radio_converters.cpp @@ -0,0 +1,152 @@ +/** + * @file demo_modem_radio_converters.cpp + * + * @brief Implementation of the modem radio convertion methods. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_modem_radio_converters.h" + +bool DemoModemRadioConverters::convert_radio_setting_sf( lr1110_radio_lora_sf_t sf_setting, + lr1110_modem_tst_mode_sf_t* sf_test ) +{ + bool success = false; + switch( sf_setting ) + { + case LR1110_RADIO_LORA_SF7: + { + success = true; + ( *sf_test ) = LR1110_MODEM_TST_MODE_SF7; + break; + } + case LR1110_RADIO_LORA_SF8: + { + success = true; + ( *sf_test ) = LR1110_MODEM_TST_MODE_SF8; + break; + } + case LR1110_RADIO_LORA_SF9: + { + success = true; + ( *sf_test ) = LR1110_MODEM_TST_MODE_SF9; + break; + } + case LR1110_RADIO_LORA_SF10: + { + success = true; + ( *sf_test ) = LR1110_MODEM_TST_MODE_SF10; + break; + } + case LR1110_RADIO_LORA_SF11: + { + success = true; + ( *sf_test ) = LR1110_MODEM_TST_MODE_SF11; + break; + } + case LR1110_RADIO_LORA_SF12: + { + success = true; + ( *sf_test ) = LR1110_MODEM_TST_MODE_SF12; + break; + } + default: + { + success = false; + } + } + return success; +} + +bool DemoModemRadioConverters::convert_radio_setting_bw( lr1110_radio_lora_bw_t bw_setting, + lr1110_modem_tst_mode_bw_t* bw_test ) +{ + bool success = false; + switch( bw_setting ) + { + case LR1110_RADIO_LORA_BW_125: + { + success = true; + ( *bw_test ) = LR1110_MODEM_TST_MODE_125_KHZ; + break; + } + case LR1110_RADIO_LORA_BW_250: + { + success = true; + ( *bw_test ) = LR1110_MODEM_TST_MODE_250_KHZ; + break; + } + case LR1110_RADIO_LORA_BW_500: + { + success = true; + ( *bw_test ) = LR1110_MODEM_TST_MODE_500_KHZ; + break; + } + default: + { + success = false; + } + } + return success; +} + +bool DemoModemRadioConverters::convert_radio_setting_cr( lr1110_radio_lora_cr_t cr_setting, + lr1110_modem_tst_mode_cr_t* cr_test ) +{ + bool success = false; + switch( cr_setting ) + { + case LR1110_RADIO_LORA_CR_4_5: + { + success = true; + ( *cr_test ) = LR1110_MODEM_TST_MODE_4_5; + break; + } + case LR1110_RADIO_LORA_CR_4_6: + { + success = true; + ( *cr_test ) = LR1110_MODEM_TST_MODE_4_5; + break; + } + case LR1110_RADIO_LORA_CR_4_7: + { + success = true; + ( *cr_test ) = LR1110_MODEM_TST_MODE_4_5; + break; + } + case LR1110_RADIO_LORA_CR_4_8: + { + success = true; + ( *cr_test ) = LR1110_MODEM_TST_MODE_4_5; + break; + } + default: + { + success = false; + } + } + return success; +} diff --git a/embedded/demo/src/demo_modem_radio_rx_continuous.cpp b/embedded/demo/src/demo_modem_radio_rx_continuous.cpp new file mode 100644 index 0000000..6126e12 --- /dev/null +++ b/embedded/demo/src/demo_modem_radio_rx_continuous.cpp @@ -0,0 +1,137 @@ +/** + * @file demo_modem_radio_rx_continuous.cpp + * + * @brief Implementation of the Continuous Packet Reception with Modem demonstration. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_modem_radio_rx_continuous.h" +#include "demo_modem_radio_converters.h" + +DemoModemRadioRxContinuous::DemoModemRadioRxContinuous( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ) + : DemoModemInterface( device, signaling, communication_interface ), + state( DEMO_MODEM_RADIO_RX_CONTINUOUS_STATE_INIT ) +{ + this->results = {}; +} + +DemoModemRadioRxContinuous::~DemoModemRadioRxContinuous( ) {} + +void DemoModemRadioRxContinuous::SpecificRuntime( ) +{ + switch( this->state ) + { + case DEMO_MODEM_RADIO_RX_CONTINUOUS_STATE_INIT: + { + // The modem must be set to correct region depending on the user frequency + if( this->settings.frequency > 900000000 ) + { + lr1110_modem_set_region( this->device->GetRadio( ), LR1110_LORAWAN_REGION_US915 ); + } + else + { + lr1110_modem_set_region( this->device->GetRadio( ), LR1110_LORAWAN_REGION_EU868 ); + } + lr1110_modem_test_mode_start( this->device->GetRadio( ) ); + lr1110_modem_test_rx_cont( this->device->GetRadio( ), this->settings.frequency, this->settings.sf, + this->settings.bw, this->settings.cr ); + this->state = DEMO_MODEM_RADIO_RX_CONTINUOUS_STATE_RUNNING; + break; + } + case DEMO_MODEM_RADIO_RX_CONTINUOUS_STATE_RUNNING: + { + uint32_t local_rx_counter = 0; + lr1110_modem_test_read_packet_counter_rx_cont( this->device->GetRadio( ), &local_rx_counter ); + if( this->results.count_rx_correct_packet != local_rx_counter ) + { + this->results.count_rx_correct_packet = local_rx_counter; + this->has_intermediate_results = true; + } + break; + } + } +} + +void DemoModemRadioRxContinuous::SpecificStop( ) +{ + uint32_t local_rx_counter = 0; + lr1110_modem_test_read_packet_counter_rx_cont( this->device->GetRadio( ), &local_rx_counter ); + lr1110_modem_test_exit( this->device->GetRadio( ) ); + this->state = DEMO_MODEM_RADIO_RX_CONTINUOUS_STATE_INIT; + this->results.count_rx_correct_packet = 0; +} + +void DemoModemRadioRxContinuous::Configure( demo_radio_settings_t& settings ) +{ + this->convert_radio_settings( &settings, &this->settings ); +} + +bool DemoModemRadioRxContinuous::HasIntermediateResults( ) const +{ + const bool has_results = this->has_intermediate_results; + return has_results; +} + +demo_radio_per_results_t* DemoModemRadioRxContinuous::GetResultsAndResetIntermediateFlag( ) +{ + this->has_intermediate_results = false; + return &this->results; +} + +bool DemoModemRadioRxContinuous::convert_radio_settings( + const demo_radio_settings_t* radio_settings, + demo_radio_rx_continuous_settings_t* demo_radio_rx_continuous_settings ) +{ + bool success = true; + + demo_radio_rx_continuous_settings->frequency = radio_settings->rf_frequency; + + switch( radio_settings->pkt_type ) + { + case LR1110_RADIO_PKT_TYPE_GFSK: + { + demo_radio_rx_continuous_settings->sf = LR1110_MODEM_TST_MODE_FSK; + // Other modulation parameters are set to dummy values + demo_radio_rx_continuous_settings->bw = LR1110_MODEM_TST_MODE_125_KHZ; + demo_radio_rx_continuous_settings->cr = LR1110_MODEM_TST_MODE_4_5; + break; + } + + case LR1110_RADIO_PKT_TYPE_LORA: + { + success &= DemoModemRadioConverters::convert_radio_setting_sf( radio_settings->modulation_lora.sf, + &demo_radio_rx_continuous_settings->sf ); + success &= DemoModemRadioConverters::convert_radio_setting_bw( radio_settings->modulation_lora.bw, + &demo_radio_rx_continuous_settings->bw ); + success &= DemoModemRadioConverters::convert_radio_setting_cr( radio_settings->modulation_lora.cr, + &demo_radio_rx_continuous_settings->cr ); + break; + } + } + return success; +} \ No newline at end of file diff --git a/embedded/demo/src/demo_modem_radio_tx_continuous.cpp b/embedded/demo/src/demo_modem_radio_tx_continuous.cpp new file mode 100644 index 0000000..29dcdc9 --- /dev/null +++ b/embedded/demo/src/demo_modem_radio_tx_continuous.cpp @@ -0,0 +1,120 @@ +/** + * @file demo_modem_radio_tx_continuous.cpp + * + * @brief Implementation of the Continuous Packet Transmit with Modem demonstration. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_modem_radio_tx_continuous.h" +#include "demo_modem_radio_converters.h" + +DemoModemRadioTxContinuous::DemoModemRadioTxContinuous( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ) + : DemoModemInterface( device, signaling, communication_interface ), + state( DEMO_MODEM_RADIO_TX_CONTINUOUS_STATE_INIT ) +{ + this->results = {}; +} + +DemoModemRadioTxContinuous::~DemoModemRadioTxContinuous( ) {} + +void DemoModemRadioTxContinuous::SpecificRuntime( ) +{ + switch( this->state ) + { + case DEMO_MODEM_RADIO_TX_CONTINUOUS_STATE_INIT: + { + // The modem must be set to correct region depending on the user frequency + if( this->settings.frequency > 900000000 ) + { + lr1110_modem_set_region( this->device->GetRadio( ), LR1110_LORAWAN_REGION_US915 ); + } + else + { + lr1110_modem_set_region( this->device->GetRadio( ), LR1110_LORAWAN_REGION_EU868 ); + } + lr1110_modem_test_mode_start( this->device->GetRadio( ) ); + lr1110_modem_test_tx_cont( this->device->GetRadio( ), this->settings.frequency, this->settings.tx_power, + this->settings.sf, this->settings.bw, this->settings.cr, + this->settings.payload_length ); + this->state = DEMO_MODEM_RADIO_TX_CONTINUOUS_STATE_RUNNING; + break; + } + case DEMO_MODEM_RADIO_TX_CONTINUOUS_STATE_RUNNING: + { + break; + } + } +} + +void DemoModemRadioTxContinuous::SpecificStop( ) +{ + lr1110_modem_test_exit( this->device->GetRadio( ) ); + this->state = DEMO_MODEM_RADIO_TX_CONTINUOUS_STATE_INIT; +} + +void DemoModemRadioTxContinuous::Configure( demo_radio_settings_t& settings ) +{ + this->convert_radio_settings( &settings, &this->settings ); +} + +demo_radio_per_results_t* DemoModemRadioTxContinuous::GetResults( ) { return &this->results; } + +bool DemoModemRadioTxContinuous::convert_radio_settings( + const demo_radio_settings_t* radio_settings, + demo_radio_tx_continuous_settings_t* demo_radio_tx_continuous_settings ) +{ + bool success = true; + + demo_radio_tx_continuous_settings->frequency = radio_settings->rf_frequency; + demo_radio_tx_continuous_settings->payload_length = radio_settings->payload_length; + demo_radio_tx_continuous_settings->tx_power = radio_settings->tx_power; + + switch( radio_settings->pkt_type ) + { + case LR1110_RADIO_PKT_TYPE_GFSK: + { + demo_radio_tx_continuous_settings->sf = LR1110_MODEM_TST_MODE_FSK; + // Other modulation parameters are set to dummy values + demo_radio_tx_continuous_settings->bw = LR1110_MODEM_TST_MODE_125_KHZ; + demo_radio_tx_continuous_settings->cr = LR1110_MODEM_TST_MODE_4_5; + break; + } + + case LR1110_RADIO_PKT_TYPE_LORA: + { + success &= DemoModemRadioConverters::convert_radio_setting_sf( radio_settings->modulation_lora.sf, + &demo_radio_tx_continuous_settings->sf ); + success &= DemoModemRadioConverters::convert_radio_setting_bw( radio_settings->modulation_lora.bw, + &demo_radio_tx_continuous_settings->bw ); + success &= DemoModemRadioConverters::convert_radio_setting_cr( radio_settings->modulation_lora.cr, + &demo_radio_tx_continuous_settings->cr ); + break; + } + } + return success; +} \ No newline at end of file diff --git a/embedded/demo/src/demo_modem_radio_tx_cw.cpp b/embedded/demo/src/demo_modem_radio_tx_cw.cpp new file mode 100644 index 0000000..648f8dd --- /dev/null +++ b/embedded/demo/src/demo_modem_radio_tx_cw.cpp @@ -0,0 +1,95 @@ +/** + * @file demo_modem_radio_tx_cw.cpp + * + * @brief Implementation of the Continuous Wave Transmit with Modem demonstration. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_modem_radio_tx_cw.h" + +DemoModemRadioTxCw::DemoModemRadioTxCw( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ) + : DemoModemInterface( device, signaling, communication_interface ), + state( DEMO_MODEM_RADIO_TX_CONTINUOUS_WAVE_STATE_INIT ) +{ + this->settings = {}; +} + +DemoModemRadioTxCw::~DemoModemRadioTxCw( ) {} + +void DemoModemRadioTxCw::SpecificRuntime( ) +{ + switch( this->state ) + { + case DEMO_MODEM_RADIO_TX_CONTINUOUS_WAVE_STATE_INIT: + { + lr1110_modem_test_mode_start( this->device->GetRadio( ) ); + lr1110_modem_test_tx_cw( this->device->GetRadio( ), this->settings.frequency, this->settings.tx_power ); + this->state = DEMO_MODEM_RADIO_TX_CONTINUOUS_WAVE_STATE_RUNNING; + this->signaling->StartContinuousTx( ); + break; + } + case DEMO_MODEM_RADIO_TX_CONTINUOUS_WAVE_STATE_RUNNING: + { + break; + } + } +} + +void DemoModemRadioTxCw::SpecificStop( ) +{ + lr1110_modem_test_exit( this->device->GetRadio( ) ); + this->signaling->StopContinuousTx( ); + this->state = DEMO_MODEM_RADIO_TX_CONTINUOUS_WAVE_STATE_INIT; +} + +void DemoModemRadioTxCw::Configure( demo_radio_settings_t& settings ) +{ + this->convert_radio_settings( &settings, &this->settings ); +} + +demo_radio_per_results_t* DemoModemRadioTxCw::GetResults( ) +{ + static demo_radio_per_results_t dummy_results = { + .count_rx_correct_packet = 0, + .count_rx_wrong_packet = 0, + .count_tx = 0, + .count_rx_timeout = 0, + .last_rssi = 0, + }; + return &dummy_results; +} + +bool DemoModemRadioTxCw::convert_radio_settings( + const demo_radio_settings_t* radio_settings, + demo_modem_radio_tx_cw_settings_t* demo_radio_tx_continuous_wave_settings ) +{ + bool success = true; + demo_radio_tx_continuous_wave_settings->frequency = radio_settings->rf_frequency; + demo_radio_tx_continuous_wave_settings->tx_power = radio_settings->tx_power; + return success; +} \ No newline at end of file diff --git a/embedded/demo/src/demo_modem_wifi.cpp b/embedded/demo/src/demo_modem_wifi.cpp new file mode 100644 index 0000000..614c191 --- /dev/null +++ b/embedded/demo/src/demo_modem_wifi.cpp @@ -0,0 +1,357 @@ +/** + * @file demo_modem_wifi.cpp + * + * @brief Implementation of the Wi-Fi modem demonstration. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "demo_modem_wifi.h" +#include "lr1110_modem_system.h" +#include "lr1110_modem_wifi.h" +#include "lr1110_modem_lorawan.h" + +#define WIFI_MODEM_DEMO_CONSUMPTION_DCDC_CORRELATION_MA ( 12 ) +#define WIFI_MODEM_DEMO_CONSUMPTION_DCDC_DEMODULATION_MA ( 4 ) +#define WIFI_MODEM_DEMO_CONSUMPTION_LDO_CORRELATION_MA ( 24 ) +#define WIFI_MODEM_DEMO_CONSUMPTION_LDO_DEMODULATION_MA ( 8 ) +#define WIFI_MODEM_DEMO_SCAN_ABORT_ON_TIMEOUT ( false ) +#define DEMO_MODEM_WIFI_MAX_RESULTS_PER_SCAN ( 32 ) + +DemoModemWifi::DemoModemWifi( DeviceModem* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface ) + : DemoModemInterface( device, signaling, communication_interface ), state( DEMO_MODEM_WIFI_INIT ) +{ +} + +void DemoModemWifi::Reset( ) +{ + this->DemoInterface::Reset( ); + this->state = DEMO_MODEM_WIFI_INIT; + this->results.nbrResults = 0; + this->results.global_consumption_uas = 0; +} + +void DemoModemWifi::SpecificRuntime( ) +{ + switch( this->state ) + { + case DEMO_MODEM_WIFI_INIT: + { + this->state = DEMO_MODEM_WIFI_SCAN; + lr1110_modem_wifi_reset_cumulative_timing( this->device->GetRadio( ) ); + break; + } + + case DEMO_MODEM_WIFI_SCAN: + { + this->SetWaitingForInterrupt( ); + + lr1110_modem_wifi_cfg_hardware_debarker( this->device->GetRadio( ), true ); + this->ExecuteScan( this->device->GetRadio( ) ); + + this->state = DEMO_MODEM_WIFI_WAIT_FOR_SCAN; + signaling->StartCapture( ); + + break; + } + + case DEMO_MODEM_WIFI_WAIT_FOR_SCAN: + { + if( this->InterruptHasRaised( ) ) + { + if( this->last_received_event.event_type == LR1110_MODEM_LORAWAN_EVENT_WIFI_SCAN_DONE ) + { + this->FetchAndSaveResults( this->last_received_event.buffer, this->last_received_event.buffer_len ); + this->state = DEMO_MODEM_WIFI_TERMINATED; + } + else + { + this->SetWaitingForInterrupt( ); + this->state = DEMO_MODEM_WIFI_WAIT_FOR_SCAN; + } + } + else + { + this->SetWaitingForInterrupt( ); + this->state = DEMO_MODEM_WIFI_WAIT_FOR_SCAN; + } + break; + } + + case DEMO_MODEM_WIFI_TERMINATED: + { + this->state = DEMO_MODEM_WIFI_INIT; + this->Terminate( ); + break; + } + } +} + +void DemoModemWifi::SpecificStop( ) { signaling->StopCapture( ); } + +const demo_wifi_scan_all_results_t* DemoModemWifi::GetResult( ) const { return &this->results; } + +uint32_t DemoModemWifi::ComputeConsumption( const lr1110_modem_system_reg_mode_t regMode, + const lr1110_modem_wifi_cumulative_timings_t& timing ) +{ + uint32_t consumption_uas = 0; + + switch( regMode ) + { + case LR1110_MODEM_SYSTEM_REG_MODE_LDO: + consumption_uas = + ( ( timing.rx_correlation_us + timing.rx_capture_us ) * WIFI_MODEM_DEMO_CONSUMPTION_LDO_CORRELATION_MA + + timing.demodulation_us * WIFI_MODEM_DEMO_CONSUMPTION_LDO_DEMODULATION_MA ) / + 1000; + break; + case LR1110_MODEM_SYSTEM_REG_MODE_DCDC: + consumption_uas = + ( ( timing.rx_correlation_us + timing.rx_capture_us ) * WIFI_MODEM_DEMO_CONSUMPTION_DCDC_CORRELATION_MA + + timing.demodulation_us * WIFI_MODEM_DEMO_CONSUMPTION_DCDC_DEMODULATION_MA ) / + 1000; + break; + } + + return consumption_uas; +} + +void DemoModemWifi::Configure( demo_wifi_settings_t& config ) { this->settings = config; } + +void DemoModemWifi::ExecuteScan( radio_t* radio ) +{ + lr1110_modem_wifi_passive_scan( + this->device->GetRadio( ), DemoModemWifi::modem_wifi_scan_type_from_demo( this->settings.types ), + this->settings.channels, DemoModemWifi::modem_wifi_mode_from_demo( this->settings.scan_mode ), + this->settings.max_results, this->settings.nbr_retrials, this->settings.timeout, + WIFI_MODEM_DEMO_SCAN_ABORT_ON_TIMEOUT, this->ResultFormatFromSetting( this->settings.result_type ) ); +} + +void DemoModemWifi::FetchAndSaveResults( const uint8_t* buffer, uint16_t buffer_length ) +{ + lr1110_modem_wifi_cumulative_timings_t wifi_results_timings = { 0 }; + lr1110_modem_wifi_read_cumulative_timing( this->device->GetRadio( ), &wifi_results_timings ); + + uint32_t consumption_uas = + DemoModemWifi::ComputeConsumption( LR1110_MODEM_SYSTEM_REG_MODE_DCDC, wifi_results_timings ); + this->results.timings = DemoModemWifi::demo_wifi_timing_from_modem( wifi_results_timings ); + this->results.global_consumption_uas += consumption_uas; + this->results.error = false; + switch( this->settings.result_type ) + { + case DEMO_WIFI_RESULT_TYPE_BASIC_COMPLETE: + { + this->ParseAndSaveBasicCompleteResults( buffer, buffer_length ); + break; + } + case DEMO_WIFI_RESULT_TYPE_BASIC_MAC_TYPE_CHANNEL: + { + this->ParseAndSaveBasicMacChannelTypeResults( buffer, buffer_length ); + break; + } + } +} + +void DemoModemWifi::ParseAndSaveBasicCompleteResults( const uint8_t* buffer, uint16_t buffer_length ) +{ + lr1110_modem_wifi_basic_complete_result_t wifi_results_mac_addr[DEMO_MODEM_WIFI_MAX_RESULTS_PER_SCAN] = { 0 }; + uint8_t nb_result_parsed = 0; + + lr1110_modem_wifi_read_complete_results( buffer, buffer_length, wifi_results_mac_addr, &nb_result_parsed ); + + AddScanToResults( LR1110_MODEM_SYSTEM_REG_MODE_DCDC, this->results, wifi_results_mac_addr, nb_result_parsed ); +} + +void DemoModemWifi::ParseAndSaveBasicMacChannelTypeResults( const uint8_t* buffer, uint16_t buffer_length ) +{ + lr1110_modem_wifi_basic_mac_type_channel_result_t wifi_results_mac_addr[DEMO_MODEM_WIFI_MAX_RESULTS_PER_SCAN] = { + 0 + }; + uint8_t nb_result_parsed = 0; + + lr1110_modem_wifi_read_basic_results( buffer, buffer_length, wifi_results_mac_addr, &nb_result_parsed ); + + AddScanToResults( LR1110_MODEM_SYSTEM_REG_MODE_DCDC, this->results, wifi_results_mac_addr, nb_result_parsed ); +} + +void DemoModemWifi::AddScanToResults( const lr1110_modem_system_reg_mode_t regMode, + demo_wifi_scan_all_results_t& results, + const lr1110_modem_wifi_basic_complete_result_t* scan_result, + const uint8_t nbr_results ) +{ + for( uint8_t index = 0; ( index < nbr_results ) && ( results.nbrResults < DEMO_WIFI_MAX_RESULT_TOTAL ); index++ ) + { + const lr1110_modem_wifi_basic_complete_result_t* local_basic_result = &scan_result[index]; + results.results[results.nbrResults].channel = + lr1110_modem_extract_channel_from_info_byte( local_basic_result->channel_info_byte ); + + results.results[results.nbrResults].type = DemoModemWifi::demo_wifi_types_from_modem( + lr1110_modem_extract_signal_type_from_data_rate_info( local_basic_result->data_rate_info_byte ) ); + + memcpy( results.results[results.nbrResults].mac_address, local_basic_result->mac_address, + LR1110_WIFI_MAC_ADDRESS_LENGTH ); + + results.results[results.nbrResults].rssi = local_basic_result->rssi; + results.results[results.nbrResults].country_code[0] = '?'; + results.results[results.nbrResults].country_code[1] = '?'; + results.nbrResults++; + } +} + +void DemoModemWifi::AddScanToResults( const lr1110_modem_system_reg_mode_t regMode, + demo_wifi_scan_all_results_t& results, + const lr1110_modem_wifi_basic_mac_type_channel_result_t* scan_result, + const uint8_t nbr_results ) +{ + for( uint8_t index = 0; ( index < nbr_results ) && ( results.nbrResults < DEMO_WIFI_MAX_RESULT_TOTAL ); index++ ) + { + const lr1110_modem_wifi_basic_mac_type_channel_result_t* local_basic_result = &scan_result[index]; + results.results[results.nbrResults].channel = + lr1110_modem_extract_channel_from_info_byte( local_basic_result->channel_info_byte ); + + results.results[results.nbrResults].type = DemoModemWifi::demo_wifi_types_from_modem( + lr1110_modem_extract_signal_type_from_data_rate_info( local_basic_result->data_rate_info_byte ) ); + + memcpy( results.results[results.nbrResults].mac_address, local_basic_result->mac_address, + LR1110_WIFI_MAC_ADDRESS_LENGTH ); + + results.results[results.nbrResults].rssi = local_basic_result->rssi; + results.results[results.nbrResults].country_code[0] = '?'; + results.results[results.nbrResults].country_code[1] = '?'; + results.nbrResults++; + } +} + +lr1110_modem_wifi_result_format_t DemoModemWifi::ResultFormatFromSetting( demo_wifi_result_type_t result_setting ) +{ + lr1110_modem_wifi_result_format_t result_type = LR1110_MODEM_WIFI_RESULT_FORMAT_BASIC_COMPLETE; + switch( result_setting ) + { + case DEMO_WIFI_RESULT_TYPE_BASIC_COMPLETE: + { + result_type = LR1110_MODEM_WIFI_RESULT_FORMAT_BASIC_COMPLETE; + break; + } + case DEMO_WIFI_RESULT_TYPE_BASIC_MAC_TYPE_CHANNEL: + { + result_type = LR1110_MODEM_WIFI_RESULT_FORMAT_BASIC_MAC_TYPE_CHANNEL; + break; + } + } + return result_type; +} + +demo_wifi_timings_t DemoModemWifi::demo_wifi_timing_from_modem( + const lr1110_modem_wifi_cumulative_timings_t& modem_timings ) +{ + demo_wifi_timings_t demo_timing; + demo_timing.demodulation_us = modem_timings.demodulation_us; + demo_timing.rx_capture_us = modem_timings.rx_capture_us; + demo_timing.rx_correlation_us = modem_timings.rx_correlation_us; + demo_timing.rx_detection_us = modem_timings.rx_detection_us; + return demo_timing; +} + +lr1110_modem_wifi_mode_t DemoModemWifi::modem_wifi_mode_from_demo( const demo_wifi_mode_t& demo_wifi_mode ) +{ + lr1110_modem_wifi_mode_t modem_wifi_mode = LR1110_MODEM_WIFI_SCAN_MODE_BEACON; + switch( demo_wifi_mode ) + { + case DEMO_WIFI_SCAN_MODE_BEACON: + { + modem_wifi_mode = LR1110_MODEM_WIFI_SCAN_MODE_BEACON; + break; + } + + case DEMO_WIFI_SCAN_MODE_BEACON_AND_PACKET: + { + modem_wifi_mode = LR1110_MODEM_WIFI_SCAN_MODE_BEACON_AND_PACKET; + break; + } + } + return modem_wifi_mode; +} + +lr1110_modem_wifi_signal_type_scan_t DemoModemWifi::modem_wifi_scan_type_from_demo( + const demo_wifi_signal_type_scan_t& demo_wifi_scan_type ) +{ + lr1110_modem_wifi_signal_type_scan_t modem_wifi_signal_type = LR1110_MODEM_WIFI_TYPE_SCAN_B; + switch( demo_wifi_scan_type ) + { + case DEMO_WIFI_SETTING_TYPE_B: + { + modem_wifi_signal_type = LR1110_MODEM_WIFI_TYPE_SCAN_B; + break; + } + + case DEMO_WIFI_SETTING_TYPE_G: + { + modem_wifi_signal_type = LR1110_MODEM_WIFI_TYPE_SCAN_G; + break; + } + + case DEMO_WIFI_SETTING_TYPE_N: + { + modem_wifi_signal_type = LR1110_MODEM_WIFI_TYPE_SCAN_N; + break; + } + + case DEMO_WIFI_SETTING_TYPE_B_G_N: + { + modem_wifi_signal_type = LR1110_MODEM_WIFI_TYPE_SCAN_B_G_N; + break; + } + } + return modem_wifi_signal_type; +} + +demo_wifi_signal_type_t DemoModemWifi::demo_wifi_types_from_modem( + lr1110_modem_wifi_signal_type_result_t wifi_type_result ) +{ + demo_wifi_signal_type_t modem_wifi_type = DEMO_WIFI_TYPE_B; + switch( wifi_type_result ) + { + case LR1110_MODEM_WIFI_TYPE_RESULT_B: + { + modem_wifi_type = DEMO_WIFI_TYPE_B; + break; + } + + case LR1110_MODEM_WIFI_TYPE_RESULT_G: + { + modem_wifi_type = DEMO_WIFI_TYPE_G; + break; + } + + case LR1110_MODEM_WIFI_TYPE_RESULT_N: + { + modem_wifi_type = DEMO_WIFI_TYPE_N; + break; + } + } + return modem_wifi_type; +} \ No newline at end of file diff --git a/embedded/demo/src/demo_gnss_assisted.cpp b/embedded/demo/src/demo_transceiver_gnss_assisted.cpp similarity index 62% rename from embedded/demo/src/demo_gnss_assisted.cpp rename to embedded/demo/src/demo_transceiver_gnss_assisted.cpp index 59ddf70..6112daa 100644 --- a/embedded/demo/src/demo_gnss_assisted.cpp +++ b/embedded/demo/src/demo_transceiver_gnss_assisted.cpp @@ -1,5 +1,5 @@ /** - * @file demo_gnss_assisted.cpp + * @file demo_transceiver_gnss_assisted.cpp * * @brief Implementation of the GNSS assisted demonstration. * @@ -29,25 +29,27 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_gnss_assisted.h" +#include "demo_transceiver_gnss_assisted.h" #include "lr1110_gnss.h" #define DEMO_GNSS_LIMIT_ALMANAC_AGE_DAYS ( 31 ) -DemoGnssAssisted::DemoGnssAssisted( DeviceTransceiver* device, SignalingInterface* signaling, - EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, - TimerInterface* timer, CommunicationInterface* communication_interface ) - : DemoGnssBase( device, signaling, environment, antenna_selector, timer, communication_interface ) +DemoTransceiverGnssAssisted::DemoTransceiverGnssAssisted( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, + TimerInterface* timer, + CommunicationInterface* communication_interface ) + : DemoTransceiverGnssInterface( device, signaling, environment, antenna_selector, timer, communication_interface ) { } -DemoGnssAssisted::~DemoGnssAssisted( ) {} +DemoTransceiverGnssAssisted::~DemoTransceiverGnssAssisted( ) {} -void DemoGnssAssisted::CallScan( ) +void DemoTransceiverGnssAssisted::CallScan( ) { const lr1110_gnss_date_t gnss_time = - DemoGnssBase::GnssTimeFromEnvironment( this->GetEnvironment( )->GetDateTime( ) ); + DemoTransceiverGnssInterface::GnssTimeFromEnvironment( this->GetEnvironment( )->GetDateTime( ) ); lr1110_gnss_solver_assistance_position_t gnss_position = { 0 }; - DemoGnssAssisted::GnssPositionFromEnvironment( this->GetEnvironment( )->GetLocation( ), gnss_position ); + DemoTransceiverGnssAssisted::GnssPositionFromEnvironment( this->GetEnvironment( )->GetLocation( ), gnss_position ); if( !this->CheckAndStoreAlmanacAge( DEMO_GNSS_LIMIT_ALMANAC_AGE_DAYS ) ) { @@ -56,19 +58,20 @@ void DemoGnssAssisted::CallScan( ) lr1110_gnss_set_assistance_position( this->device->GetRadio( ), &gnss_position ); - if( this->GetSettings( ).capture_mode == LR1110_GNSS_DOUBLE_SCAN_MODE ) + if( this->GetSettings( ).capture_mode == DEMO_GNSS_DOUBLE_SCAN_MODE ) { this->timer->set_and_start( 30005 ); } lr1110_gnss_scan_assisted( - this->device->GetRadio( ), gnss_time, this->GetSettings( ).option, + this->device->GetRadio( ), gnss_time, + DemoTransceiverGnssInterface::TransceiverSearchModeFromDemo( this->GetSettings( ).option ), LR1110_GNSS_BIT_CHANGE_MASK | LR1110_GNSS_DOPPLER_MASK | LR1110_GNSS_IRQ_PSEUDO_RANGE_MASK, this->GetSettings( ).nb_satellites ); } -void DemoGnssAssisted::GnssPositionFromEnvironment( const environment_location_t& location, - lr1110_gnss_solver_assistance_position_t& gnss_position ) +void DemoTransceiverGnssAssisted::GnssPositionFromEnvironment( const environment_location_t& location, + lr1110_gnss_solver_assistance_position_t& gnss_position ) { gnss_position.latitude = location.latitude; gnss_position.longitude = location.longitude; diff --git a/embedded/demo/src/demo_gnss_autonomous.cpp b/embedded/demo/src/demo_transceiver_gnss_autonomous.cpp similarity index 64% rename from embedded/demo/src/demo_gnss_autonomous.cpp rename to embedded/demo/src/demo_transceiver_gnss_autonomous.cpp index c9f1b1c..77812c7 100644 --- a/embedded/demo/src/demo_gnss_autonomous.cpp +++ b/embedded/demo/src/demo_transceiver_gnss_autonomous.cpp @@ -1,5 +1,5 @@ /** - * @file demo_gnss_autonomous.cpp + * @file demo_transceiver_gnss_autonomous.cpp * * @brief Implementation of the GNSS autonomous demonstration. * @@ -29,30 +29,33 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_gnss_autonomous.h" +#include "demo_transceiver_gnss_autonomous.h" #include "lr1110_gnss.h" -DemoGnssAutonomous::DemoGnssAutonomous( DeviceTransceiver* device, SignalingInterface* signaling, - EnvironmentInterface* environment, AntennaSelectorInterface* antenna_selector, - TimerInterface* timer, CommunicationInterface* communication_interface ) - : DemoGnssBase( device, signaling, environment, antenna_selector, timer, communication_interface ) +DemoTransceiverGnssAutonomous::DemoTransceiverGnssAutonomous( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, + TimerInterface* timer, + CommunicationInterface* communication_interface ) + : DemoTransceiverGnssInterface( device, signaling, environment, antenna_selector, timer, communication_interface ) { } -DemoGnssAutonomous::~DemoGnssAutonomous( ) {} +DemoTransceiverGnssAutonomous::~DemoTransceiverGnssAutonomous( ) {} -void DemoGnssAutonomous::CallScan( ) +void DemoTransceiverGnssAutonomous::CallScan( ) { const lr1110_gnss_date_t gnss_time = - DemoGnssBase::GnssTimeFromEnvironment( this->GetEnvironment( )->GetDateTime( ) ); + DemoTransceiverGnssInterface::GnssTimeFromEnvironment( this->GetEnvironment( )->GetDateTime( ) ); - if( this->GetSettings( ).capture_mode == LR1110_GNSS_DOUBLE_SCAN_MODE ) + if( this->GetSettings( ).capture_mode == DEMO_GNSS_DOUBLE_SCAN_MODE ) { this->timer->set_and_start( 30000 ); } lr1110_gnss_scan_autonomous( this->device->GetRadio( ), gnss_time, + DemoTransceiverGnssInterface::TransceiverSearchModeFromDemo( this->GetSettings( ).option ), LR1110_GNSS_BIT_CHANGE_MASK | LR1110_GNSS_DOPPLER_MASK | LR1110_GNSS_IRQ_PSEUDO_RANGE_MASK, this->GetSettings( ).nb_satellites ); } diff --git a/embedded/demo/src/demo_gnss_base.cpp b/embedded/demo/src/demo_transceiver_gnss_interface.cpp similarity index 71% rename from embedded/demo/src/demo_gnss_base.cpp rename to embedded/demo/src/demo_transceiver_gnss_interface.cpp index 92dd347..c20ed16 100644 --- a/embedded/demo/src/demo_gnss_base.cpp +++ b/embedded/demo/src/demo_transceiver_gnss_interface.cpp @@ -1,5 +1,5 @@ /** - * @file demo_gnss_base.cpp + * @file demo_transceiver_gnss_interface.cpp * * @brief Implementation of the components shared by GNSS demonstrations. * @@ -30,21 +30,22 @@ */ #include -#include "demo_gnss_base.h" +#include "demo_transceiver_gnss_interface.h" #include "lr1110_gnss.h" #include "system_lptim.h" #define DEMO_GNSS_CONSUMPTION_DCDC_ACQUISITION_MA ( 11 ) #define DEMO_GNSS_CONSUMPTION_DCDC_COMPUTATION_MA ( 6 ) -DemoGnssBase::DemoGnssBase( DeviceTransceiver* device, SignalingInterface* signaling, EnvironmentInterface* environment, - AntennaSelectorInterface* antenna_selector, TimerInterface* timer, - CommunicationInterface* communication_interface ) - : DemoTransceiverBase( device, signaling, communication_interface ), +DemoTransceiverGnssInterface::DemoTransceiverGnssInterface( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + AntennaSelectorInterface* antenna_selector, + TimerInterface* timer, + CommunicationInterface* communication_interface ) + : DemoTransceiverInterface( device, signaling, communication_interface, environment ), timer( timer ), gnss_irq( LR1110_SYSTEM_IRQ_GNSS_SCAN_DONE ), state( DEMO_GNSS_BASE_INIT ), - environment( environment ), inter_capture_delay_s( 0 ), instant_start_capture_ms( 0 ), instant_second_capture_ms( 0 ), @@ -52,11 +53,11 @@ DemoGnssBase::DemoGnssBase( DeviceTransceiver* device, SignalingInterface* signa { } -DemoGnssBase::~DemoGnssBase( ) {} +DemoTransceiverGnssInterface::~DemoTransceiverGnssInterface( ) {} -void DemoGnssBase::Reset( ) +void DemoTransceiverGnssInterface::Reset( ) { - this->DemoBase::Reset( ); + this->DemoInterface::Reset( ); this->state = DEMO_GNSS_BASE_INIT; this->result.nb_result = 0; this->result.nav_message.size = 0; @@ -71,17 +72,17 @@ void DemoGnssBase::Reset( ) this->instant_second_capture_ms = 0; } -void DemoGnssBase::JumpToErrorState( const demo_gnss_error_t error_code ) +void DemoTransceiverGnssInterface::JumpToErrorState( const demo_gnss_error_t error_code ) { this->result.error = error_code; this->state = DEMO_GNSS_BASE_ERROR; } -demo_gnss_settings_t DemoGnssBase::GetSettings( ) const { return this->settings; } +demo_gnss_settings_t DemoTransceiverGnssInterface::GetSettings( ) const { return this->settings; } -EnvironmentInterface* DemoGnssBase::GetEnvironment( ) { return this->environment; } +EnvironmentInterface* DemoTransceiverGnssInterface::GetEnvironment( ) { return this->environment; } -void DemoGnssBase::SpecificRuntime( ) +void DemoTransceiverGnssInterface::SpecificRuntime( ) { static uint32_t measurement_instant_s; switch( this->state ) @@ -94,8 +95,10 @@ void DemoGnssBase::SpecificRuntime( ) lr1110_gnss_set_constellations_to_use( this->device->GetRadio( ), this->settings.constellation_mask ); - lr1110_gnss_set_scan_mode( this->device->GetRadio( ), this->settings.capture_mode, - &this->inter_capture_delay_s ); + lr1110_gnss_set_scan_mode( + this->device->GetRadio( ), + DemoTransceiverGnssInterface::TransceiverScanModeFromDemo( this->settings.capture_mode ), + &this->inter_capture_delay_s ); this->SetAntennaSwitch( this->settings.antenna_selection ); @@ -152,15 +155,8 @@ void DemoGnssBase::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - - if( ( irq_status & LR1110_SYSTEM_IRQ_GNSS_SCAN_DONE ) != 0 ) + if( ( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_GNSS_SCAN_DONE ) != 0 ) { - this->ClearRegisteredIrqs( ); this->state = DEMO_GNSS_BASE_GET_RESULTS; this->signaling->StopCapture( ); } @@ -182,17 +178,9 @@ void DemoGnssBase::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - - if( ( irq_status & LR1110_SYSTEM_IRQ_GNSS_SCAN_DONE ) != 0 ) + if( ( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_GNSS_SCAN_DONE ) != 0 ) { - this->ClearRegisteredIrqs( ); - - if( this->settings.capture_mode == LR1110_GNSS_SINGLE_SCAN_MODE ) + if( this->settings.capture_mode == DEMO_GNSS_SINGLE_SCAN_MODE ) { this->state = DEMO_GNSS_BASE_GET_RESULTS; } @@ -238,11 +226,13 @@ void DemoGnssBase::SpecificRuntime( ) break; } - if( DemoGnssBase::CanFetchResults( this->result.nav_message ) ) + if( DemoTransceiverGnssInterface::CanFetchResults( this->result.nav_message ) ) { lr1110_gnss_get_nb_detected_satellites( this->device->GetRadio( ), &nb_sv_detected ); lr1110_gnss_get_detected_satellites( this->device->GetRadio( ), nb_sv_detected, list_of_sv ); - lr1110_gnss_get_timings( this->device->GetRadio( ), &this->result.timings ); + lr1110_gnss_timings_t tansceiver_timings = {}; + lr1110_gnss_get_timings( this->device->GetRadio( ), &tansceiver_timings ); + this->result.timings = DemoTransceiverGnssInterface::DemoTimingFromTransceiver( tansceiver_timings ); this->result.consumption_uas = ( this->result.timings.radio_ms * DEMO_GNSS_CONSUMPTION_DCDC_ACQUISITION_MA + @@ -272,7 +262,8 @@ void DemoGnssBase::SpecificRuntime( ) } else { - const demo_gnss_error_t error_code = DemoGnssBase::GetHostErrorFromResult( this->result.nav_message ); + const demo_gnss_error_t error_code = + DemoTransceiverGnssInterface::GetHostErrorFromResult( this->result.nav_message ); this->JumpToErrorState( error_code ); this->communication_interface->Log( "Error during GNSS scan\n" ); } @@ -294,17 +285,17 @@ void DemoGnssBase::SpecificRuntime( ) } } -void DemoGnssBase::SpecificStop( ) { signaling->StopCapture( ); } +void DemoTransceiverGnssInterface::SpecificStop( ) { signaling->StopCapture( ); } -bool DemoGnssBase::CanFetchResults( demo_gnss_nav_result_t& nav_message ) +bool DemoTransceiverGnssInterface::CanFetchResults( demo_gnss_nav_result_t& nav_message ) { - if( DemoGnssBase::IsResultToSolver( nav_message ) ) + if( DemoTransceiverGnssInterface::IsResultToSolver( nav_message ) ) { return true; } else { - const demo_gnss_error_t error_code = DemoGnssBase::GetHostErrorFromResult( nav_message ); + const demo_gnss_error_t error_code = DemoTransceiverGnssInterface::GetHostErrorFromResult( nav_message ); if( error_code == DEMO_GNSS_BASE_ERROR_NO_SATELLITE ) { // In the case where no satellite has been detected, it is still ok @@ -318,18 +309,16 @@ bool DemoGnssBase::CanFetchResults( demo_gnss_nav_result_t& nav_message ) } } -void DemoGnssBase::SpecificInterruptHandler( ) {} +void DemoTransceiverGnssInterface::Configure( demo_gnss_settings_t& config ) { this->settings = config; } -void DemoGnssBase::Configure( demo_gnss_settings_t& config ) { this->settings = config; } +const demo_gnss_all_results_t* DemoTransceiverGnssInterface::GetResult( ) const { return &this->result; } -const demo_gnss_all_results_t* DemoGnssBase::GetResult( ) const { return &this->result; } - -void DemoGnssBase::ClearRegisteredIrqs( ) const +void DemoTransceiverGnssInterface::ClearRegisteredIrqs( ) const { lr1110_system_clear_irq_status( this->device->GetRadio( ), this->gnss_irq ); } -void DemoGnssBase::SetAntennaSwitch( const demo_gnss_antenna_selection_t antenna_selection ) +void DemoTransceiverGnssInterface::SetAntennaSwitch( const demo_gnss_antenna_selection_t antenna_selection ) { switch( antenna_selection ) { @@ -352,13 +341,13 @@ void DemoGnssBase::SetAntennaSwitch( const demo_gnss_antenna_selection_t antenna } } -lr1110_gnss_date_t DemoGnssBase::GnssTimeFromEnvironment( environment_date_time_t date_time ) +lr1110_gnss_date_t DemoTransceiverGnssInterface::GnssTimeFromEnvironment( environment_date_time_t date_time ) { lr1110_gnss_date_t gnss_time = date_time; return gnss_time; } -void DemoGnssBase::AskAndStoreDate( ) +void DemoTransceiverGnssInterface::AskAndStoreDate( ) { environment_location_t initial_position; lr1110_gnss_date_t actual_time; @@ -373,7 +362,7 @@ void DemoGnssBase::AskAndStoreDate( ) } } -bool DemoGnssBase::IsResultToSolver( const demo_gnss_nav_result_t& nav_result ) +bool DemoTransceiverGnssInterface::IsResultToSolver( const demo_gnss_nav_result_t& nav_result ) { if( nav_result.size >= 2 ) { @@ -385,7 +374,7 @@ bool DemoGnssBase::IsResultToSolver( const demo_gnss_nav_result_t& nav_result ) } } -bool DemoGnssBase::IsResultToHost( const demo_gnss_nav_result_t& nav_result ) +bool DemoTransceiverGnssInterface::IsResultToHost( const demo_gnss_nav_result_t& nav_result ) { if( nav_result.size >= 2 ) { @@ -397,10 +386,10 @@ bool DemoGnssBase::IsResultToHost( const demo_gnss_nav_result_t& nav_result ) } } -demo_gnss_error_t DemoGnssBase::GetHostErrorFromResult( const demo_gnss_nav_result_t& nav_result ) +demo_gnss_error_t DemoTransceiverGnssInterface::GetHostErrorFromResult( const demo_gnss_nav_result_t& nav_result ) { demo_gnss_error_t error = DEMO_GNSS_BASE_ERROR_UNKNOWN; - if( DemoGnssBase::IsResultToHost( nav_result ) ) + if( DemoTransceiverGnssInterface::IsResultToHost( nav_result ) ) { const lr1110_gnss_message_host_status_t status_code_raw = ( lr1110_gnss_message_host_status_t ) nav_result.message[1]; @@ -434,7 +423,7 @@ demo_gnss_error_t DemoGnssBase::GetHostErrorFromResult( const demo_gnss_nav_resu return error; } -uint16_t DemoGnssBase::GetAlmanacAgeFromGpsEpochInDays( const uint16_t almanac_age ) +uint16_t DemoTransceiverGnssInterface::GetAlmanacAgeFromGpsEpochInDays( const uint16_t almanac_age ) { // The almanac_age is the number of days since last GPS week number rollover // As we are in year 2020, our last rollover was on April 7th 2019. The next @@ -444,13 +433,64 @@ uint16_t DemoGnssBase::GetAlmanacAgeFromGpsEpochInDays( const uint16_t almanac_a // (and now I'm a 50 year old guy... Greetings from the past ;) ) // Let's convert in the number of days elapsed since GPS epoch (January - // 6th 1970) + // 6th 1980) const uint16_t days_between_2019_rollover_to_epoch = 14336; const uint16_t almanac_age_days_since_gps_epoch = almanac_age + days_between_2019_rollover_to_epoch; return almanac_age_days_since_gps_epoch; } -uint16_t DemoGnssBase::GetAlmanacAgeDaysSinceToday( ) const +lr1110_gnss_search_mode_t DemoTransceiverGnssInterface::TransceiverSearchModeFromDemo( + const demo_gnss_search_mode_t& demo_search_mode ) +{ + lr1110_gnss_search_mode_t transceiver_search_mode = LR1110_GNSS_OPTION_DEFAULT; + switch( demo_search_mode ) + { + case DEMO_GNSS_OPTION_DEFAULT: + { + transceiver_search_mode = LR1110_GNSS_OPTION_DEFAULT; + break; + } + + case DEMO_GNSS_OPTION_BEST_EFFORT: + { + transceiver_search_mode = LR1110_GNSS_OPTION_BEST_EFFORT; + break; + } + } + return transceiver_search_mode; +} + +lr1110_gnss_scan_mode_t DemoTransceiverGnssInterface::TransceiverScanModeFromDemo( + const demo_gnss_scan_mode_t& demo_scan_mode ) +{ + lr1110_gnss_scan_mode_t transceiver_scan_mode = LR1110_GNSS_SINGLE_SCAN_MODE; + switch( demo_scan_mode ) + { + case DEMO_GNSS_SINGLE_SCAN_MODE: + { + transceiver_scan_mode = LR1110_GNSS_SINGLE_SCAN_MODE; + break; + } + + case DEMO_GNSS_DOUBLE_SCAN_MODE: + { + transceiver_scan_mode = LR1110_GNSS_DOUBLE_SCAN_MODE; + break; + } + } + return transceiver_scan_mode; +} + +demo_gnss_timings_t DemoTransceiverGnssInterface::DemoTimingFromTransceiver( + const lr1110_gnss_timings_s& transceiver_timings ) +{ + demo_gnss_timings_t demo_timings = {}; + demo_timings.computation_ms = transceiver_timings.computation_ms; + demo_timings.radio_ms = transceiver_timings.radio_ms; + return demo_timings; +} + +uint16_t DemoTransceiverGnssInterface::GetAlmanacAgeDaysSinceToday( ) const { // First, we get the age of the almanac of the satellite id 0 uint16_t almanac_age = 0; @@ -458,7 +498,8 @@ uint16_t DemoGnssBase::GetAlmanacAgeDaysSinceToday( ) const // Then we convert the age from almanac into number of days elapsed since // GPS epoch - const uint16_t almanac_age_since_epoch = DemoGnssBase::GetAlmanacAgeFromGpsEpochInDays( almanac_age ); + const uint16_t almanac_age_since_epoch = + DemoTransceiverGnssInterface::GetAlmanacAgeFromGpsEpochInDays( almanac_age ); // We get the actual time in days const time_t now_seconds = this->environment->GetDateTime( ); @@ -468,19 +509,19 @@ uint16_t DemoGnssBase::GetAlmanacAgeDaysSinceToday( ) const return almanac_age_since_update; } -bool DemoGnssBase::IsAlmanacTooOld( uint16_t almanac_age_days, const uint16_t days_limit ) +bool DemoTransceiverGnssInterface::IsAlmanacTooOld( uint16_t almanac_age_days, const uint16_t days_limit ) { return almanac_age_days > days_limit; } -bool DemoGnssBase::CheckAndStoreAlmanacAge( const uint16_t days_limit ) +bool DemoTransceiverGnssInterface::CheckAndStoreAlmanacAge( const uint16_t days_limit ) { const uint16_t almanac_age_days = this->GetAlmanacAgeDaysSinceToday( ); - const bool almanac_too_old = DemoGnssBase::IsAlmanacTooOld( almanac_age_days, days_limit ); + const bool almanac_too_old = DemoTransceiverGnssInterface::IsAlmanacTooOld( almanac_age_days, days_limit ); this->result.almanac_age_days = almanac_age_days; this->result.almanac_too_old = almanac_too_old; return !almanac_too_old; -} \ No newline at end of file +} diff --git a/embedded/demo/src/demo_transceiver_interface.cpp b/embedded/demo/src/demo_transceiver_interface.cpp new file mode 100644 index 0000000..3f530e2 --- /dev/null +++ b/embedded/demo/src/demo_transceiver_interface.cpp @@ -0,0 +1,53 @@ +/** + * @file demo_transceiver_interface.cpp + * + * @brief Implementation of transceiver demo class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "demo_transceiver_interface.h" + +DemoTransceiverInterface::DemoTransceiverInterface( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ) + : DemoInterface( device, signaling, communication_interface ), + environment( environment ), + last_received_irq_mask( 0 ), + last_irq_received_instant_ms( 0 ) +{ +} + +void DemoTransceiverInterface::SpecificInterruptHandler( const InterruptionInterface* interruption ) +{ + const InterruptionIrq* interrupt = dynamic_cast< const InterruptionIrq* >( interruption ); + if( interrupt != 0 ) + { + this->last_received_irq_mask = interrupt->get_irq_mask( ); + this->last_received_stat_1 = interrupt->get_stat_1( ); + this->last_irq_received_instant_ms = environment->GetLocalTimeMilliseconds( ); + } +} \ No newline at end of file diff --git a/embedded/demo/src/demo_radio_interface.cpp b/embedded/demo/src/demo_transceiver_radio_interface.cpp similarity index 73% rename from embedded/demo/src/demo_radio_interface.cpp rename to embedded/demo/src/demo_transceiver_radio_interface.cpp index 4596290..c07641e 100644 --- a/embedded/demo/src/demo_radio_interface.cpp +++ b/embedded/demo/src/demo_transceiver_radio_interface.cpp @@ -1,5 +1,5 @@ /** - * @file demo_radio_interface.cpp + * @file demo_transceiver_radio_interface.cpp * * @brief Implementation of the radio demonstration interface. * @@ -29,17 +29,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_radio_interface.h" +#include "demo_transceiver_radio_interface.h" -DemoRadioInterface::DemoRadioInterface( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ) - : DemoTransceiverBase( device, signaling, communication_interface ) +DemoTransceiverRadioInterface::DemoTransceiverRadioInterface( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ) + : DemoTransceiverInterface( device, signaling, communication_interface, environment ) { } -DemoRadioInterface::~DemoRadioInterface( ) {} +DemoTransceiverRadioInterface::~DemoTransceiverRadioInterface( ) {} -void DemoRadioInterface::Configure( demo_radio_settings_t& settings ) +void DemoTransceiverRadioInterface::Configure( demo_radio_settings_t& settings ) { this->settings = settings; diff --git a/embedded/demo/src/demo_radio_per.cpp b/embedded/demo/src/demo_transceiver_radio_per.cpp similarity index 77% rename from embedded/demo/src/demo_radio_per.cpp rename to embedded/demo/src/demo_transceiver_radio_per.cpp index e47eb7b..4386d9e 100644 --- a/embedded/demo/src/demo_radio_per.cpp +++ b/embedded/demo/src/demo_transceiver_radio_per.cpp @@ -1,5 +1,5 @@ /** - * @file demo_radio_per.cpp + * @file demo_transceiver_radio_per.cpp * * @brief Implementation of the Packet Error Rate demonstration. * @@ -29,13 +29,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_radio_per.h" +#include "demo_transceiver_radio_per.h" #include "lr1110_radio.h" -DemoRadioPer::DemoRadioPer( DeviceTransceiver* device, SignalingInterface* signaling, EnvironmentInterface* environment, - CommunicationInterface* communication_interface, demo_radio_per_mode_t mode ) - : DemoRadioInterface( device, signaling, communication_interface ), - environment( environment ), +DemoTransceiverRadioPer::DemoTransceiverRadioPer( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + CommunicationInterface* communication_interface, + demo_radio_per_mode_t mode ) + : DemoTransceiverRadioInterface( device, signaling, communication_interface, environment ), state( DEMO_RADIO_PER_STATE_INIT ), has_intermediate_results( false ), mode( mode ) @@ -44,9 +45,9 @@ DemoRadioPer::DemoRadioPer( DeviceTransceiver* device, SignalingInterface* signa this->settings = {}; } -DemoRadioPer::~DemoRadioPer( ) {} +DemoTransceiverRadioPer::~DemoTransceiverRadioPer( ) {} -void DemoRadioPer::SpecificRuntime( ) +void DemoTransceiverRadioPer::SpecificRuntime( ) { const uint32_t now_ms = this->environment->GetLocalTimeMilliseconds( ); const demo_radio_per_state_t previous_state = this->state; @@ -57,7 +58,7 @@ void DemoRadioPer::SpecificRuntime( ) { this->has_intermediate_results = false; - this->device->ResetAndInit( ); + this->device->Init( ); lr1110_radio_set_pkt_type( this->device->GetRadio( ), this->settings.pkt_type ); switch( this->settings.pkt_type ) @@ -74,6 +75,10 @@ void DemoRadioPer::SpecificRuntime( ) lr1110_radio_set_gfsk_pkt_params( this->device->GetRadio( ), &this->settings.packet_gfsk ); break; } + default: + { + break; + } } lr1110_radio_set_rf_freq( this->device->GetRadio( ), this->settings.rf_frequency ); @@ -128,14 +133,8 @@ void DemoRadioPer::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - if( irq_status & LR1110_SYSTEM_IRQ_TX_DONE ) + if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_TX_DONE ) { - lr1110_system_clear_irq_status( this->device->GetRadio( ), LR1110_SYSTEM_IRQ_TX_DONE ); this->results.count_tx++; this->has_intermediate_results = true; this->state = @@ -157,22 +156,16 @@ void DemoRadioPer::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - if( ( irq_status & LR1110_SYSTEM_IRQ_CRC_ERROR ) || ( irq_status & LR1110_SYSTEM_IRQ_HEADER_ERROR ) ) + if( ( this->last_received_irq_mask & ( LR1110_SYSTEM_IRQ_CRC_ERROR | LR1110_SYSTEM_IRQ_HEADER_ERROR ) ) != + 0 ) { - lr1110_system_clear_irq_status( this->device->GetRadio( ), LR1110_SYSTEM_IRQ_ALL_MASK ); this->results.count_rx_wrong_packet++; this->has_intermediate_results = true; this->state = DEMO_RADIO_PER_STATE_SET_RX; } - else if( irq_status & LR1110_SYSTEM_IRQ_RX_DONE ) + else if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_RX_DONE ) { this->signaling->Rx( ); - lr1110_system_clear_irq_status( this->device->GetRadio( ), LR1110_SYSTEM_IRQ_ALL_MASK ); this->results.count_rx_correct_packet++; this->has_intermediate_results = true; this->state = DEMO_RADIO_PER_STATE_SET_RX; @@ -196,7 +189,7 @@ void DemoRadioPer::SpecificRuntime( ) } } -void DemoRadioPer::SpecificStop( ) +void DemoTransceiverRadioPer::SpecificStop( ) { lr1110_system_set_standby( this->device->GetRadio( ), LR1110_SYSTEM_STANDBY_CFG_RC ); @@ -208,12 +201,10 @@ void DemoRadioPer::SpecificStop( ) this->state = DEMO_RADIO_PER_STATE_INIT; } -void DemoRadioPer::LogInfo( ) const {} - -void DemoRadioPer::SpecificInterruptHandler( ) {} +void DemoTransceiverRadioPer::LogInfo( ) const {} -void DemoRadioPer::ClearRegisteredIrqs( ) const {} +void DemoTransceiverRadioPer::ClearRegisteredIrqs( ) const {} -bool DemoRadioPer::HasIntermediateResults( ) const { return this->has_intermediate_results; } +bool DemoTransceiverRadioPer::HasIntermediateResults( ) const { return this->has_intermediate_results; } -const demo_radio_per_results_t* DemoRadioPer::GetResult( ) const { return &this->results; } +const demo_radio_per_results_t* DemoTransceiverRadioPer::GetResult( ) const { return &this->results; } diff --git a/embedded/demo/src/demo_ping_pong.cpp b/embedded/demo/src/demo_transceiver_radio_ping_pong.cpp similarity index 75% rename from embedded/demo/src/demo_ping_pong.cpp rename to embedded/demo/src/demo_transceiver_radio_ping_pong.cpp index 4dbdd32..bfd6b54 100644 --- a/embedded/demo/src/demo_ping_pong.cpp +++ b/embedded/demo/src/demo_transceiver_radio_ping_pong.cpp @@ -1,5 +1,5 @@ /** - * @file demo_ping_pong.cpp + * @file demo_transceiver_radio_ping_pong.cpp * * @brief Implementation of the Ping-Pong demonstration. * @@ -29,7 +29,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_ping_pong.h" +#include "demo_transceiver_radio_ping_pong.h" #include "lr1110_radio.h" #define DEMO_PING_PONG_WAIT_MASTER_PING_TO_PING_TIMEOUT_MS ( 1000 ) @@ -44,33 +44,32 @@ // Slave opens Ping Rx window 5 ms before Master actually sends the Ping #define DEMO_PING_PONG_SLAVE_WAIT_START_PING_RX ( DEMO_PING_PONG_WAIT_MASTER_PING_TO_PING_TIMEOUT_MS - 5 ) -DemoPingPong::DemoPingPong( DeviceTransceiver* device, SignalingInterface* signaling, EnvironmentInterface* environment, - CommunicationInterface* communication_interface ) - : DemoRadioInterface( device, signaling, communication_interface ), - environment( environment ), +DemoTransceiverRadioPingPong::DemoTransceiverRadioPingPong( DeviceTransceiver* device, SignalingInterface* signaling, + EnvironmentInterface* environment, + CommunicationInterface* communication_interface ) + : DemoTransceiverRadioInterface( device, signaling, communication_interface, environment ), mode( DEMO_PING_PONG_MODE_MASTER ), state( DEMO_PING_PONG_STATE_INIT ), - last_irq_received_instant_ms( 0 ), last_tx_done_instant_ms( 0 ), last_rx_done_instant_ms( 0 ), radio_interrupt_mask( LR1110_SYSTEM_IRQ_TX_DONE | LR1110_SYSTEM_IRQ_RX_DONE | LR1110_SYSTEM_IRQ_TIMEOUT ), has_intermediate_results( false ) { - this->results = {}; - this->settings = {}; + this->results = { }; + this->settings = { }; for( uint16_t i = 0; i < DEMO_PING_PONG_MAX_PAYLOAD_SIZE; i++ ) { - this->payload_ping[i] = 0x00; - this->payload_pong[i] = 0x01; + this->payload_ping.content[i] = 0x00; + this->payload_pong.content[i] = 0x01; } } -DemoPingPong::~DemoPingPong( ) {} +DemoTransceiverRadioPingPong::~DemoTransceiverRadioPingPong( ) {} -const demo_ping_pong_results_t* DemoPingPong::GetResult( ) const { return &this->results; } +const demo_ping_pong_results_t* DemoTransceiverRadioPingPong::GetResult( ) const { return &this->results; } -void DemoPingPong::SpecificRuntime( ) +void DemoTransceiverRadioPingPong::SpecificRuntime( ) { const uint32_t now_ms = this->environment->GetLocalTimeMilliseconds( ); const demo_ping_pong_state_t previous_state = this->state; @@ -78,8 +77,11 @@ void DemoPingPong::SpecificRuntime( ) { case DEMO_PING_PONG_STATE_INIT: { - this->results.status = DEMO_PING_PONG_STATUS_OK; - this->results.mode = this->mode; + this->results.status = DEMO_PING_PONG_STATUS_OK; + this->results.mode = this->mode; + this->payload_ping.size = this->settings.payload_length; + this->payload_pong.size = this->settings.payload_length; + if( this->ConfigureRadio( ) == DEMO_PING_PONG_STATUS_OK ) { this->last_tx_done_instant_ms = now_ms; // Fake the instant of last received event @@ -108,12 +110,7 @@ void DemoPingPong::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - if( irq_status & LR1110_SYSTEM_IRQ_TX_DONE ) + if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_TX_DONE ) { this->results.count_tx++; this->FetchStatisticToResults( ); @@ -138,18 +135,12 @@ void DemoPingPong::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - - if( irq_status & LR1110_SYSTEM_IRQ_CRC_ERROR ) + if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_CRC_ERROR ) { - lr1110_system_clear_irq_status( this->device->GetRadio( ), LR1110_SYSTEM_IRQ_CRC_ERROR ); this->results.count_rx_wrong_packet++; + this->communication_interface->Log( "Wrong packet: CRC error\n" ); } - else if( irq_status & LR1110_SYSTEM_IRQ_RX_DONE ) + else if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_RX_DONE ) { demo_ping_pong_fetched_payload_t received_payload = { 0 }; this->FetchPayload( &received_payload ); @@ -171,12 +162,21 @@ void DemoPingPong::SpecificRuntime( ) } else { - this->communication_interface->Log( "Wrong packet\n" ); + this->communication_interface->Log( "Wrong packet: not ping nor pong\n --> payload (%u bytes): ", + received_payload.received_payload.size ); + for( uint8_t index_rx_payload = 0; index_rx_payload < received_payload.received_payload.size; + index_rx_payload++ ) + { + this->communication_interface->Log( + "0x%02x ", received_payload.received_payload.content[index_rx_payload] ); + } + this->communication_interface->Log( "\n" ); + this->communication_interface->Log( "Wrong packet: not ping nor pong\n" ); this->state = DEMO_PING_PONG_STATE_MASTER_WAIT_SEND_PING; this->results.count_rx_wrong_packet++; } } - if( irq_status & LR1110_SYSTEM_IRQ_TIMEOUT ) + if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_TIMEOUT ) { this->communication_interface->Log( "Master Timeout\n" ); this->state = DEMO_PING_PONG_STATE_MASTER_WAIT_SEND_PING; @@ -209,17 +209,11 @@ void DemoPingPong::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - if( irq_status & LR1110_SYSTEM_IRQ_CRC_ERROR ) + if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_CRC_ERROR ) { - lr1110_system_clear_irq_status( this->device->GetRadio( ), LR1110_SYSTEM_IRQ_CRC_ERROR ); this->results.count_rx_wrong_packet++; } - else if( irq_status & LR1110_SYSTEM_IRQ_RX_DONE ) + else if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_RX_DONE ) { demo_ping_pong_fetched_payload_t received_payload = { 0 }; this->FetchPayload( &received_payload ); @@ -245,7 +239,7 @@ void DemoPingPong::SpecificRuntime( ) this->results.count_rx_wrong_packet++; } } - if( irq_status & LR1110_SYSTEM_IRQ_TIMEOUT ) + if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_TIMEOUT ) { // In case of timeout: go back to master this->last_tx_done_instant_ms = this->last_irq_received_instant_ms; @@ -282,12 +276,7 @@ void DemoPingPong::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - if( irq_status & LR1110_SYSTEM_IRQ_TX_DONE ) + if( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_TX_DONE ) { this->ClearRegisteredIrqs( ); this->results.count_tx++; @@ -320,9 +309,9 @@ void DemoPingPong::SpecificRuntime( ) } } -bool DemoPingPong::HasIntermediateResults( ) const { return has_intermediate_results; } +bool DemoTransceiverRadioPingPong::HasIntermediateResults( ) const { return has_intermediate_results; } -void DemoPingPong::SpecificStop( ) +void DemoTransceiverRadioPingPong::SpecificStop( ) { lr1110_system_set_standby( this->device->GetRadio( ), LR1110_SYSTEM_STANDBY_CFG_RC ); @@ -334,18 +323,19 @@ void DemoPingPong::SpecificStop( ) this->state = DEMO_PING_PONG_STATE_INIT; } -void DemoPingPong::LogInfo( ) const +void DemoTransceiverRadioPingPong::LogInfo( ) const { this->communication_interface->Log( "Status: %s\n" "Counters:\n - rx ok: %u\n - tx ok: %u\n - rx timeout: %u\n" " - rx wrong: %u\n" "Last RSSI: %i dBm\n", - DemoPingPong::ModeToString( this->results.mode ), this->results.count_rx_correct_packet, this->results.count_tx, - this->results.count_rx_timeout, this->results.count_rx_wrong_packet, this->results.last_rssi ); + DemoTransceiverRadioPingPong::ModeToString( this->results.mode ), this->results.count_rx_correct_packet, + this->results.count_tx, this->results.count_rx_timeout, this->results.count_rx_wrong_packet, + this->results.last_rssi ); } -const char* DemoPingPong::ModeToString( const demo_ping_pong_mode_t mode ) +const char* DemoTransceiverRadioPingPong::ModeToString( const demo_ping_pong_mode_t mode ) { switch( mode ) { @@ -357,18 +347,17 @@ const char* DemoPingPong::ModeToString( const demo_ping_pong_mode_t mode ) { return ( const char* ) "SLAVE"; } + default: + { + return ( const char* ) "MODE UNKNOWN"; + } } } -void DemoPingPong::SpecificInterruptHandler( ) -{ - this->last_irq_received_instant_ms = environment->GetLocalTimeMilliseconds( ); -} - -demo_ping_pong_status_t DemoPingPong::ConfigureRadio( ) const +demo_ping_pong_status_t DemoTransceiverRadioPingPong::ConfigureRadio( ) const { // 0. Reset the device - this->device->ResetAndInit( ); + this->device->Init( ); // 1. Set packet type lr1110_radio_set_pkt_type( this->device->GetRadio( ), this->settings.pkt_type ); @@ -409,43 +398,43 @@ demo_ping_pong_status_t DemoPingPong::ConfigureRadio( ) const return DEMO_PING_PONG_STATUS_OK; } -void DemoPingPong::StartSendMessage( ) const +void DemoTransceiverRadioPingPong::StartSendMessage( ) const { switch( this->mode ) { case DEMO_PING_PONG_MODE_MASTER: { - DemoPingPong::TransmitPayload( this->device->GetRadio( ), this->payload_ping, this->settings.payload_length, - DEMO_PING_PONG_TX_TIMEOUT_DEFAULT ); + DemoTransceiverRadioPingPong::TransmitPayload( this->device->GetRadio( ), &this->payload_ping, + DEMO_PING_PONG_TX_TIMEOUT_DEFAULT ); break; } case DEMO_PING_PONG_MODE_SLAVE: { - DemoPingPong::TransmitPayload( this->device->GetRadio( ), this->payload_pong, this->settings.payload_length, - DEMO_PING_PONG_TX_TIMEOUT_DEFAULT ); + DemoTransceiverRadioPingPong::TransmitPayload( this->device->GetRadio( ), &this->payload_pong, + DEMO_PING_PONG_TX_TIMEOUT_DEFAULT ); break; } } } -void DemoPingPong::StartReceptionMessage( ) const +void DemoTransceiverRadioPingPong::StartReceptionMessage( ) const { lr1110_radio_set_rx( this->device->GetRadio( ), DEMO_PING_PONG_RX_TIMEOUT_DEFAULT ); } -void DemoPingPong::EndReceptionMessage( ) const +void DemoTransceiverRadioPingPong::EndReceptionMessage( ) const { lr1110_system_set_standby( this->device->GetRadio( ), LR1110_SYSTEM_STANDBY_CFG_RC ); } -void DemoPingPong::TransmitPayload( const void* radio, const uint8_t* payload, const uint8_t payload_size, - const uint32_t timeout ) +void DemoTransceiverRadioPingPong::TransmitPayload( const void* radio, const demo_ping_pong_rf_payload_t* payload, + const uint32_t timeout ) { - lr1110_regmem_write_buffer8( radio, payload, payload_size ); + lr1110_regmem_write_buffer8( radio, payload->content, payload->size ); lr1110_radio_set_tx( radio, timeout ); } -void DemoPingPong::FetchPayload( demo_ping_pong_fetched_payload_t* fetch_payload ) const +void DemoTransceiverRadioPingPong::FetchPayload( demo_ping_pong_fetched_payload_t* fetch_payload ) const { lr1110_radio_rx_buffer_status_t buffer_status = { 0 }; lr1110_radio_get_rx_buffer_status( this->device->GetRadio( ), &buffer_status ); @@ -458,7 +447,7 @@ void DemoPingPong::FetchPayload( demo_ping_pong_fetched_payload_t* fetch_payload { lr1110_radio_pkt_status_lora_t packet_status = { 0 }; lr1110_radio_get_lora_pkt_status( this->device->GetRadio( ), &packet_status ); - fetch_payload->rssi = packet_status.rssi_packet_in_dbm; + fetch_payload->rssi = packet_status.rssi_pkt_in_dbm; break; } case LR1110_RADIO_PKT_TYPE_GFSK: @@ -468,10 +457,15 @@ void DemoPingPong::FetchPayload( demo_ping_pong_fetched_payload_t* fetch_payload fetch_payload->rssi = packet_status.rssi_avg_in_dbm; break; } + default: + { + fetch_payload->received_payload.size = 0; + break; + } } } -void DemoPingPong::FetchStatisticToResults( ) +void DemoTransceiverRadioPingPong::FetchStatisticToResults( ) { switch( this->settings.pkt_type ) { @@ -485,25 +479,25 @@ void DemoPingPong::FetchStatisticToResults( ) lr1110_radio_get_gfsk_stats( this->device->GetRadio( ), &this->results.statistics_gfsk ); break; } + default: + { + break; + } } } -bool DemoPingPong::IsPongPayload( const demo_ping_pong_rf_payload_t& payload ) const +bool DemoTransceiverRadioPingPong::IsPongPayload( const demo_ping_pong_rf_payload_t& payload ) const { - demo_ping_pong_rf_payload_t payload_pong = { this->settings.payload_length, { 1 } }; - - return DemoPingPong::ArePayloadEquals( payload_pong, payload ); + return DemoTransceiverRadioPingPong::ArePayloadEquals( this->payload_pong, payload ); } -bool DemoPingPong::IsPingPayload( const demo_ping_pong_rf_payload_t& payload ) const +bool DemoTransceiverRadioPingPong::IsPingPayload( const demo_ping_pong_rf_payload_t& payload ) const { - demo_ping_pong_rf_payload_t payload_ping = { this->settings.payload_length, { 0 } }; - - return DemoPingPong::ArePayloadEquals( payload_ping, payload ); + return DemoTransceiverRadioPingPong::ArePayloadEquals( this->payload_ping, payload ); } -bool DemoPingPong::ArePayloadEquals( const demo_ping_pong_rf_payload_t& expected, - const demo_ping_pong_rf_payload_t& test ) +bool DemoTransceiverRadioPingPong::ArePayloadEquals( const demo_ping_pong_rf_payload_t& expected, + const demo_ping_pong_rf_payload_t& test ) { if( expected.size == test.size ) { @@ -522,7 +516,7 @@ bool DemoPingPong::ArePayloadEquals( const demo_ping_pong_rf_payload_t& expected } } -void DemoPingPong::ClearRegisteredIrqs( ) const +void DemoTransceiverRadioPingPong::ClearRegisteredIrqs( ) const { lr1110_system_clear_irq_status( this->device->GetRadio( ), this->radio_interrupt_mask ); } diff --git a/embedded/demo/src/demo_tx_cw.cpp b/embedded/demo/src/demo_transceiver_radio_tx_cw.cpp similarity index 77% rename from embedded/demo/src/demo_tx_cw.cpp rename to embedded/demo/src/demo_transceiver_radio_tx_cw.cpp index 80ef9c6..60eb1d8 100644 --- a/embedded/demo/src/demo_tx_cw.cpp +++ b/embedded/demo/src/demo_transceiver_radio_tx_cw.cpp @@ -1,5 +1,5 @@ /** - * @file demo_tx_cw.cpp + * @file demo_transceiver_radio_tx_cw.cpp * * @brief Implementation of the Continuous Wave Transmit demonstration. * @@ -29,19 +29,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_tx_cw.h" +#include "demo_transceiver_radio_tx_cw.h" #include "lr1110_radio.h" -DemoTxCw::DemoTxCw( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ) - : DemoRadioInterface( device, signaling, communication_interface ), state( DEMO_TX_CW_STATE_INIT ) +DemoTransceiverRadioTxCw::DemoTransceiverRadioTxCw( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ) + : DemoTransceiverRadioInterface( device, signaling, communication_interface, environment ), + state( DEMO_TX_CW_STATE_INIT ) { this->settings = {}; } -DemoTxCw::~DemoTxCw( ) {} +DemoTransceiverRadioTxCw::~DemoTransceiverRadioTxCw( ) {} -void DemoTxCw::SpecificRuntime( ) +void DemoTransceiverRadioTxCw::SpecificRuntime( ) { switch( this->state ) { @@ -60,17 +62,17 @@ void DemoTxCw::SpecificRuntime( ) } } -void DemoTxCw::SpecificStop( ) +void DemoTransceiverRadioTxCw::SpecificStop( ) { lr1110_system_set_standby( this->device->GetRadio( ), LR1110_SYSTEM_STANDBY_CFG_RC ); this->signaling->StopContinuousTx( ); this->state = DEMO_TX_CW_STATE_INIT; } -void DemoTxCw::ConfigureRadio( ) const +void DemoTransceiverRadioTxCw::ConfigureRadio( ) const { // 0. Reset the device - this->device->ResetAndInit( ); + this->device->Init( ); lr1110_radio_set_pkt_type( this->device->GetRadio( ), LR1110_RADIO_PKT_TYPE_LORA ); // 1. Set RF frequency @@ -82,6 +84,5 @@ void DemoTxCw::ConfigureRadio( ) const // 3. Set tx output power lr1110_radio_set_tx_params( this->device->GetRadio( ), this->settings.tx_power, this->settings.pa_ramp_time ); } -void DemoTxCw::SpecificInterruptHandler( ) {} -void DemoTxCw::ClearRegisteredIrqs( ) const {} \ No newline at end of file +void DemoTransceiverRadioTxCw::ClearRegisteredIrqs( ) const {} \ No newline at end of file diff --git a/embedded/demo/src/demo_wifi_country_code.cpp b/embedded/demo/src/demo_transceiver_wifi_country_code.cpp similarity index 68% rename from embedded/demo/src/demo_wifi_country_code.cpp rename to embedded/demo/src/demo_transceiver_wifi_country_code.cpp index 4ed69af..0c66fd9 100644 --- a/embedded/demo/src/demo_wifi_country_code.cpp +++ b/embedded/demo/src/demo_transceiver_wifi_country_code.cpp @@ -1,5 +1,5 @@ /** - * @file demo_wifi_country_code.cpp + * @file demo_transceiver_wifi_country_code.cpp * * @brief Implementation of the Wi-Fi country code scan demonstration. * @@ -29,29 +29,31 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_wifi_country_code.h" +#include "demo_transceiver_wifi_country_code.h" #include #define DEMO_WIFI_MAX_RESULTS_PER_SCAN ( 20 ) -DemoWifiCountryCode::DemoWifiCountryCode( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ) - : DemoWifiInterface( device, signaling, communication_interface ) +DemoTransceiverWifiCountryCode::DemoTransceiverWifiCountryCode( DeviceTransceiver* device, + SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ) + : DemoTransceiverWifiInterface( device, signaling, communication_interface, environment ) { } -DemoWifiCountryCode::~DemoWifiCountryCode( ) {} +DemoTransceiverWifiCountryCode::~DemoTransceiverWifiCountryCode( ) {} -void DemoWifiCountryCode::Configure( demo_wifi_country_code_settings_t& config ) { this->settings = config; } +void DemoTransceiverWifiCountryCode::Configure( demo_wifi_country_code_settings_t& config ) { this->settings = config; } -void DemoWifiCountryCode::ExecuteScan( radio_t* radio ) +void DemoTransceiverWifiCountryCode::ExecuteScan( radio_t* radio ) { lr1110_wifi_search_country_code( radio, this->settings.channels, this->settings.max_results, this->settings.nbr_retrials, this->settings.timeout, this->settings.does_abort_on_timeout ); } -void DemoWifiCountryCode::FetchAndSaveResults( radio_t* radio ) +void DemoTransceiverWifiCountryCode::FetchAndSaveResults( radio_t* radio ) { lr1110_wifi_country_code_t wifi_results_country_code[DEMO_WIFI_MAX_RESULTS_PER_SCAN] = { 0 }; uint8_t nbr_results = 0; @@ -65,15 +67,16 @@ void DemoWifiCountryCode::FetchAndSaveResults( radio_t* radio ) max_results_to_fetch ); } -void DemoWifiCountryCode::AddScanToResults( const lr1110_system_reg_mode_t regMode, - demo_wifi_scan_all_results_t& results, - const lr1110_wifi_channel_mask_t channels, - const lr1110_wifi_country_code_t* scan_result, const uint8_t nbr_results ) +void DemoTransceiverWifiCountryCode::AddScanToResults( const lr1110_system_reg_mode_t regMode, + demo_wifi_scan_all_results_t& results, + const lr1110_wifi_channel_mask_t channels, + const lr1110_wifi_country_code_t* scan_result, + const uint8_t nbr_results ) { for( uint8_t index = 0; ( index < nbr_results ) && ( results.nbrResults < DEMO_WIFI_MAX_RESULT_TOTAL ); index++ ) { results.results[results.nbrResults].channel = - lr1110_extract_channel_from_info_byte( scan_result[index].channel_info_byte ); + lr1110_wifi_extract_channel_from_info_byte( scan_result[index].channel_info_byte ); results.results[results.nbrResults].type = DEMO_WIFI_TYPE_B; diff --git a/embedded/demo/src/demo_wifi_interface.cpp b/embedded/demo/src/demo_transceiver_wifi_interface.cpp similarity index 54% rename from embedded/demo/src/demo_wifi_interface.cpp rename to embedded/demo/src/demo_transceiver_wifi_interface.cpp index 8bdb0c6..33e0ab1 100644 --- a/embedded/demo/src/demo_wifi_interface.cpp +++ b/embedded/demo/src/demo_transceiver_wifi_interface.cpp @@ -1,5 +1,5 @@ /** - * @file demo_wifi_interface.cpp + * @file demo_transceiver_wifi_interface.cpp * * @brief Implementation of the Wi-Fi demonstration interface. * @@ -29,7 +29,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_wifi_interface.h" +#include "demo_transceiver_wifi_interface.h" #include "lr1110_wifi.h" #define WIFI_DEMO_CONSUMPTION_DCDC_CORRELATION_MA ( 12 ) @@ -37,18 +37,19 @@ #define WIFI_DEMO_CONSUMPTION_LDO_CORRELATION_MA ( 24 ) #define WIFI_DEMO_CONSUMPTION_LDO_DEMODULATION_MA ( 8 ) -DemoWifiInterface::DemoWifiInterface( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ) - : DemoTransceiverBase( device, signaling, communication_interface ), state( DEMO_WIFI_INIT ) +DemoTransceiverWifiInterface::DemoTransceiverWifiInterface( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ) + : DemoTransceiverInterface( device, signaling, communication_interface, environment ), state( DEMO_WIFI_INIT ) { wifi_irq = LR1110_SYSTEM_IRQ_WIFI_SCAN_DONE; } -DemoWifiInterface::~DemoWifiInterface( ) {} +DemoTransceiverWifiInterface::~DemoTransceiverWifiInterface( ) {} -void DemoWifiInterface::Reset( ) +void DemoTransceiverWifiInterface::Reset( ) { - this->DemoBase::Reset( ); + this->DemoInterface::Reset( ); this->state = DEMO_WIFI_INIT; this->results.nbrResults = 0; this->results.global_consumption_uas = 0; @@ -58,7 +59,7 @@ void DemoWifiInterface::Reset( ) lr1110_system_set_dio_irq_params( this->device->GetRadio( ), irq_to_en_dio1, irq_to_en_dio2 ); } -void DemoWifiInterface::SpecificRuntime( ) +void DemoTransceiverWifiInterface::SpecificRuntime( ) { switch( this->state ) { @@ -86,21 +87,14 @@ void DemoWifiInterface::SpecificRuntime( ) { if( this->InterruptHasRaised( ) ) { - lr1110_system_stat1_t stat1; - lr1110_system_stat2_t stat2; - uint32_t irq_status; - - lr1110_system_get_status( this->device->GetRadio( ), &stat1, &stat2, &irq_status ); - - if( ( irq_status & LR1110_SYSTEM_IRQ_WIFI_SCAN_DONE ) != 0 ) + if( ( this->last_received_irq_mask & LR1110_SYSTEM_IRQ_WIFI_SCAN_DONE ) != 0 ) { - this->ClearRegisteredIrqs( ); signaling->StopCapture( ); - if( stat1.command_status != LR1110_SYSTEM_CMD_STATUS_OK ) + if( this->last_received_stat_1.command_status != LR1110_SYSTEM_CMD_STATUS_OK ) { this->results.error = true; this->results.nbrResults = 0; - this->results.timings = {}; + this->results.timings = { }; this->state = DEMO_WIFI_TERMINATED; } else @@ -130,8 +124,8 @@ void DemoWifiInterface::SpecificRuntime( ) lr1110_wifi_read_cumulative_timing( this->device->GetRadio( ), &wifi_results_timings ); uint32_t consumption_uas = - DemoWifiInterface::ComputeConsumption( LR1110_SYSTEM_REG_MODE_DCDC, wifi_results_timings ); - results.timings = wifi_results_timings; + DemoTransceiverWifiInterface::ComputeConsumption( LR1110_SYSTEM_REG_MODE_DCDC, wifi_results_timings ); + results.timings = DemoTransceiverWifiInterface::demo_wifi_timing_from_transceiver( wifi_results_timings ); results.global_consumption_uas += consumption_uas; results.error = false; this->state = DEMO_WIFI_TERMINATED; @@ -148,14 +142,12 @@ void DemoWifiInterface::SpecificRuntime( ) } } -void DemoWifiInterface::SpecificStop( ) { signaling->StopCapture( ); } - -void DemoWifiInterface::SpecificInterruptHandler( ) {} +void DemoTransceiverWifiInterface::SpecificStop( ) { signaling->StopCapture( ); } #define CASE_STATE_STR( state ) \ case DEMO_WIFI_##state: \ return ( char* ) #state; -const char* DemoWifiInterface::state2str( const demo_wifi_state_t state ) +const char* DemoTransceiverWifiInterface::state2str( const demo_wifi_state_t state ) { switch( state ) { @@ -169,10 +161,10 @@ const char* DemoWifiInterface::state2str( const demo_wifi_state_t state ) } } -const demo_wifi_scan_all_results_t* DemoWifiInterface::GetResult( ) const { return &this->results; } +const demo_wifi_scan_all_results_t* DemoTransceiverWifiInterface::GetResult( ) const { return &this->results; } -uint32_t DemoWifiInterface::ComputeConsumption( const lr1110_system_reg_mode_t regMode, - const lr1110_wifi_cumulative_timings_t& timing ) +uint32_t DemoTransceiverWifiInterface::ComputeConsumption( const lr1110_system_reg_mode_t regMode, + const lr1110_wifi_cumulative_timings_t& timing ) { uint32_t consumption_uas = 0; @@ -195,7 +187,92 @@ uint32_t DemoWifiInterface::ComputeConsumption( const lr1110_system_reg_mode_t return consumption_uas; } -void DemoWifiInterface::ClearRegisteredIrqs( ) const +lr1110_wifi_mode_t DemoTransceiverWifiInterface::transceiver_wifi_mode_from_demo( + const demo_wifi_mode_t& demo_wifi_mode ) +{ + lr1110_wifi_mode_t transceiver_wifi_mode = LR1110_WIFI_SCAN_MODE_BEACON; + switch( demo_wifi_mode ) + { + case DEMO_WIFI_SCAN_MODE_BEACON: + { + transceiver_wifi_mode = LR1110_WIFI_SCAN_MODE_BEACON; + break; + } + + case DEMO_WIFI_SCAN_MODE_BEACON_AND_PACKET: + { + transceiver_wifi_mode = LR1110_WIFI_SCAN_MODE_BEACON_AND_PKT; + break; + } + + default: + break; + } + return transceiver_wifi_mode; +} + +lr1110_wifi_signal_type_scan_t DemoTransceiverWifiInterface::transceiver_wifi_scan_type_from_demo( + const demo_wifi_signal_type_scan_t& demo_wifi_scan_type ) +{ + lr1110_wifi_signal_type_scan_t transceiver_signal_type_scan = LR1110_WIFI_TYPE_SCAN_B; + switch( demo_wifi_scan_type ) + { + case DEMO_WIFI_SETTING_TYPE_B: + { + transceiver_signal_type_scan = LR1110_WIFI_TYPE_SCAN_B; + break; + } + case DEMO_WIFI_SETTING_TYPE_G: + { + transceiver_signal_type_scan = LR1110_WIFI_TYPE_SCAN_G; + break; + } + case DEMO_WIFI_SETTING_TYPE_N: + { + transceiver_signal_type_scan = LR1110_WIFI_TYPE_SCAN_N; + break; + } + case DEMO_WIFI_SETTING_TYPE_B_G_N: + { + transceiver_signal_type_scan = LR1110_WIFI_TYPE_SCAN_B_G_N; + break; + } + } + return transceiver_signal_type_scan; +} + +void DemoTransceiverWifiInterface::ClearRegisteredIrqs( ) const { lr1110_system_clear_irq_status( this->device->GetRadio( ), this->wifi_irq ); } + +demo_wifi_timings_t DemoTransceiverWifiInterface::demo_wifi_timing_from_transceiver( + const lr1110_wifi_cumulative_timings_t& transceiver_timings ) +{ + demo_wifi_timings_t demo_timing; + demo_timing.demodulation_us = transceiver_timings.demodulation_us; + demo_timing.rx_capture_us = transceiver_timings.rx_capture_us; + demo_timing.rx_correlation_us = transceiver_timings.rx_correlation_us; + demo_timing.rx_detection_us = transceiver_timings.rx_detection_us; + return demo_timing; +} + +#define WIFI_TYPE_FROM_TRANSCEIVER_CASE( var, type ) \ + case LR1110_WIFI_TYPE_RESULT_##type: \ + { \ + var = DEMO_WIFI_TYPE_##type; \ + break; \ + } +demo_wifi_signal_type_t DemoTransceiverWifiInterface::demo_wifi_types_from_transceiver( + lr1110_wifi_signal_type_result_t wifi_type_result ) +{ + demo_wifi_signal_type_t demo_wifi_type = DEMO_WIFI_TYPE_B; + switch( wifi_type_result ) + { + WIFI_TYPE_FROM_TRANSCEIVER_CASE( demo_wifi_type, B ) + WIFI_TYPE_FROM_TRANSCEIVER_CASE( demo_wifi_type, G ) + WIFI_TYPE_FROM_TRANSCEIVER_CASE( demo_wifi_type, N ) + } + return demo_wifi_type; +} +#undef WIFI_TYPE_FROM_TRANSCEIVER_CASE \ No newline at end of file diff --git a/embedded/demo/src/demo_wifi_scan.cpp b/embedded/demo/src/demo_transceiver_wifi_scan.cpp similarity index 65% rename from embedded/demo/src/demo_wifi_scan.cpp rename to embedded/demo/src/demo_transceiver_wifi_scan.cpp index 50a7646..c812a09 100644 --- a/embedded/demo/src/demo_wifi_scan.cpp +++ b/embedded/demo/src/demo_transceiver_wifi_scan.cpp @@ -1,5 +1,5 @@ /** - * @file demo_wifi_scan.cpp + * @file demo_transceiver_wifi_scan.cpp * * @brief Implementation of the Wi-Fi MAC address scan demonstration. * @@ -29,29 +29,32 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "demo_wifi_scan.h" +#include "demo_transceiver_wifi_scan.h" #include "lr1110_wifi.h" #include #define WIFI_SCAN_ABORT_ON_TIMEOUT ( false ) #define DEMO_WIFI_MAX_RESULTS_PER_SCAN ( 20 ) -DemoWifiScan::DemoWifiScan( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ) - : DemoWifiInterface( device, signaling, communication_interface ) +DemoTransceiverWifiScan::DemoTransceiverWifiScan( DeviceTransceiver* device, SignalingInterface* signaling, + CommunicationInterface* communication_interface, + EnvironmentInterface* environment ) + : DemoTransceiverWifiInterface( device, signaling, communication_interface, environment ) { } -DemoWifiScan::~DemoWifiScan( ) {} +DemoTransceiverWifiScan::~DemoTransceiverWifiScan( ) {} -void DemoWifiScan::ExecuteScan( radio_t* radio ) +void DemoTransceiverWifiScan::ExecuteScan( radio_t* radio ) { - lr1110_wifi_scan( radio, this->settings.types, this->settings.channels, this->settings.scan_mode, + lr1110_wifi_scan( radio, DemoTransceiverWifiInterface::transceiver_wifi_scan_type_from_demo( this->settings.types ), + this->settings.channels, + DemoTransceiverWifiInterface::transceiver_wifi_mode_from_demo( this->settings.scan_mode ), this->settings.max_results, this->settings.nbr_retrials, this->settings.timeout, WIFI_SCAN_ABORT_ON_TIMEOUT ); } -void DemoWifiScan::FetchAndSaveResults( radio_t* radio ) +void DemoTransceiverWifiScan::FetchAndSaveResults( radio_t* radio ) { switch( this->settings.result_type ) { @@ -68,7 +71,7 @@ void DemoWifiScan::FetchAndSaveResults( radio_t* radio ) } } -void DemoWifiScan::FetchAndSaveBasicCompleteResults( radio_t* radio ) +void DemoTransceiverWifiScan::FetchAndSaveBasicCompleteResults( radio_t* radio ) { lr1110_wifi_basic_complete_result_t wifi_results_mac_addr[DEMO_WIFI_MAX_RESULTS_PER_SCAN] = { 0 }; uint8_t nbr_results = 0; @@ -83,7 +86,7 @@ void DemoWifiScan::FetchAndSaveBasicCompleteResults( radio_t* radio ) AddScanToResults( LR1110_SYSTEM_REG_MODE_DCDC, this->results, wifi_results_mac_addr, max_results_to_fetch ); } -void DemoWifiScan::FetchAndSaveBasicMacChannelTypeResults( radio_t* radio ) +void DemoTransceiverWifiScan::FetchAndSaveBasicMacChannelTypeResults( radio_t* radio ) { lr1110_wifi_basic_mac_type_channel_result_t wifi_results_mac_addr[DEMO_WIFI_MAX_RESULTS_PER_SCAN] = { 0 }; uint8_t nbr_results = 0; @@ -98,19 +101,21 @@ void DemoWifiScan::FetchAndSaveBasicMacChannelTypeResults( radio_t* radio ) AddScanToResults( LR1110_SYSTEM_REG_MODE_DCDC, this->results, wifi_results_mac_addr, max_results_to_fetch ); } -void DemoWifiScan::Configure( demo_wifi_settings_t& config ) { this->settings = config; } +void DemoTransceiverWifiScan::Configure( demo_wifi_settings_t& config ) { this->settings = config; } -void DemoWifiScan::AddScanToResults( const lr1110_system_reg_mode_t regMode, demo_wifi_scan_all_results_t& results, - const lr1110_wifi_basic_complete_result_t* scan_result, const uint8_t nbr_results ) +void DemoTransceiverWifiScan::AddScanToResults( const lr1110_system_reg_mode_t regMode, + demo_wifi_scan_all_results_t& results, + const lr1110_wifi_basic_complete_result_t* scan_result, + const uint8_t nbr_results ) { for( uint8_t index = 0; ( index < nbr_results ) && ( results.nbrResults < DEMO_WIFI_MAX_RESULT_TOTAL ); index++ ) { const lr1110_wifi_basic_complete_result_t* local_basic_result = &scan_result[index]; results.results[results.nbrResults].channel = - lr1110_extract_channel_from_info_byte( local_basic_result->channel_info_byte ); + lr1110_wifi_extract_channel_from_info_byte( local_basic_result->channel_info_byte ); - results.results[results.nbrResults].type = demo_wifi_types_from_transceiver( - lr1110_extract_signal_type_from_data_rate_info( local_basic_result->data_rate_info_byte ) ); + results.results[results.nbrResults].type = DemoTransceiverWifiInterface::demo_wifi_types_from_transceiver( + lr1110_wifi_extract_signal_type_from_data_rate_info( local_basic_result->data_rate_info_byte ) ); memcpy( results.results[results.nbrResults].mac_address, local_basic_result->mac_address, LR1110_WIFI_MAC_ADDRESS_LENGTH ); @@ -122,18 +127,19 @@ void DemoWifiScan::AddScanToResults( const lr1110_system_reg_mode_t regMode, dem } } -void DemoWifiScan::AddScanToResults( const lr1110_system_reg_mode_t regMode, demo_wifi_scan_all_results_t& results, - const lr1110_wifi_basic_mac_type_channel_result_t* scan_result, - const uint8_t nbr_results ) +void DemoTransceiverWifiScan::AddScanToResults( const lr1110_system_reg_mode_t regMode, + demo_wifi_scan_all_results_t& results, + const lr1110_wifi_basic_mac_type_channel_result_t* scan_result, + const uint8_t nbr_results ) { for( uint8_t index = 0; ( index < nbr_results ) && ( results.nbrResults < DEMO_WIFI_MAX_RESULT_TOTAL ); index++ ) { const lr1110_wifi_basic_mac_type_channel_result_t* local_basic_result = &scan_result[index]; results.results[results.nbrResults].channel = - lr1110_extract_channel_from_info_byte( local_basic_result->channel_info_byte ); + lr1110_wifi_extract_channel_from_info_byte( local_basic_result->channel_info_byte ); - results.results[results.nbrResults].type = demo_wifi_types_from_transceiver( - lr1110_extract_signal_type_from_data_rate_info( local_basic_result->data_rate_info_byte ) ); + results.results[results.nbrResults].type = DemoTransceiverWifiInterface::demo_wifi_types_from_transceiver( + lr1110_wifi_extract_signal_type_from_data_rate_info( local_basic_result->data_rate_info_byte ) ); memcpy( results.results[results.nbrResults].mac_address, local_basic_result->mac_address, LR1110_WIFI_MAC_ADDRESS_LENGTH ); diff --git a/embedded/demo/src/demo_wifi_types.cpp b/embedded/demo/src/demo_wifi_types.cpp deleted file mode 100644 index 619a0d3..0000000 --- a/embedded/demo/src/demo_wifi_types.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "demo_wifi_types.h" - -#define WIFI_TYPE_FROM_TRANSCEIVER_CASE( var, type ) \ - case LR1110_WIFI_TYPE_RESULT_##type: \ - { \ - var = DEMO_WIFI_TYPE_##type; \ - break; \ - } -demo_wifi_signal_type_t demo_wifi_types_from_transceiver( lr1110_wifi_signal_type_result_t wifi_type_result ) -{ - demo_wifi_signal_type_t demo_wifi_type = DEMO_WIFI_TYPE_B; - switch( wifi_type_result ) - { - WIFI_TYPE_FROM_TRANSCEIVER_CASE( demo_wifi_type, B ) - WIFI_TYPE_FROM_TRANSCEIVER_CASE( demo_wifi_type, G ) - WIFI_TYPE_FROM_TRANSCEIVER_CASE( demo_wifi_type, N ) - } - return demo_wifi_type; -} -#undef WIFI_TYPE_FROM_TRANSCEIVER_CASE \ No newline at end of file diff --git a/embedded/demo/src/interruption_irq.cpp b/embedded/demo/src/interruption_irq.cpp new file mode 100644 index 0000000..92ba1dc --- /dev/null +++ b/embedded/demo/src/interruption_irq.cpp @@ -0,0 +1,68 @@ +/** + * @file interruption_irq.cpp + * + * @brief Implementation of the interruption for transceiver class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "interruption_irq.h" + +InterruptionIrq::InterruptionIrq( ) : irq_mask( 0 ), stat_1( ), stat_2( ) {} + +InterruptionIrq::~InterruptionIrq( ) {} + +bool InterruptionIrq::is_wifi_interruption( ) const +{ + return ( ( this->irq_mask & LR1110_SYSTEM_IRQ_WIFI_SCAN_DONE ) != 0 ); +} + +bool InterruptionIrq::is_gnss_interruption( ) const +{ + return ( ( this->irq_mask & LR1110_SYSTEM_IRQ_GNSS_SCAN_DONE ) != 0 ); +} + +bool InterruptionIrq::is_radio_interruption( ) const +{ + return ( ( this->irq_mask & + ( LR1110_SYSTEM_IRQ_TX_DONE | LR1110_SYSTEM_IRQ_RX_DONE | LR1110_SYSTEM_IRQ_PREAMBLE_DETECTED | + LR1110_SYSTEM_IRQ_SYNC_WORD_HEADER_VALID | LR1110_SYSTEM_IRQ_HEADER_ERROR | + LR1110_SYSTEM_IRQ_CRC_ERROR | LR1110_SYSTEM_IRQ_CAD_DONE | LR1110_SYSTEM_IRQ_CAD_DETECTED | + LR1110_SYSTEM_IRQ_TIMEOUT | LR1110_SYSTEM_IRQ_FSK_LEN_ERROR | LR1110_SYSTEM_IRQ_FSK_ADDR_ERROR ) ) != + 0 ); +} + +lr1110_system_irq_mask_t InterruptionIrq::get_irq_mask( ) const { return ( lr1110_system_irq_mask_t ) this->irq_mask; } + +lr1110_system_stat1_t InterruptionIrq::get_stat_1( ) const { return this->stat_1; } + +lr1110_system_stat2_t InterruptionIrq::get_stat_2( ) const { return this->stat_2; } + +void InterruptionIrq::set_irq_mask( uint32_t irq_mask ) { this->irq_mask = irq_mask; } + +void InterruptionIrq::set_stat_1( lr1110_system_stat1_t stat_1 ) { this->stat_1 = stat_1; } + +void InterruptionIrq::set_stat_2( lr1110_system_stat2_t stat_2 ) { this->stat_2 = stat_2; } diff --git a/embedded/demo/src/interruption_modem.cpp b/embedded/demo/src/interruption_modem.cpp new file mode 100644 index 0000000..dd42793 --- /dev/null +++ b/embedded/demo/src/interruption_modem.cpp @@ -0,0 +1,23 @@ +#include "interruption_modem.h" + +InterruptionModem::InterruptionModem( ) : event( ) {} + +bool InterruptionModem::is_wifi_interruption( ) const +{ + return this->event.event_type == LR1110_MODEM_LORAWAN_EVENT_WIFI_SCAN_DONE; +} + +bool InterruptionModem::is_gnss_interruption( ) const +{ + return this->event.event_type == LR1110_MODEM_LORAWAN_EVENT_GNSS_SCAN_DONE; +} + +bool InterruptionModem::is_radio_interruption( ) const +{ + // We set to true the radio interruption whatever the event was, expect if it was Wi-Fi or GNSS + return ( !this->is_gnss_interruption( ) && !this->is_wifi_interruption( ) ); +} + +lr1110_modem_event_fields_t InterruptionModem::GetEvent( ) const { return this->event; } + +void InterruptionModem::SetEvent( const lr1110_modem_event_fields_t& _event ) { this->event = _event; } diff --git a/embedded/demo/inc/device_base.h b/embedded/device/inc/device_interface.h similarity index 83% rename from embedded/demo/inc/device_base.h rename to embedded/device/inc/device_interface.h index dd72a39..bdcacdd 100644 --- a/embedded/demo/inc/device_base.h +++ b/embedded/device/inc/device_interface.h @@ -1,5 +1,5 @@ /** - * @file device_base.h + * @file device_interface.h * * @brief Definition of device base class. * @@ -29,11 +29,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEVICE_BASE_H__ -#define __DEVICE_BASE_H__ +#ifndef __DEVICE_INTERFACE_H__ +#define __DEVICE_INTERFACE_H__ #include "configuration.h" #include "version.h" +#include "interruption_interface.h" #define GNSS_HELPER_NUMBER_SATELLITES_ALMANAC_READ ( 128 ) @@ -49,19 +50,21 @@ typedef struct uint32_t crc_almanac; } GnssHelperAlmanacDetails_t; -class DeviceBase +class DeviceInterface { public: - explicit DeviceBase( radio_t* radio ); - virtual void ResetAndInit( ) = 0; + explicit DeviceInterface( radio_t* radio ); + virtual void Init( ) = 0; virtual void FetchVersion( version_handler_t& version_handler ) = 0; virtual void GetAlmanacAgesAndCrcOfAllSatellites( GnssHelperAlmanacDetails_t* almanac_details ) = 0; + virtual void GetAlmanacAgesForSatelliteId( uint8_t sv_id, uint16_t* almanac_age ) = 0; virtual void UpdateAlmanac( const uint8_t* almanac_buffer, const uint8_t buffer_size ) = 0; virtual bool checkAlmanacUpdate( uint32_t expected_crc ) = 0; + virtual bool FetchInterrupt( InterruptionInterface** interruption ) = 0; radio_t* GetRadio( ) const; protected: radio_t* radio; }; -#endif // __DEVICE_BASE_H__ \ No newline at end of file +#endif // __DEVICE_INTERFACE_H__ diff --git a/embedded/device/inc/device_modem.h b/embedded/device/inc/device_modem.h new file mode 100644 index 0000000..e214b73 --- /dev/null +++ b/embedded/device/inc/device_modem.h @@ -0,0 +1,55 @@ +/** + * @file device_modem.h + * + * @brief Definition of modem device class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __DEVICE_MODEM_H__ +#define __DEVICE_MODEM_H__ + +#include "device_interface.h" +#include "interruption_modem.h" +#include "lr1110_modem_common.h" + +class DeviceModem : public DeviceInterface +{ + public: + explicit DeviceModem( radio_t* radio ); + void FetchVersion( version_handler_t& version_handler ) override; + void Init( ) override; + void GetAlmanacAgesAndCrcOfAllSatellites( GnssHelperAlmanacDetails_t* almanac_details ) override; + void GetAlmanacAgesForSatelliteId( uint8_t sv_id, uint16_t* almanac_age ) override; + void UpdateAlmanac( const uint8_t* almanac_buffer, const uint8_t buffer_size ) override; + bool FetchInterrupt( InterruptionInterface** interruption ) override; + bool checkAlmanacUpdate( uint32_t expected_crc ) override; + + protected: + InterruptionModem interruption; +}; + +#endif // __DEVICE_MODEM_H__ diff --git a/embedded/demo/inc/device_transceiver.h b/embedded/device/inc/device_transceiver.h similarity index 85% rename from embedded/demo/inc/device_transceiver.h rename to embedded/device/inc/device_transceiver.h index e00730c..c2e4a3f 100644 --- a/embedded/demo/inc/device_transceiver.h +++ b/embedded/device/inc/device_transceiver.h @@ -32,17 +32,24 @@ #ifndef __DEVICE_TRANSCEIVER_H__ #define __DEVICE_TRANSCEIVER_H__ -#include "device_base.h" +#include "device_interface.h" +#include "interruption_irq.h" +#include "lr1110_system_types.h" -class DeviceTransceiver : public DeviceBase +class DeviceTransceiver : public DeviceInterface { public: explicit DeviceTransceiver( radio_t* radio ); void FetchVersion( version_handler_t& version_handler ) override; - void ResetAndInit( ) override; + void Init( ) override; void GetAlmanacAgesAndCrcOfAllSatellites( GnssHelperAlmanacDetails_t* almanac_details ) override; + void GetAlmanacAgesForSatelliteId( uint8_t sv_id, uint16_t* almanac_age ) override; void UpdateAlmanac( const uint8_t* almanac_buffer, const uint8_t buffer_size ) override; + bool FetchInterrupt( InterruptionInterface** interruption ) override; bool checkAlmanacUpdate( uint32_t expected_crc ) override; + + private: + InterruptionIrq last_interrupt; }; #endif // __DEVICE_TRANSCEIVER_H__ \ No newline at end of file diff --git a/embedded/demo/src/device_base.cpp b/embedded/device/src/device_interface.cpp similarity index 90% rename from embedded/demo/src/device_base.cpp rename to embedded/device/src/device_interface.cpp index ffad42b..1b3db10 100644 --- a/embedded/demo/src/device_base.cpp +++ b/embedded/device/src/device_interface.cpp @@ -29,8 +29,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "device_base.h" +#include "device_interface.h" -DeviceBase::DeviceBase( radio_t* radio ) : radio( radio ) {} +DeviceInterface::DeviceInterface( radio_t* radio ) : radio( radio ) {} -radio_t* DeviceBase::GetRadio( ) const { return this->radio; } +radio_t* DeviceInterface::GetRadio( ) const { return this->radio; } diff --git a/embedded/device/src/device_modem.cpp b/embedded/device/src/device_modem.cpp new file mode 100644 index 0000000..a8435d2 --- /dev/null +++ b/embedded/device/src/device_modem.cpp @@ -0,0 +1,146 @@ +/** + * @file device_modem.cpp + * + * @brief Implementation of modem device class. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "device_modem.h" +#include "demo_configuration.h" +#include "lr1110_modem_hal.h" +#include "lr1110_modem_system.h" +#include "lr1110_modem_lorawan.h" +#include "lr1110_modem_driver_version.h" +#include "lr1110_modem_gnss.h" +#include + +DeviceModem::DeviceModem( radio_t* radio ) : DeviceInterface( radio ) {} + +void DeviceModem::Init( ) +{ + lr1110_modem_system_set_reg_mode( this->radio, LR1110_MODEM_SYSTEM_REG_MODE_DCDC ); + + lr1110_modem_system_rf_switch_cfg_t rf_switch_setup = { 0 }; + rf_switch_setup.enable = DEMO_COMMON_RF_SWITCH_ENABLE; + rf_switch_setup.standby = DEMO_COMMON_RF_SWITCH_STANDBY; + rf_switch_setup.tx = DEMO_COMMON_RF_SWITCH_TX; + rf_switch_setup.tx_hp = DEMO_COMMON_RF_SWITCH_TX_HP; + rf_switch_setup.rx = DEMO_COMMON_RF_SWITCH_RX; + rf_switch_setup.wifi = DEMO_COMMON_RF_SWITCH_WIFI; + rf_switch_setup.gnss = DEMO_COMMON_RF_SWITCH_GNSS; + lr1110_modem_system_set_dio_as_rf_switch( this->radio, &rf_switch_setup ); + + lr1110_modem_system_set_tcxo_mode( this->radio, LR1110_MODEM_SYSTEM_TCXO_CTRL_3_0V, 500 ); + lr1110_modem_system_cfg_lfclk( this->radio, LR1110_MODEM_SYSTEM_LFCLK_XTAL, true ); + + lr1110_modem_set_rf_output( this->radio, LR1110_MODEM_RADIO_PA_SEL_LP_HP_LF ); +} + +void DeviceModem::GetAlmanacAgesAndCrcOfAllSatellites( GnssHelperAlmanacDetails_t* almanac_details ) +{ + for( uint8_t index_satellite = 0; index_satellite < GNSS_HELPER_NUMBER_SATELLITES_ALMANAC_READ; index_satellite++ ) + { + almanac_details->ages_per_almanacs[index_satellite].sv_id = index_satellite; + this->GetAlmanacAgesForSatelliteId( index_satellite, + &almanac_details->ages_per_almanacs[index_satellite].almanac_age ); + } + lr1110_modem_gnss_context_t gnss_context = { 0 }; + lr1110_modem_gnss_get_context( this->radio, &gnss_context ); + almanac_details->crc_almanac = gnss_context.global_almanac_crc; +} + +void DeviceModem::GetAlmanacAgesForSatelliteId( uint8_t sv_id, uint16_t* almanac_age ) +{ + uint8_t local_almanac[LR1110_MODEM_GNSS_SINGLE_ALMANAC_READ_SIZE] = { 0 }; + lr1110_modem_almanac_read_by_index( this->radio, sv_id, 1, local_almanac, + LR1110_MODEM_GNSS_SINGLE_ALMANAC_READ_SIZE ); + ( *almanac_age ) = ( ( uint16_t )( local_almanac[1] ) << 0 ) + ( ( uint16_t )( local_almanac[2] ) << 8 ); +} + +void DeviceModem::UpdateAlmanac( const uint8_t* almanac_buffer, const uint8_t buffer_size ) +{ + if( buffer_size == LR1110_MODEM_GNSS_SINGLE_ALMANAC_WRITE_SIZE ) + { + lr1110_modem_gnss_one_chunk_almanac_update( this->radio, almanac_buffer ); + } +} + +bool DeviceModem::FetchInterrupt( InterruptionInterface** interruption ) +{ + lr1110_modem_event_fields_t event = {}; + lr1110_modem_get_event( this->GetRadio( ), &event ); + bool has_event = false; + if( event.event_type == LR1110_MODEM_LORAWAN_EVENT_NO_EVENT ) + { + has_event = false; + } + else + { + this->interruption.SetEvent( event ); + ( *interruption ) = &this->interruption; + + has_event = true; + } + return has_event; +} + +bool DeviceModem::checkAlmanacUpdate( uint32_t expected_crc ) +{ + lr1110_modem_gnss_context_t gnss_context = {}; + lr1110_modem_gnss_get_context( this->radio, &gnss_context ); + return expected_crc == gnss_context.global_almanac_crc; +} + +void DeviceModem::FetchVersion( version_handler_t& version_handler ) +{ + lr1110_modem_version_t lr1110_modem_version = { 0 }; + + lr1110_modem_get_version( this->radio, &lr1110_modem_version ); + version_handler.device_type = VERSION_DEVICE_MODEM; + version_handler.modem.version_chip_type = lr1110_modem_version.functionality; + version_handler.modem.version_chip_bootloader = lr1110_modem_version.bootloader; + version_handler.modem.version_chip_fw = lr1110_modem_version.firmware; + + lr1110_modem_get_chip_eui( this->radio, version_handler.chip_uid ); + lr1110_modem_get_dev_eui( this->radio, version_handler.dev_eui ); + lr1110_modem_get_join_eui( this->radio, version_handler.join_eui ); + + uint32_t pin_raw = 0; + lr1110_modem_get_pin( this->radio, &pin_raw ); + version_handler.pin[0] = ( uint8_t )( pin_raw >> 24 ); + version_handler.pin[1] = ( uint8_t )( pin_raw >> 16 ); + version_handler.pin[2] = ( uint8_t )( pin_raw >> 8 ); + version_handler.pin[3] = ( uint8_t )( pin_raw >> 0 ); + + strcpy( version_handler.version_sw, DEMO_VERSION ); + strcpy( version_handler.version_driver, lr1110_modem_driver_version_get_version_string( ) ); + + GnssHelperAlmanacDetails_t almanac_ages_crc = { 0 }; + this->GetAlmanacAgesAndCrcOfAllSatellites( &almanac_ages_crc ); + version_handler.almanac_date = almanac_ages_crc.ages_per_almanacs[0].almanac_age; + version_handler.almanac_crc = almanac_ages_crc.crc_almanac; +} diff --git a/embedded/demo/src/device_transceiver.cpp b/embedded/device/src/device_transceiver.cpp similarity index 76% rename from embedded/demo/src/device_transceiver.cpp rename to embedded/device/src/device_transceiver.cpp index 82d79c5..4a4cef0 100644 --- a/embedded/demo/src/device_transceiver.cpp +++ b/embedded/device/src/device_transceiver.cpp @@ -36,12 +36,10 @@ #include "demo_configuration.h" #include -DeviceTransceiver::DeviceTransceiver( radio_t* radio ) : DeviceBase( radio ) {} +DeviceTransceiver::DeviceTransceiver( radio_t* radio ) : DeviceInterface( radio ) {} -void DeviceTransceiver::ResetAndInit( ) +void DeviceTransceiver::Init( ) { - lr1110_system_reset( this->radio ); - lr1110_system_set_reg_mode( this->radio, LR1110_SYSTEM_REG_MODE_DCDC ); lr1110_system_rfswitch_cfg_t rf_switch_setup = { 0 }; @@ -84,6 +82,11 @@ void DeviceTransceiver::GetAlmanacAgesAndCrcOfAllSatellites( GnssHelperAlmanacDe ( almanac_bytestream[GNSS_HELPER_NUMBER_SATELLITES_ALMANAC_READ - 4] << 24 ); } +void DeviceTransceiver::GetAlmanacAgesForSatelliteId( uint8_t sv_id, uint16_t* almanac_age ) +{ + lr1110_gnss_get_almanac_age_for_satellite( this->radio, sv_id, almanac_age ); +} + void DeviceTransceiver::UpdateAlmanac( const uint8_t* almanac_buffer, const uint8_t buffer_size ) { if( buffer_size == LR1110_GNSS_SINGLE_ALMANAC_WRITE_SIZE ) @@ -92,6 +95,37 @@ void DeviceTransceiver::UpdateAlmanac( const uint8_t* almanac_buffer, const uint } } +bool DeviceTransceiver::FetchInterrupt( InterruptionInterface** interruption ) +{ + // For the transceiver, the interrupts are all fetched at once. So the plan it to read them all from the chip, then + // to generate an interruption object with the interruption register. + // After that, the next call to FetchInterrupt must return false immediatly. + + uint32_t interruption_mask = 0; + lr1110_system_stat1_t stat1 = {}; + lr1110_system_stat2_t stat2 = {}; + + lr1110_system_get_status( this->radio, &stat1, &stat2, &interruption_mask ); + lr1110_system_clear_irq_status( this->GetRadio( ), interruption_mask ); + + bool has_interrupt = false; + if( interruption_mask == LR1110_SYSTEM_IRQ_NONE ) + { + // There is no more interrupt return false + has_interrupt = false; + } + else + { + this->last_interrupt.set_irq_mask( interruption_mask ); + this->last_interrupt.set_stat_1( stat1 ); + this->last_interrupt.set_stat_2( stat2 ); + has_interrupt = true; + } + + ( *interruption ) = &this->last_interrupt; + return has_interrupt; +} + bool DeviceTransceiver::checkAlmanacUpdate( uint32_t expected_crc ) { bool update_success = false; @@ -125,11 +159,15 @@ void DeviceTransceiver::FetchVersion( version_handler_t& version_handler ) lr1110_system_version_t lr1110_version = { 0 }; lr1110_system_get_version( this->radio, &lr1110_version ); - version_handler.version_chip_fw = lr1110_version.fw; - version_handler.version_chip_hw = lr1110_version.hw; - version_handler.version_chip_type = lr1110_version.type; + version_handler.device_type = VERSION_DEVICE_TRANSCEIVER; + version_handler.transceiver.version_chip_type = lr1110_version.type; + version_handler.transceiver.version_chip_hw = lr1110_version.hw; + version_handler.transceiver.version_chip_fw = lr1110_version.fw; lr1110_system_read_uid( this->radio, version_handler.chip_uid ); + lr1110_system_read_uid( this->radio, version_handler.dev_eui ); + lr1110_system_read_join_eui( this->radio, version_handler.join_eui ); + lr1110_system_read_pin( this->radio, version_handler.pin ); strcpy( version_handler.version_sw, DEMO_VERSION ); strcpy( version_handler.version_driver, lr1110_driver_version_get_version_string( ) ); diff --git a/embedded/gcc/redirect.c b/embedded/gcc/redirect.c new file mode 100644 index 0000000..9bee019 --- /dev/null +++ b/embedded/gcc/redirect.c @@ -0,0 +1,55 @@ +/** + * @file redirect.c + * + * @brief Implementation of the GCC printf/scanf redirection + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +extern int __io_putchar( int ch ); +extern int __io_getchar( void ); + +int _read( int file, char* data, int len ) +{ + for( int index = 0; index < len; index++ ) + { + data[index] = __io_getchar( ); + } + + return len; +} + +int _write( int file, char* data, int len ) +{ + for( int index = 0; index < len; index++ ) + { + __io_putchar( data[index] ); + } + return len; +} \ No newline at end of file diff --git a/embedded/gcc/syscalls.c b/embedded/gcc/syscalls.c deleted file mode 100644 index 568f267..0000000 --- a/embedded/gcc/syscalls.c +++ /dev/null @@ -1,194 +0,0 @@ -/** -***************************************************************************** -** -** File : syscalls.c -** -** Abstract : System Workbench Minimal System calls file -** -** For more information about which c-functions -** need which of these lowlevel functions -** please consult the Newlib libc-manual -** -** Environment : System Workbench for MCU -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -** (c)Copyright System Workbench for MCU. -** You may use this file as-is or modify it according to the needs of your -** project. Distribution of this file (unmodified or modified) is not -** permitted. System Workbench for MCU permit registered System Workbench(R) users the -** rights to distribute the assembled, compiled & linked contents of this -** file as part of an application binary file, provided that it is built -** using the System Workbench for MCU toolchain. -** -***************************************************************************** -*/ - -/* Includes */ -#include -#include -#include -#include -#include -#include -#include -#include - - -/* Variables */ -//#undef errno -extern int errno; -#define FreeRTOS -#define MAX_STACK_SIZE 0x2000 - -extern int __io_putchar(int ch) __attribute__((weak)); -extern int __io_getchar(void) __attribute__((weak)); - -#ifndef FreeRTOS - register char * stack_ptr __asm("sp"); -#endif - - -register char * stack_ptr __asm("sp"); - -char *__env[1] = { 0 }; -char **environ = __env; - - -/* Functions */ -void initialise_monitor_handles() -{ -} - -int _getpid(void) -{ - return 1; -} - -int _kill(int pid, int sig) -{ - errno = EINVAL; - return -1; -} - -void _exit (int status) -{ - _kill(status, -1); - while (1) {} /* Make sure we hang here */ -} - -int _read (int file, char *ptr, int len) -{ - int DataIdx; - - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - *ptr++ = __io_getchar(); - } - -return len; -} - -int _write(int file, char *ptr, int len) -{ - int DataIdx; - - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - __io_putchar(*ptr++); - } - return len; -} - -caddr_t _sbrk(int incr) -{ - extern char end __asm("end"); - static char *heap_end; - char *prev_heap_end; - - if (heap_end == 0) - heap_end = &end; - - prev_heap_end = heap_end; - if (heap_end + incr > stack_ptr) - { -// write(1, "Heap and stack collision\n", 25); -// abort(); - errno = ENOMEM; - return (caddr_t) -1; - } - - heap_end += incr; - - return (caddr_t) prev_heap_end; -} - -int _close(int file) -{ - return -1; -} - - -int _fstat(int file, struct stat *st) -{ - st->st_mode = S_IFCHR; - return 0; -} - -int _isatty(int file) -{ - return 1; -} - -int _lseek(int file, int ptr, int dir) -{ - return 0; -} - -int _open(char *path, int flags, ...) -{ - /* Pretend like we always fail */ - return -1; -} - -int _wait(int *status) -{ - errno = ECHILD; - return -1; -} - -int _unlink(char *name) -{ - errno = ENOENT; - return -1; -} - -int _times(struct tms *buf) -{ - return -1; -} - -int _stat(char *file, struct stat *st) -{ - st->st_mode = S_IFCHR; - return 0; -} - -int _link(char *old, char *new) -{ - errno = EMLINK; - return -1; -} - -int _fork(void) -{ - errno = EAGAIN; - return -1; -} - -int _execve(char *name, char **argv, char **env) -{ - errno = ENOMEM; - return -1; -} diff --git a/embedded/gcc/usart_redirect.c b/embedded/gcc/usart_redirect.c index 917b366..d50371e 100644 --- a/embedded/gcc/usart_redirect.c +++ b/embedded/gcc/usart_redirect.c @@ -1,3 +1,34 @@ +/** + * @file usart_redirect.c + * + * @brief Implementation of the printf/scanf redirection to system uart calls + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "system_uart.h" int __io_putchar( int ch ) { return system_uart_send_char( ch ); } diff --git a/embedded/gui/inc/gui.h b/embedded/gui/inc/gui.h index 3023dd5..bb66871 100644 --- a/embedded/gui/inc/gui.h +++ b/embedded/gui/inc/gui.h @@ -35,6 +35,7 @@ #include "guiCommon.h" #include "guiFormat.h" #include "guiMenu.h" +#include "guiConnectivity.h" #include "guiMenuRadioTestModes.h" #include "guiConfigRadioTestModes.h" #include "guiRadioTxCw.h" @@ -49,35 +50,13 @@ #include "guiTestGnss.h" #include "guiConfigWifi.h" #include "guiConfigGnss.h" +#include "guiConfigGnssAssistancePosition.h" +#include "guiEui.h" #include #include #include "stdio.h" #include "version.h" -typedef struct -{ - GuiSplashScreen* guiSplashscreen; - GuiAbout* guiAbout; - GuiMenu* guiMenu; - GuiMenuDemo* guiMenuDemo; - GuiMenuRadioTestModes* guiMenuRadioTestModes; - GuiConfigRadioTestModes* guiConfigRadioTestModes; - GuiRadioTxCw* guiRadioTxCw; - GuiRadioPer* guiRadioPer; - GuiRadioPingPong* guiRadioPingPong; - GuiTestWifi* guiTestWifi; - GuiResultsWifi* guiResultWifi; - GuiConfigWifi* guiConfigWifi; - GuiTestGnss* guiTestGnssAutonomous; - GuiResultsGnss* guiResultGnssAutonomous; - GuiConfigGnss* guiConfigGnssAutonomous; - GuiTestGnss* guiTestGnssAssisted; - GuiResultsGnss* guiResultGnssAssisted; - GuiConfigGnss* guiConfigGnssAssisted; - GuiCommon* guiCurrent; - GuiCommon* guiNext; -} GuiPages_t; - typedef enum { GUI_LAST_EVENT_NONE, @@ -94,6 +73,11 @@ typedef enum GUI_LAST_EVENT_UPDATE_DEMO_WIFI, GUI_LAST_EVENT_UPDATE_DEMO_GNSS_AUTONOMOUS, GUI_LAST_EVENT_UPDATE_DEMO_GNSS_ASSISTED, + GUI_LAST_EVENT_UPDATE_DEMO_GNSS_ASSISTANCE_POSITION, + GUI_LAST_EVENT_PRINT_EUI, + GUI_LAST_EVENT_JOIN, + GUI_LAST_EVENT_LEAVE, + GUI_LAST_EVENT_RESET_SEMTECH_DEFAULT_COMMISSIONING, } GuiLastEvent_t; class Gui @@ -103,7 +87,9 @@ class Gui virtual ~Gui( ); virtual void Init( GuiDemoSettings_t* settings, GuiDemoSettings_t* settings_default, - version_handler_t* version_handler ); + GuiGnssDemoAssistancePosition_t* assistance_position, + GuiGnssDemoAssistancePosition_t* assistance_position_default, + version_handler_t* version_handler ); virtual void Runtime( ); static void InterruptHandler( bool is_down ); @@ -111,8 +97,14 @@ class Gui void GetWifiSettings( GuiWifiDemoSetting_t* settings ); void GetGnssAutonomousSettings( GuiGnssDemoSetting_t* settings ); void GetGnssAssistedSettings( GuiGnssDemoSetting_t* settings ); + void GetGnssAssistancePosition( GuiGnssDemoAssistancePosition_t* assistance_position ); + void GetNetworkConnectivitySettings( GuiNetworkConnectivitySettings_t* connectivity_settings ); + + void EnableConnectivity( ) const; + void DisableConnectivity( ) const; void HostConnectivityChange( bool is_connected ); + void NetworkConnectivityChange( const GuiNetworkConnectivityStatus_t* new_connectivity_status ); virtual GuiLastEvent_t GetLastEvent( ); void UpdateRadioPingPongResult( GuiRadioPingPongResult_t& gui_demo_result ); @@ -142,18 +134,23 @@ class Gui } protected: - const GuiDemoResult_t& GetDemoResult( ) const { return this->demo_results; } - GuiDemoSettings_t demo_settings; - GuiDemoSettings_t demo_settings_default; + const GuiDemoResult_t& GetDemoResult( ) const { return this->demo_results; } + GuiDemoSettings_t demo_settings; + GuiDemoSettings_t demo_settings_default; + GuiGnssDemoAssistancePosition_t gnss_assistance_position; + GuiGnssDemoAssistancePosition_t gnss_assistance_position_default; + GuiNetworkConnectivitySettings_t network_connectivity_settings; + bool at_least_one_scan_done; private: + void CreateNewPage( guiPageType_t page_type ); bool refresh_pending; static volatile bool interruptPending; static bool isTouched; GuiLastEvent_t event; GuiDemoResult_t demo_results; - GuiPages_t guiPages; version_handler_t* version_handler; + GuiCommon* guiCurrent; }; #endif // __GUI_H__ diff --git a/embedded/gui/inc/guiAbout.h b/embedded/gui/inc/guiAbout.h index 877211d..648e6d9 100644 --- a/embedded/gui/inc/guiAbout.h +++ b/embedded/gui/inc/guiAbout.h @@ -42,8 +42,6 @@ class GuiAbout : public GuiCommon GuiAbout( version_handler_t* version_handler ); virtual ~GuiAbout( ); - virtual void draw( ); - static void callback( lv_obj_t* obj, lv_event_t event ); private: diff --git a/embedded/gui/inc/guiCommon.h b/embedded/gui/inc/guiCommon.h index ab63fa2..f52d3ec 100644 --- a/embedded/gui/inc/guiCommon.h +++ b/embedded/gui/inc/guiCommon.h @@ -48,7 +48,9 @@ typedef enum GUI_PAGE_NONE = 0, GUI_PAGE_SPLASHSCREEN, GUI_PAGE_ABOUT, + GUI_PAGE_EUI, GUI_PAGE_MENU, + GUI_PAGE_CONNECTIVITY, GUI_PAGE_MENU_RADIO_TEST_MODES, GUI_PAGE_RADIO_TEST_MODES_CONFIG, GUI_PAGE_RADIO_TX_CW, @@ -64,6 +66,7 @@ typedef enum GUI_PAGE_GNSS_ASSISTED_TEST, GUI_PAGE_GNSS_ASSISTED_RESULTS, GUI_PAGE_GNSS_ASSISTED_CONFIG, + GUI_PAGE_GNSS_ASSISTANCE_POSITION_CONFIG, } guiPageType_t; typedef enum @@ -79,6 +82,8 @@ typedef enum GUI_EVENT_SAVE, GUI_EVENT_SEND, GUI_EVENT_STOP, + GUI_EVENT_LAUNCH_CONNECTIVITY, + GUI_EVENT_EUI, GUI_EVENT_LAUNCH_RADIO_TEST_MODE, GUI_EVENT_LAUNCH_DEMO, GUI_EVENT_START_TX_CW, @@ -89,6 +94,11 @@ typedef enum GUI_EVENT_START_GNSS_AUTONOMOUS, GUI_EVENT_START_GNSS_ASSISTED, GUI_EVENT_START_GNSS_ASSISTED_LP, + GUI_EVENT_JOIN, + GUI_EVENT_ABORT, + GUI_EVENT_LEAVE, + GUI_EVENT_ASSISTANCE_POSITION, + GUI_EVENT_RESTORE_EUI_KEYS, } guiEvent_t; typedef enum @@ -104,15 +114,13 @@ class GuiCommon GuiCommon( guiPageType_t pageType ); virtual ~GuiCommon( ); - virtual void init( ){}; - virtual void draw( ){}; - virtual void refresh( ){}; - virtual guiEvent_t getAndClearEvent( ); - virtual void updateHostConnectivityState( ){}; - virtual void start( ){}; - virtual void stop( ){}; - virtual void updateResults( guiEvent_t event ){}; + virtual void refresh( ){}; + virtual void updateHostConnectivityState( ){}; + virtual void updateNetworkConnectivityState( ){}; + virtual void start( ){}; + virtual void stop( ){}; + guiEvent_t getAndClearEvent( ); guiPageType_t getType( ); void createSection( const char* text, int16_t y_offfset_from_center ); @@ -123,13 +131,16 @@ class GuiCommon guiButtonPos_t button_pos, int16_t y_pos, bool is_clickable ); void createChoiceSwitch( lv_obj_t** sw, lv_obj_t* screen, const char* lbl_sw_name_left, const char* lbl_sw_name_right, lv_event_cb_t event_cb, int16_t y_pos, bool is_visible ); + void createNetworkConnectivityIcon( lv_obj_t** icon ); + void updateNetworkConnectivityIcon( lv_obj_t* icon ); void updateHostConnectivityState( const bool is_connected ); + void updateNetworkConnectivityState( const GuiNetworkConnectivityStatus_t* new_connectivity_status ); + static float convertConsoToUah( const uint32_t conso_uas ); static uint32_t check_value_limits( const uint32_t value, const uint32_t limit_low, const uint32_t limit_high ); - void createHeader( const char* text ); - guiEvent_t touchEvent( uint16_t x, uint16_t y ); + void createHeader( const char* text ); static lv_style_t screen_style; static lv_style_t note_style; @@ -145,11 +156,14 @@ class GuiCommon static guiEvent_t _event; static bool _is_gui_environment_init; + static bool _has_connectivity; protected: - guiPageType_t _pageType; - lv_obj_t* screen; - static bool _is_host_connected; + guiPageType_t _pageType; + lv_obj_t* screen; + lv_obj_t* _label_connectivity_icon; + static bool _is_host_connected; + static GuiNetworkConnectivityStatus_t _network_connectivity_status; }; #endif diff --git a/embedded/gui/inc/guiConfigGnss.h b/embedded/gui/inc/guiConfigGnss.h index 607801b..824727a 100644 --- a/embedded/gui/inc/guiConfigGnss.h +++ b/embedded/gui/inc/guiConfigGnss.h @@ -33,17 +33,15 @@ #define __GUI_CONFIG_GNSS_H__ #include "guiCommon.h" +#include "version.h" class GuiConfigGnss : public GuiCommon { public: - GuiConfigGnss( guiPageType_t pageType, GuiGnssDemoSetting_t* settings, - const GuiGnssDemoSetting_t* settings_default ); + GuiConfigGnss( guiPageType_t pageType, GuiGnssDemoSetting_t* settings, const GuiGnssDemoSetting_t* settings_default, + version_handler_t* version_handler ); virtual ~GuiConfigGnss( ); - virtual void init( ); - virtual void draw( ); - static void callback( lv_obj_t* obj, lv_event_t event ); static void callbackSettings( lv_obj_t* obj, lv_event_t event ); @@ -67,4 +65,4 @@ class GuiConfigGnss : public GuiCommon const char* btnm_constellations_map[3] = { "GPS", "BEIDOU", "" }; }; -#endif +#endif // __GUI_CONFIG_GNSS_H__ diff --git a/embedded/gui/inc/guiConfigGnssAssistancePosition.h b/embedded/gui/inc/guiConfigGnssAssistancePosition.h new file mode 100644 index 0000000..71f2aa6 --- /dev/null +++ b/embedded/gui/inc/guiConfigGnssAssistancePosition.h @@ -0,0 +1,70 @@ +/** + * @file guiConfigGnssAssistancePosition.h + * + * @brief Definition of the GNSS assistance position configuration page. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __GUI_CONFIG_GNSS_ASSISTANCE_POSITION_H__ +#define __GUI_CONFIG_GNSS_ASSISTANCE_POSITION_H__ + +#include "guiCommon.h" + +class GuiConfigGnssAssistancePosition : public GuiCommon +{ + public: + GuiConfigGnssAssistancePosition( GuiGnssDemoAssistancePosition_t* settings, + const GuiGnssDemoAssistancePosition_t* settings_default ); + virtual ~GuiConfigGnssAssistancePosition( ); + + static void callback( lv_obj_t* obj, lv_event_t event ); + static void callback_ta( lv_obj_t* obj, lv_event_t event ); + static void callback_kb( lv_obj_t* obj, lv_event_t event ); + + bool IsConfigTempEqualTo( const GuiGnssDemoAssistancePosition_t* settings_to_compare ); + + void ConfigActionButton( ); + void ConfigParam( ); + + GuiGnssDemoAssistancePosition_t settings_temp; + GuiGnssDemoAssistancePosition_t* settings_current; + const GuiGnssDemoAssistancePosition_t* settings_default; + + char ta_text[10]; + + private: + void create_ta( lv_obj_t** ta, lv_obj_t* screen, int16_t off_y, const char* lbl_name, uint16_t max_length, + const char* init_text, lv_event_cb_t event_cb ); + lv_obj_t* ta_latitude; + lv_obj_t* ta_longitude; + lv_obj_t* kb_num; + lv_obj_t* btn_cancel; + lv_obj_t* btn_default; + lv_obj_t* btn_save; +}; + +#endif // __GUI_CONFIG_GNSS_ASSISTANCE_POSITION_H__ diff --git a/embedded/gui/inc/guiConfigRadioTestModes.h b/embedded/gui/inc/guiConfigRadioTestModes.h index b642d3c..1350e04 100644 --- a/embedded/gui/inc/guiConfigRadioTestModes.h +++ b/embedded/gui/inc/guiConfigRadioTestModes.h @@ -33,16 +33,15 @@ #define __GUI_CONFIG_RADIO_TEST_MODES_H__ #include "guiCommon.h" +#include "version.h" class GuiConfigRadioTestModes : public GuiCommon { public: - GuiConfigRadioTestModes( GuiRadioSetting_t* settings_current, const GuiRadioSetting_t* settings_default ); + GuiConfigRadioTestModes( GuiRadioSetting_t* settings_current, const GuiRadioSetting_t* settings_default, + version_handler_t* version_handler ); virtual ~GuiConfigRadioTestModes( ); - virtual void init( ); - virtual void draw( ); - void ConfigParamGeneric( ); void ConfigParamLora( ); void ConfigParamGfsk( ); @@ -96,6 +95,8 @@ class GuiConfigRadioTestModes : public GuiCommon GuiRadioSetting_t settings_temp; GuiRadioSetting_t* settings_current; const GuiRadioSetting_t* settings_default; + + version_device_type_t device_type; }; #endif // __GUI_CONFIG_RADIO_TEST_MODES_H__ diff --git a/embedded/gui/inc/guiConfigWifi.h b/embedded/gui/inc/guiConfigWifi.h index 23fa952..fec175a 100644 --- a/embedded/gui/inc/guiConfigWifi.h +++ b/embedded/gui/inc/guiConfigWifi.h @@ -40,9 +40,6 @@ class GuiConfigWifi : public GuiCommon GuiConfigWifi( GuiWifiDemoSetting_t* settings_current, const GuiWifiDemoSetting_t* settings_default ); virtual ~GuiConfigWifi( ); - virtual void init( ); - virtual void draw( ); - static void callback( lv_obj_t* obj, lv_event_t event ); static void callbackSettings( lv_obj_t* obj, lv_event_t event ); diff --git a/embedded/gui/inc/guiConnectivity.h b/embedded/gui/inc/guiConnectivity.h new file mode 100644 index 0000000..ed4011e --- /dev/null +++ b/embedded/gui/inc/guiConnectivity.h @@ -0,0 +1,62 @@ +/** + * @file guiMenuConnectivity.h + * + * @brief Definition of the GUI connectivity page + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __GUI_CONNECTIVITY_H__ +#define __GUI_CONNECTIVITY_H__ + +#include "guiCommon.h" + +class GuiConnectivity : public GuiCommon +{ + public: + GuiConnectivity( GuiNetworkConnectivitySettings_t* network_connectivity_settings ); + virtual ~GuiConnectivity( ); + + void updateNetworkConnectivityState( ) override; + + static void callback( lv_obj_t* obj, lv_event_t event ); + static void callback_ddlist( lv_obj_t* obj, lv_event_t event ); + + private: + void create_ddlist( lv_obj_t** ddlist, int16_t off_y, const char* lbl_name, const char* options, + lv_event_cb_t event_cb, int16_t width ); + GuiNetworkConnectivitySettings_t* _network_connectivity_settings; + lv_obj_t* btn_back; + lv_obj_t* btn_join; + lv_obj_t* btn_restore; + lv_obj_t* lbl_btn_restore; + lv_obj_t* lbl_btn_join; + lv_obj_t* lbl_connectivity_state; + lv_obj_t* ddlist_lorawan_region; + lv_obj_t* ddlist_adr_profile; +}; + +#endif // __GUI_CONNECTIVITY_H__ diff --git a/embedded/demo/inc/demo_transceiver_base.h b/embedded/gui/inc/guiEui.h similarity index 77% rename from embedded/demo/inc/demo_transceiver_base.h rename to embedded/gui/inc/guiEui.h index b808140..40164be 100644 --- a/embedded/demo/inc/demo_transceiver_base.h +++ b/embedded/gui/inc/guiEui.h @@ -1,7 +1,7 @@ /** - * @file demo_transceiver_base.h + * @file guiEui.h * - * @brief Definition of transceiver device class. + * @brief Definition of the GUI EUI page. * * Revised BSD License * Copyright Semtech Corporation 2020. All rights reserved. @@ -29,18 +29,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __DEMO_TRANSCEIVER_BASE_H__ -#define __DEMO_TRANSCEIVER_BASE_H__ +#ifndef __GUI_EUI_H__ +#define __GUI_EUI_H__ -#include "demo_base.h" -#include "device_transceiver.h" -#include "lr1110_system.h" +#include "guiCommon.h" +#include "lvgl.h" +#include "version.h" -class DemoTransceiverBase : public DemoBase +class GuiEui : public GuiCommon { public: - DemoTransceiverBase( DeviceTransceiver* device, SignalingInterface* signaling, - CommunicationInterface* communication_interface ); + GuiEui( version_handler_t* version_handler ); + virtual ~GuiEui( ); + + static void callback( lv_obj_t* obj, lv_event_t event ); + + private: + lv_obj_t* btn_back; }; -#endif // __DEMO_TRANSCEIVER_BASE_H__ \ No newline at end of file +#endif // __GUI_EUI_H__ diff --git a/embedded/gui/inc/guiFormat.h b/embedded/gui/inc/guiFormat.h index 0e18009..6fe6da7 100644 --- a/embedded/gui/inc/guiFormat.h +++ b/embedded/gui/inc/guiFormat.h @@ -84,6 +84,13 @@ typedef enum GUI_DEMO_STATUS_KO_UNKNOWN, } GuiDemoStatus_t; +typedef enum +{ + GUI_CONNECTIVITY_STATUS_NOT_CONNECTED, + GUI_CONNECTIVITY_STATUS_JOINING, + GUI_CONNECTIVITY_STATUS_CONNECTED, +} GuiConnectivityState_t; + typedef struct { GuiWifiMacAddress_t macAddr; @@ -178,6 +185,12 @@ typedef struct bool is_best_effort_activated; } GuiGnssDemoSetting_t; +typedef struct +{ + float latitude; + float longitude; +} GuiGnssDemoAssistancePosition_t; + typedef struct { uint8_t sf; @@ -217,4 +230,29 @@ typedef struct GuiGnssDemoSetting_t gnss_assisted_settings; } GuiDemoSettings_t; +typedef enum +{ + GUI_NETWORK_CONNECTIVITY_REGION_EU868, + GUI_NETWORK_CONNECTIVITY_REGION_US915, +} GuiNetworkConnectivityLorawanRegion_t; + +typedef enum +{ + GUI_NETWORK_CONNECTIVITY_ADR_NETWORK_SERVER_CONTROLLED, + GUI_NETWORK_CONNECTIVITY_ADR_MOBILE_LONG_RANGE, + GUI_NETWORK_CONNECTIVITY_ADR_MOBILE_LOW_POWER, +} GuiNetworkConnectivityAdrProfile_t; + +typedef struct +{ + GuiNetworkConnectivityLorawanRegion_t region; + GuiNetworkConnectivityAdrProfile_t adr_profile; +} GuiNetworkConnectivitySettings_t; + +typedef struct +{ + GuiConnectivityState_t connectivity_state; + bool is_time_sync; +} GuiNetworkConnectivityStatus_t; + #endif diff --git a/embedded/gui/inc/guiMenu.h b/embedded/gui/inc/guiMenu.h index e882ec9..f072434 100644 --- a/embedded/gui/inc/guiMenu.h +++ b/embedded/gui/inc/guiMenu.h @@ -33,15 +33,14 @@ #define __GUI_MENU_H__ #include "guiMenuCommon.h" +#include "version.h" class GuiMenu : public GuiMenuCommon { public: - GuiMenu( ); + GuiMenu( version_handler_t* version_handler ); virtual ~GuiMenu( ); - virtual void draw( ); - static void callback( lv_obj_t* obj, lv_event_t event ); private: @@ -51,6 +50,12 @@ class GuiMenu : public GuiMenuCommon lv_obj_t* lbl_demos; lv_obj_t* btn_demos; lv_obj_t* lbl_btn_demos; + lv_obj_t* lbl_connectivity; + lv_obj_t* btn_connectivity; + lv_obj_t* lbl_btn_connectivity; + lv_obj_t* lbl_eui; + lv_obj_t* btn_eui; + lv_obj_t* lbl_btn_eui; }; #endif diff --git a/embedded/gui/inc/guiMenuCommon.h b/embedded/gui/inc/guiMenuCommon.h index 7202ec9..5895fe0 100644 --- a/embedded/gui/inc/guiMenuCommon.h +++ b/embedded/gui/inc/guiMenuCommon.h @@ -40,7 +40,7 @@ class GuiMenuCommon : public GuiCommon GuiMenuCommon( guiPageType_t pageType ); virtual ~GuiMenuCommon( ); - void createTestEntry( int16_t y_pos, lv_obj_t** lbl, lv_obj_t** btn, lv_obj_t** lbl_btn, const char* lbl_name, + void createTestEntry( uint8_t index, lv_obj_t** lbl, lv_obj_t** btn, lv_obj_t** lbl_btn, const char* lbl_name, bool is_clickable, lv_event_cb_t event_cb ); }; diff --git a/embedded/gui/inc/guiMenuDemo.h b/embedded/gui/inc/guiMenuDemo.h index a34089d..80f391a 100644 --- a/embedded/gui/inc/guiMenuDemo.h +++ b/embedded/gui/inc/guiMenuDemo.h @@ -33,19 +33,21 @@ #define __GUI_MENU_DEMO_H__ #include "guiMenuCommon.h" +#include "version.h" class GuiMenuDemo : public GuiMenuCommon { public: - GuiMenuDemo( ); + GuiMenuDemo( version_handler_t* version_handler ); virtual ~GuiMenuDemo( ); - virtual void draw( ); virtual void updateHostConnectivityState( ); + virtual void updateNetworkConnectivityState( ); static void callback( lv_obj_t* obj, lv_event_t event ); private: + void updateButtons( ); lv_obj_t* lbl_wifi; lv_obj_t* btn_wifi; lv_obj_t* lbl_btn_wifi; diff --git a/embedded/gui/inc/guiMenuRadioTestModes.h b/embedded/gui/inc/guiMenuRadioTestModes.h index cb804cb..7c49896 100644 --- a/embedded/gui/inc/guiMenuRadioTestModes.h +++ b/embedded/gui/inc/guiMenuRadioTestModes.h @@ -33,15 +33,14 @@ #define __GUI_MENU_RADIO_TEST_MODES_H__ #include "guiMenuCommon.h" +#include "version.h" class GuiMenuRadioTestModes : public GuiMenuCommon { public: - GuiMenuRadioTestModes( ); + GuiMenuRadioTestModes( version_handler_t* version_handler ); virtual ~GuiMenuRadioTestModes( ); - virtual void draw( ); - static void callback( lv_obj_t* obj, lv_event_t event ); private: diff --git a/embedded/gui/inc/guiRadioPer.h b/embedded/gui/inc/guiRadioPer.h index 2f666b7..d8fb4c4 100644 --- a/embedded/gui/inc/guiRadioPer.h +++ b/embedded/gui/inc/guiRadioPer.h @@ -40,8 +40,6 @@ class GuiRadioPer : public GuiCommon GuiRadioPer( const GuiRadioSetting_t* settings, const GuiRadioPerResult_t* results ); virtual ~GuiRadioPer( ); - virtual void init( ); - virtual void draw( ); virtual void refresh( ); virtual void start( ); virtual void stop( ); diff --git a/embedded/gui/inc/guiRadioPingPong.h b/embedded/gui/inc/guiRadioPingPong.h index abd459a..aa72902 100644 --- a/embedded/gui/inc/guiRadioPingPong.h +++ b/embedded/gui/inc/guiRadioPingPong.h @@ -40,8 +40,6 @@ class GuiRadioPingPong : public GuiCommon GuiRadioPingPong( const GuiRadioSetting_t* settings, const GuiRadioPingPongResult_t* results ); virtual ~GuiRadioPingPong( ); - virtual void init( ); - virtual void draw( ); virtual void refresh( ); virtual void start( ); virtual void stop( ); diff --git a/embedded/gui/inc/guiRadioTxCw.h b/embedded/gui/inc/guiRadioTxCw.h index 1f30a9d..fefb3bb 100644 --- a/embedded/gui/inc/guiRadioTxCw.h +++ b/embedded/gui/inc/guiRadioTxCw.h @@ -40,12 +40,8 @@ class GuiRadioTxCw : public GuiCommon GuiRadioTxCw( const GuiRadioSetting_t* settings ); virtual ~GuiRadioTxCw( ); - virtual void init( ); - virtual void draw( ); - virtual void refresh( ); virtual void start( ); virtual void stop( ); - virtual void updateHostConnectivityState( ); static void callback( lv_obj_t* obj, lv_event_t event ); diff --git a/embedded/gui/inc/guiResultsGnss.h b/embedded/gui/inc/guiResultsGnss.h index 11e58d0..b455b57 100644 --- a/embedded/gui/inc/guiResultsGnss.h +++ b/embedded/gui/inc/guiResultsGnss.h @@ -42,8 +42,7 @@ class GuiResultsGnss : public GuiCommon GuiResultsGnss( const GuiGnssResult_t* results, guiPageType_t pageType ); virtual ~GuiResultsGnss( ); - virtual void draw( ); - virtual void updateResults( guiEvent_t event ); + void findAndDisplayNextPage( bool up ); static void callback( lv_obj_t* obj, lv_event_t event ); @@ -57,7 +56,6 @@ class GuiResultsGnss : public GuiCommon void setResults( ); uint8_t _pageTotal; uint8_t _pageCurrent; - uint8_t _index; const GuiGnssResult_t* _results; }; diff --git a/embedded/gui/inc/guiResultsWifi.h b/embedded/gui/inc/guiResultsWifi.h index 132ddc7..cc3d374 100644 --- a/embedded/gui/inc/guiResultsWifi.h +++ b/embedded/gui/inc/guiResultsWifi.h @@ -40,9 +40,6 @@ class GuiResultsWifi : public GuiCommon GuiResultsWifi( const GuiWifiResult_t* results ); virtual ~GuiResultsWifi( ); - virtual void draw( ); - virtual void updateResults( guiEvent_t event ); - static void callback( lv_obj_t* obj, lv_event_t event ); lv_obj_t* table; @@ -52,11 +49,12 @@ class GuiResultsWifi : public GuiCommon lv_obj_t* btn_back; private: - void findNextChannel( bool up ); - void setChannelResults( ); - bool _isSeveralPages; - uint8_t _index; - const GuiWifiResult_t* _results; + void findAndDisplayFirstNonEmptyChannel( ); + void findAndDisplayNextChannel( bool up ); + void setChannelResults( ); + uint8_t _index; + const GuiWifiResult_t* _results; + const GuiWifiResultChannel_t* _current_chan; }; #endif diff --git a/embedded/gui/inc/guiSplashScreen.h b/embedded/gui/inc/guiSplashScreen.h index a6fb23e..cac9f4a 100644 --- a/embedded/gui/inc/guiSplashScreen.h +++ b/embedded/gui/inc/guiSplashScreen.h @@ -33,16 +33,15 @@ #define __GUI_SPLASH_SCREEN_H__ #include "guiCommon.h" +#include "version.h" #include "lvgl.h" class GuiSplashScreen : public GuiCommon { public: - GuiSplashScreen( ); + GuiSplashScreen( version_handler_t* version_handler ); virtual ~GuiSplashScreen( ); - virtual void draw( ); - static void callback( lv_obj_t* obj, lv_event_t event ); private: diff --git a/embedded/gui/inc/guiTestGnss.h b/embedded/gui/inc/guiTestGnss.h index 1caeff1..ed6d1ee 100644 --- a/embedded/gui/inc/guiTestGnss.h +++ b/embedded/gui/inc/guiTestGnss.h @@ -37,14 +37,13 @@ class GuiTestGnss : public GuiCommon { public: - GuiTestGnss( const GuiGnssResult_t* results, guiPageType_t pageType ); + GuiTestGnss( const GuiGnssResult_t* results, guiPageType_t pageType, bool at_least_one_scan_done ); virtual ~GuiTestGnss( ); - virtual void init( ); virtual void start( ); - virtual void draw( ); virtual void refresh( ); virtual void updateHostConnectivityState( void ); + virtual void updateNetworkConnectivityState( ); static void callback( lv_obj_t* obj, lv_event_t event ); @@ -57,8 +56,10 @@ class GuiTestGnss : public GuiCommon lv_obj_t* btn_send; lv_obj_t* btn_back; lv_obj_t* btn_config; + lv_obj_t* btn_assist; private: + void updateButtons( ); const GuiGnssResult_t* _results; }; diff --git a/embedded/gui/inc/guiTestWifi.h b/embedded/gui/inc/guiTestWifi.h index 8ad63c6..2412022 100644 --- a/embedded/gui/inc/guiTestWifi.h +++ b/embedded/gui/inc/guiTestWifi.h @@ -37,14 +37,13 @@ class GuiTestWifi : public GuiCommon { public: - GuiTestWifi( const GuiWifiResult_t* results ); + GuiTestWifi( const GuiWifiResult_t* results, bool at_least_one_scan_done ); virtual ~GuiTestWifi( ); - virtual void init( ); - virtual void draw( ); virtual void refresh( ); virtual void start( ); virtual void updateHostConnectivityState( ); + virtual void updateNetworkConnectivityState( ); static void callback( lv_obj_t* obj, lv_event_t event ); @@ -59,6 +58,7 @@ class GuiTestWifi : public GuiCommon lv_obj_t* btn_config; private: + void updateButtons( ); const GuiWifiResult_t* _results; }; diff --git a/embedded/gui/src/gui.cpp b/embedded/gui/src/gui.cpp index af1efe0..dea07a7 100644 --- a/embedded/gui/src/gui.cpp +++ b/embedded/gui/src/gui.cpp @@ -43,54 +43,43 @@ Gui::Gui( ) : refresh_pending( false ), event( GUI_LAST_EVENT_NONE ) Gui::~Gui( ) {} -void Gui::Init( GuiDemoSettings_t* settings, GuiDemoSettings_t* settings_default, version_handler_t* version_handler ) +void Gui::Init( GuiDemoSettings_t* settings, GuiDemoSettings_t* settings_default, + GuiGnssDemoAssistancePosition_t* assistance_position, + GuiGnssDemoAssistancePosition_t* assistance_position_default, version_handler_t* version_handler ) { - this->demo_settings = *settings; - this->demo_settings_default = *settings_default; - this->version_handler = version_handler; - - guiPages.guiSplashscreen = new GuiSplashScreen( ); - - guiPages.guiAbout = new GuiAbout( this->version_handler ); - - guiPages.guiMenu = new GuiMenu( ); - - guiPages.guiMenuRadioTestModes = new GuiMenuRadioTestModes( ); - guiPages.guiConfigRadioTestModes = new GuiConfigRadioTestModes( &( this->demo_settings.radio_settings ), - &( this->demo_settings_default.radio_settings ) ); - - guiPages.guiMenuDemo = new GuiMenuDemo( ); - - guiPages.guiCurrent = guiPages.guiSplashscreen; - guiPages.guiNext = guiPages.guiCurrent; - guiPages.guiCurrent->draw( ); - - this->demo_results.wifi_result.nbMacAddrTotal = 0; + this->demo_settings = *settings; + this->demo_settings_default = *settings_default; + this->gnss_assistance_position = *assistance_position; + this->gnss_assistance_position_default = *assistance_position_default; + this->version_handler = version_handler; + this->network_connectivity_settings.region = GUI_NETWORK_CONNECTIVITY_REGION_EU868; + this->network_connectivity_settings.adr_profile = GUI_NETWORK_CONNECTIVITY_ADR_NETWORK_SERVER_CONTROLLED; + + this->guiCurrent = new GuiSplashScreen( this->version_handler ); } void Gui::Runtime( ) { - guiEvent_t event_from_display; + guiEvent_t event_from_display = GUI_EVENT_NONE; + guiPageType_t next_page_type = GUI_PAGE_NONE; + + this->event = GUI_LAST_EVENT_NONE; - event_from_display = guiPages.guiCurrent->getAndClearEvent( ); + event_from_display = this->guiCurrent->getAndClearEvent( ); if( event_from_display != GUI_EVENT_NONE ) { - switch( guiPages.guiCurrent->getType( ) ) + switch( this->guiCurrent->getType( ) ) { case GUI_PAGE_SPLASHSCREEN: { switch( event_from_display ) { case GUI_EVENT_NEXT: - delete guiPages.guiSplashscreen; - delete guiPages.guiAbout; - guiPages.guiSplashscreen = NULL; - guiPages.guiAbout = NULL; - this->guiPages.guiNext = this->guiPages.guiMenu; + next_page_type = GUI_PAGE_MENU; break; case GUI_EVENT_ABOUT: - this->guiPages.guiNext = this->guiPages.guiAbout; + next_page_type = GUI_PAGE_ABOUT; break; default: break; @@ -103,7 +92,7 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - this->guiPages.guiNext = this->guiPages.guiSplashscreen; + next_page_type = GUI_PAGE_SPLASHSCREEN; break; default: break; @@ -116,10 +105,54 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_LAUNCH_RADIO_TEST_MODE: - this->guiPages.guiNext = this->guiPages.guiMenuRadioTestModes; + next_page_type = GUI_PAGE_MENU_RADIO_TEST_MODES; break; case GUI_EVENT_LAUNCH_DEMO: - this->guiPages.guiNext = this->guiPages.guiMenuDemo; + next_page_type = GUI_PAGE_MENU_DEMO; + break; + case GUI_EVENT_LAUNCH_CONNECTIVITY: + next_page_type = GUI_PAGE_CONNECTIVITY; + break; + case GUI_EVENT_EUI: + next_page_type = GUI_PAGE_EUI; + break; + default: + break; + } + break; + } + + case GUI_PAGE_CONNECTIVITY: + { + switch( event_from_display ) + { + case GUI_EVENT_JOIN: + this->event = GUI_LAST_EVENT_JOIN; + break; + case GUI_EVENT_ABORT: + this->event = GUI_LAST_EVENT_LEAVE; + break; + case GUI_EVENT_LEAVE: + this->event = GUI_LAST_EVENT_LEAVE; + break; + case GUI_EVENT_RESTORE_EUI_KEYS: + this->event = GUI_LAST_EVENT_RESET_SEMTECH_DEFAULT_COMMISSIONING; + break; + case GUI_EVENT_BACK: + next_page_type = GUI_PAGE_MENU; + break; + default: + break; + } + break; + } + + case GUI_PAGE_EUI: + { + switch( event_from_display ) + { + case GUI_EVENT_BACK: + next_page_type = GUI_PAGE_MENU; break; default: break; @@ -132,28 +165,20 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_START_TX_CW: - this->guiPages.guiRadioTxCw = new GuiRadioTxCw( &( this->demo_settings.radio_settings ) ); - this->guiPages.guiNext = this->guiPages.guiRadioTxCw; - this->guiPages.guiNext->init( ); + next_page_type = GUI_PAGE_RADIO_TX_CW; break; case GUI_EVENT_START_PER_TX: case GUI_EVENT_START_PER_RX: - this->guiPages.guiRadioPer = new GuiRadioPer( &( this->demo_settings.radio_settings ), - &( this->demo_results.radio_per_result ) ); - this->guiPages.guiNext = this->guiPages.guiRadioPer; - this->guiPages.guiNext->init( ); + next_page_type = GUI_PAGE_RADIO_PER; break; case GUI_EVENT_START_PING_PONG: - this->guiPages.guiRadioPingPong = new GuiRadioPingPong( &( this->demo_settings.radio_settings ), - &( this->demo_results.radio_pingpong_result ) ); - this->guiPages.guiNext = this->guiPages.guiRadioPingPong; - this->guiPages.guiNext->init( ); + next_page_type = GUI_PAGE_RADIO_PING_PONG; break; case GUI_EVENT_CONFIG: - this->guiPages.guiNext = this->guiPages.guiConfigRadioTestModes; + next_page_type = GUI_PAGE_RADIO_TEST_MODES_CONFIG; break; case GUI_EVENT_BACK: - this->guiPages.guiNext = this->guiPages.guiMenu; + next_page_type = GUI_PAGE_MENU; break; default: break; @@ -166,11 +191,11 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - this->guiPages.guiNext = this->guiPages.guiMenuRadioTestModes; + next_page_type = GUI_PAGE_MENU_RADIO_TEST_MODES; break; case GUI_EVENT_SAVE: - guiPages.guiNext = guiPages.guiMenuRadioTestModes; - this->event = GUI_LAST_EVENT_UPDATE_DEMO_RADIO; + next_page_type = GUI_PAGE_MENU_RADIO_TEST_MODES; + this->event = GUI_LAST_EVENT_UPDATE_DEMO_RADIO; break; default: break; @@ -183,18 +208,18 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_START_TX_CW: - this->guiPages.guiCurrent->start( ); + this->guiCurrent->start( ); this->event = GUI_LAST_EVENT_START_DEMO_TX_CW; break; case GUI_EVENT_STOP: - this->guiPages.guiCurrent->stop( ); + this->guiCurrent->stop( ); this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_BACK: - delete this->guiPages.guiRadioTxCw; - this->guiPages.guiRadioTxCw = NULL; - this->guiPages.guiNext = this->guiPages.guiMenuRadioTestModes; - this->event = GUI_LAST_EVENT_STOP_DEMO; + next_page_type = GUI_PAGE_MENU_RADIO_TEST_MODES; + this->event = GUI_LAST_EVENT_STOP_DEMO; + break; + default: break; } break; @@ -205,22 +230,22 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_START_PER_TX: - this->guiPages.guiCurrent->start( ); + this->guiCurrent->start( ); this->event = GUI_LAST_EVENT_START_DEMO_PER_TX; break; case GUI_EVENT_START_PER_RX: - this->guiPages.guiCurrent->start( ); + this->guiCurrent->start( ); this->event = GUI_LAST_EVENT_START_DEMO_PER_RX; break; case GUI_EVENT_STOP: - this->guiPages.guiCurrent->stop( ); + this->guiCurrent->stop( ); this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_BACK: - delete this->guiPages.guiRadioPer; - this->guiPages.guiRadioPer = NULL; - this->guiPages.guiNext = this->guiPages.guiMenuRadioTestModes; - this->event = GUI_LAST_EVENT_STOP_DEMO; + next_page_type = GUI_PAGE_MENU_RADIO_TEST_MODES; + this->event = GUI_LAST_EVENT_STOP_DEMO; + break; + default: break; } break; @@ -231,18 +256,18 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_START_PING_PONG: - this->guiPages.guiCurrent->start( ); + this->guiCurrent->start( ); this->event = GUI_LAST_EVENT_START_DEMO_PING_PONG; break; case GUI_EVENT_STOP: - this->guiPages.guiCurrent->stop( ); + this->guiCurrent->stop( ); this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_BACK: - delete this->guiPages.guiRadioPingPong; - this->guiPages.guiRadioPingPong = NULL; - this->guiPages.guiNext = this->guiPages.guiMenuRadioTestModes; - this->event = GUI_LAST_EVENT_STOP_DEMO; + next_page_type = GUI_PAGE_MENU_RADIO_TEST_MODES; + this->event = GUI_LAST_EVENT_STOP_DEMO; + break; + default: break; } break; @@ -253,40 +278,21 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_START_WIFI: - guiPages.guiTestWifi = new GuiTestWifi( &demo_results.wifi_result ); - guiPages.guiResultWifi = new GuiResultsWifi( &demo_results.wifi_result ); - guiPages.guiConfigWifi = new GuiConfigWifi( &( this->demo_settings.wifi_settings ), - &( this->demo_settings_default.wifi_settings ) ); - this->guiPages.guiNext = this->guiPages.guiTestWifi; - this->guiPages.guiNext->init( ); + next_page_type = GUI_PAGE_WIFI_TEST; + this->at_least_one_scan_done = false; break; case GUI_EVENT_START_GNSS_AUTONOMOUS: - guiPages.guiTestGnssAutonomous = - new GuiTestGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_AUTONOMOUS_TEST ); - guiPages.guiResultGnssAutonomous = - new GuiResultsGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_AUTONOMOUS_RESULTS ); - guiPages.guiConfigGnssAutonomous = new GuiConfigGnss( - GUI_PAGE_GNSS_AUTONOMOUS_CONFIG, &( this->demo_settings.gnss_autonomous_settings ), - &( this->demo_settings_default.gnss_autonomous_settings ) ); - this->guiPages.guiNext = this->guiPages.guiTestGnssAutonomous; - this->guiPages.guiNext->init( ); + next_page_type = GUI_PAGE_GNSS_AUTONOMOUS_TEST; + this->at_least_one_scan_done = false; break; case GUI_EVENT_START_GNSS_ASSISTED: - guiPages.guiTestGnssAssisted = - new GuiTestGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_ASSISTED_TEST ); - guiPages.guiResultGnssAssisted = - new GuiResultsGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_ASSISTED_RESULTS ); - guiPages.guiConfigGnssAssisted = - new GuiConfigGnss( GUI_PAGE_GNSS_ASSISTED_CONFIG, &( this->demo_settings.gnss_assisted_settings ), - &( this->demo_settings_default.gnss_assisted_settings ) ); - this->guiPages.guiNext = this->guiPages.guiTestGnssAssisted; - this->guiPages.guiNext->init( ); + next_page_type = GUI_PAGE_GNSS_ASSISTED_TEST; + this->at_least_one_scan_done = false; break; case GUI_EVENT_BACK: - this->guiPages.guiNext = this->guiPages.guiMenu; + next_page_type = GUI_PAGE_MENU; break; default: - this->event = GUI_LAST_EVENT_NONE; break; } break; @@ -296,31 +302,26 @@ void Gui::Runtime( ) { switch( event_from_display ) { + case GUI_EVENT_START_WIFI: + this->guiCurrent->start( ); + this->event = GUI_LAST_EVENT_START_DEMO_WIFI; + this->at_least_one_scan_done = true; + break; case GUI_EVENT_STOP: this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_BACK: - delete guiPages.guiTestWifi; - delete guiPages.guiResultWifi; - delete guiPages.guiConfigWifi; - guiPages.guiTestWifi = NULL; - guiPages.guiResultWifi = NULL; - guiPages.guiConfigWifi = NULL; - guiPages.guiNext = guiPages.guiMenuDemo; - this->event = GUI_LAST_EVENT_STOP_DEMO; - break; - case GUI_EVENT_START_WIFI: - guiPages.guiCurrent->start( ); - this->event = GUI_LAST_EVENT_START_DEMO_WIFI; + next_page_type = GUI_PAGE_MENU_DEMO; + this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_RESULTS: - guiPages.guiNext = guiPages.guiResultWifi; + next_page_type = GUI_PAGE_WIFI_RESULTS; break; case GUI_EVENT_SEND: this->event = GUI_LAST_EVENT_SEND; break; case GUI_EVENT_CONFIG: - guiPages.guiNext = guiPages.guiConfigWifi; + next_page_type = GUI_PAGE_WIFI_CONFIG; break; default: break; @@ -333,11 +334,7 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - guiPages.guiNext = guiPages.guiTestWifi; - break; - case GUI_EVENT_LEFT: - case GUI_EVENT_RIGHT: - guiPages.guiCurrent->updateResults( event_from_display ); + next_page_type = GUI_PAGE_WIFI_TEST; break; default: break; @@ -350,11 +347,11 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - guiPages.guiNext = guiPages.guiTestWifi; + next_page_type = GUI_PAGE_WIFI_TEST; break; case GUI_EVENT_SAVE: - guiPages.guiNext = guiPages.guiTestWifi; - this->event = GUI_LAST_EVENT_UPDATE_DEMO_WIFI; + next_page_type = GUI_PAGE_WIFI_TEST; + this->event = GUI_LAST_EVENT_UPDATE_DEMO_WIFI; break; default: break; @@ -370,27 +367,22 @@ void Gui::Runtime( ) this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_BACK: - delete guiPages.guiTestGnssAutonomous; - delete guiPages.guiResultGnssAutonomous; - delete guiPages.guiConfigGnssAutonomous; - guiPages.guiTestGnssAutonomous = NULL; - guiPages.guiResultGnssAutonomous = NULL; - guiPages.guiConfigGnssAutonomous = NULL; - this->event = GUI_LAST_EVENT_STOP_DEMO; - guiPages.guiNext = guiPages.guiMenuDemo; + next_page_type = GUI_PAGE_MENU_DEMO; + this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_START_GNSS_AUTONOMOUS: - guiPages.guiCurrent->start( ); - this->event = GUI_LAST_EVENT_START_DEMO_GNSS_AUTONOMOUS; + this->guiCurrent->start( ); + this->event = GUI_LAST_EVENT_START_DEMO_GNSS_AUTONOMOUS; + this->at_least_one_scan_done = true; break; case GUI_EVENT_RESULTS: - guiPages.guiNext = guiPages.guiResultGnssAutonomous; + next_page_type = GUI_PAGE_GNSS_AUTONOMOUS_RESULTS; break; case GUI_EVENT_SEND: this->event = GUI_LAST_EVENT_SEND; break; case GUI_EVENT_CONFIG: - guiPages.guiNext = guiPages.guiConfigGnssAutonomous; + next_page_type = GUI_PAGE_GNSS_AUTONOMOUS_CONFIG; break; default: break; @@ -403,11 +395,7 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - guiPages.guiNext = guiPages.guiTestGnssAutonomous; - break; - case GUI_EVENT_LEFT: - case GUI_EVENT_RIGHT: - guiPages.guiCurrent->updateResults( event_from_display ); + next_page_type = GUI_PAGE_GNSS_AUTONOMOUS_TEST; break; default: break; @@ -420,11 +408,11 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - guiPages.guiNext = guiPages.guiTestGnssAutonomous; + next_page_type = GUI_PAGE_GNSS_AUTONOMOUS_TEST; break; case GUI_EVENT_SAVE: - guiPages.guiNext = guiPages.guiTestGnssAutonomous; - this->event = GUI_LAST_EVENT_UPDATE_DEMO_GNSS_AUTONOMOUS; + next_page_type = GUI_PAGE_GNSS_AUTONOMOUS_TEST; + this->event = GUI_LAST_EVENT_UPDATE_DEMO_GNSS_AUTONOMOUS; break; default: break; @@ -435,31 +423,29 @@ void Gui::Runtime( ) case GUI_PAGE_GNSS_ASSISTED_TEST: switch( event_from_display ) { + case GUI_EVENT_START_GNSS_ASSISTED: + this->guiCurrent->start( ); + this->event = GUI_LAST_EVENT_START_DEMO_GNSS_ASSISTED; + this->at_least_one_scan_done = true; + break; case GUI_EVENT_STOP: this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_BACK: - delete guiPages.guiTestGnssAssisted; - delete guiPages.guiResultGnssAssisted; - delete guiPages.guiConfigGnssAssisted; - guiPages.guiTestGnssAssisted = NULL; - guiPages.guiResultGnssAssisted = NULL; - guiPages.guiConfigGnssAssisted = NULL; - this->event = GUI_LAST_EVENT_STOP_DEMO; - guiPages.guiNext = guiPages.guiMenuDemo; - break; - case GUI_EVENT_START_GNSS_ASSISTED: - guiPages.guiCurrent->start( ); - this->event = GUI_LAST_EVENT_START_DEMO_GNSS_ASSISTED; + next_page_type = GUI_PAGE_MENU_DEMO; + this->event = GUI_LAST_EVENT_STOP_DEMO; break; case GUI_EVENT_RESULTS: - guiPages.guiNext = guiPages.guiResultGnssAssisted; + next_page_type = GUI_PAGE_GNSS_ASSISTED_RESULTS; break; case GUI_EVENT_SEND: this->event = GUI_LAST_EVENT_SEND; break; case GUI_EVENT_CONFIG: - guiPages.guiNext = guiPages.guiConfigGnssAssisted; + next_page_type = GUI_PAGE_GNSS_ASSISTED_CONFIG; + break; + case GUI_EVENT_ASSISTANCE_POSITION: + next_page_type = GUI_PAGE_GNSS_ASSISTANCE_POSITION_CONFIG; break; default: break; @@ -471,11 +457,7 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - guiPages.guiNext = guiPages.guiTestGnssAssisted; - break; - case GUI_EVENT_LEFT: - case GUI_EVENT_RIGHT: - guiPages.guiCurrent->updateResults( event_from_display ); + next_page_type = GUI_PAGE_GNSS_ASSISTED_TEST; break; default: break; @@ -487,11 +469,11 @@ void Gui::Runtime( ) switch( event_from_display ) { case GUI_EVENT_BACK: - guiPages.guiNext = guiPages.guiTestGnssAssisted; + next_page_type = GUI_PAGE_GNSS_ASSISTED_TEST; break; case GUI_EVENT_SAVE: - guiPages.guiNext = guiPages.guiTestGnssAssisted; - this->event = GUI_LAST_EVENT_UPDATE_DEMO_GNSS_ASSISTED; + next_page_type = GUI_PAGE_GNSS_ASSISTED_TEST; + this->event = GUI_LAST_EVENT_UPDATE_DEMO_GNSS_ASSISTED; break; default: break; @@ -499,21 +481,34 @@ void Gui::Runtime( ) break; } - default: + case GUI_PAGE_GNSS_ASSISTANCE_POSITION_CONFIG: + { + switch( event_from_display ) + { + case GUI_EVENT_BACK: + next_page_type = GUI_PAGE_GNSS_ASSISTED_TEST; + break; + case GUI_EVENT_SAVE: + next_page_type = GUI_PAGE_GNSS_ASSISTED_TEST; + this->event = GUI_LAST_EVENT_UPDATE_DEMO_GNSS_ASSISTANCE_POSITION; + break; + default: + break; + } break; } - if( ( guiPages.guiCurrent == NULL ) || ( guiPages.guiCurrent->getType( ) != guiPages.guiNext->getType( ) ) ) - { - guiPages.guiNext->draw( ); - guiPages.guiCurrent = guiPages.guiNext; + default: + break; } } + this->CreateNewPage( next_page_type ); + if( this->refresh_pending == true ) { this->refresh_pending = false; - guiPages.guiCurrent->refresh( ); + this->guiCurrent->refresh( ); } lv_task_handler( ); @@ -533,15 +528,31 @@ void Gui::GetGnssAssistedSettings( GuiGnssDemoSetting_t* settings ) *settings = this->demo_settings.gnss_assisted_settings; } +void Gui::GetGnssAssistancePosition( GuiGnssDemoAssistancePosition_t* assistance_position ) +{ + *assistance_position = this->gnss_assistance_position; +} + +void Gui::GetNetworkConnectivitySettings( GuiNetworkConnectivitySettings_t* connectivity_settings ) +{ + *connectivity_settings = this->network_connectivity_settings; +} + +void Gui::EnableConnectivity( ) const { GuiCommon::_has_connectivity = true; } + +void Gui::DisableConnectivity( ) const { GuiCommon::_has_connectivity = false; } + void Gui::InterruptHandler( bool is_down ) { interruptPending = true; Gui::isTouched = is_down; } -void Gui::HostConnectivityChange( bool is_connected ) +void Gui::HostConnectivityChange( bool is_connected ) { this->guiCurrent->updateHostConnectivityState( is_connected ); } + +void Gui::NetworkConnectivityChange( const GuiNetworkConnectivityStatus_t* new_connectivity_status ) { - guiPages.guiCurrent->updateHostConnectivityState( is_connected ); + this->guiCurrent->updateNetworkConnectivityState( new_connectivity_status ); } GuiLastEvent_t Gui::GetLastEvent( ) @@ -585,3 +596,135 @@ void Gui::UpdateReverseGeoCoding( const GuiResultGeoLoc_t& new_reverse_geo_codin void Gui::SetDemoStatus( GuiDemoStatus_t& demo_status ) {} bool Gui::HasRefreshPending( ) const { return this->refresh_pending; } + +void Gui::CreateNewPage( guiPageType_t page_type ) +{ + if( page_type != GUI_PAGE_NONE ) + { + delete this->guiCurrent; + this->guiCurrent = NULL; + + switch( page_type ) + { + case GUI_PAGE_SPLASHSCREEN: + { + this->guiCurrent = new GuiSplashScreen( this->version_handler ); + break; + } + case GUI_PAGE_ABOUT: + { + this->guiCurrent = new GuiAbout( this->version_handler ); + break; + } + case GUI_PAGE_MENU: + { + this->guiCurrent = new GuiMenu( this->version_handler ); + break; + } + case GUI_PAGE_CONNECTIVITY: + { + this->guiCurrent = new GuiConnectivity( &( this->network_connectivity_settings ) ); + break; + } + case GUI_PAGE_MENU_DEMO: + { + this->guiCurrent = new GuiMenuDemo( this->version_handler ); + break; + } + case GUI_PAGE_MENU_RADIO_TEST_MODES: + { + this->guiCurrent = new GuiMenuRadioTestModes( this->version_handler ); + break; + } + case GUI_PAGE_EUI: + { + this->guiCurrent = new GuiEui( this->version_handler ); + break; + } + case GUI_PAGE_WIFI_TEST: + { + this->guiCurrent = new GuiTestWifi( &demo_results.wifi_result, this->at_least_one_scan_done ); + break; + } + case GUI_PAGE_WIFI_CONFIG: + { + this->guiCurrent = new GuiConfigWifi( &( this->demo_settings.wifi_settings ), + &( this->demo_settings_default.wifi_settings ) ); + break; + } + case GUI_PAGE_WIFI_RESULTS: + { + this->guiCurrent = new GuiResultsWifi( &demo_results.wifi_result ); + break; + } + case GUI_PAGE_GNSS_AUTONOMOUS_TEST: + { + this->guiCurrent = new GuiTestGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_AUTONOMOUS_TEST, + this->at_least_one_scan_done ); + break; + } + case GUI_PAGE_GNSS_AUTONOMOUS_CONFIG: + { + this->guiCurrent = + new GuiConfigGnss( GUI_PAGE_GNSS_AUTONOMOUS_CONFIG, &demo_settings.gnss_autonomous_settings, + &demo_settings_default.gnss_autonomous_settings, this->version_handler ); + break; + } + case GUI_PAGE_GNSS_AUTONOMOUS_RESULTS: + { + this->guiCurrent = new GuiResultsGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_AUTONOMOUS_RESULTS ); + break; + } + case GUI_PAGE_GNSS_ASSISTED_TEST: + { + this->guiCurrent = + new GuiTestGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_ASSISTED_TEST, this->at_least_one_scan_done ); + break; + } + case GUI_PAGE_GNSS_ASSISTED_CONFIG: + { + this->guiCurrent = + new GuiConfigGnss( GUI_PAGE_GNSS_ASSISTED_CONFIG, &demo_settings.gnss_assisted_settings, + &demo_settings_default.gnss_assisted_settings, this->version_handler ); + break; + } + case GUI_PAGE_GNSS_ASSISTED_RESULTS: + { + this->guiCurrent = new GuiResultsGnss( &demo_results.gnss_result, GUI_PAGE_GNSS_ASSISTED_RESULTS ); + break; + } + case GUI_PAGE_GNSS_ASSISTANCE_POSITION_CONFIG: + { + this->guiCurrent = new GuiConfigGnssAssistancePosition( &( this->gnss_assistance_position ), + &( this->gnss_assistance_position_default ) ); + break; + } + case GUI_PAGE_RADIO_TEST_MODES_CONFIG: + { + this->guiCurrent = new GuiConfigRadioTestModes( + &demo_settings.radio_settings, &demo_settings_default.radio_settings, this->version_handler ); + break; + } + case GUI_PAGE_RADIO_TX_CW: + { + this->guiCurrent = new GuiRadioTxCw( &demo_settings.radio_settings ); + break; + } + case GUI_PAGE_RADIO_PER: + { + this->guiCurrent = new GuiRadioPer( &demo_settings.radio_settings, &demo_results.radio_per_result ); + break; + } + case GUI_PAGE_RADIO_PING_PONG: + { + this->guiCurrent = + new GuiRadioPingPong( &demo_settings.radio_settings, &demo_results.radio_pingpong_result ); + break; + } + default: + { + break; + } + } + } +} diff --git a/embedded/gui/src/guiAbout.cpp b/embedded/gui/src/guiAbout.cpp index 69ef09f..937254e 100644 --- a/embedded/gui/src/guiAbout.cpp +++ b/embedded/gui/src/guiAbout.cpp @@ -33,7 +33,7 @@ #include "version.h" #include "semtech_logo.h" -#define GUI_ABOUT_BUFFER_LENGTH ( 30 ) +#define GUI_ABOUT_BUFFER_LENGTH ( 100 ) GuiAbout::GuiAbout( version_handler_t* version_handler ) : GuiCommon( GUI_PAGE_ABOUT ), version_handler( version_handler ) @@ -42,65 +42,60 @@ GuiAbout::GuiAbout( version_handler_t* version_handler ) this->createHeader( "ABOUT" ); - snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LR1110 EVK - %s", DEMO_VERSION ); - lv_obj_t* lbl_version_evk = lv_label_create( this->screen, NULL ); - lv_obj_set_style( lbl_version_evk, &( GuiCommon::screen_style ) ); - lv_label_set_long_mode( lbl_version_evk, LV_LABEL_LONG_BREAK ); - lv_label_set_align( lbl_version_evk, LV_LABEL_ALIGN_CENTER ); - lv_label_set_text( lbl_version_evk, buffer ); - lv_obj_set_width( lbl_version_evk, 240 ); - lv_obj_align( lbl_version_evk, NULL, LV_ALIGN_CENTER, 0, -100 ); - - snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LR1110 TYPE - 0x%02x", this->version_handler->version_chip_type ); - lv_obj_t* lbl_version_type = lv_label_create( this->screen, NULL ); - lv_obj_set_style( lbl_version_type, &( GuiCommon::screen_style ) ); - lv_label_set_long_mode( lbl_version_type, LV_LABEL_LONG_BREAK ); - lv_label_set_align( lbl_version_type, LV_LABEL_ALIGN_CENTER ); - lv_label_set_text( lbl_version_type, buffer ); - lv_obj_set_width( lbl_version_type, 240 ); - lv_obj_align( lbl_version_type, NULL, LV_ALIGN_CENTER, 0, -80 ); - - snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LR1110 HARDWARE - 0x%02x", this->version_handler->version_chip_hw ); - lv_obj_t* lbl_version_hw = lv_label_create( this->screen, NULL ); - lv_obj_set_style( lbl_version_hw, &( GuiCommon::screen_style ) ); - lv_label_set_long_mode( lbl_version_hw, LV_LABEL_LONG_BREAK ); - lv_label_set_align( lbl_version_hw, LV_LABEL_ALIGN_CENTER ); - lv_label_set_text( lbl_version_hw, buffer ); - lv_obj_set_width( lbl_version_hw, 240 ); - lv_obj_align( lbl_version_hw, NULL, LV_ALIGN_CENTER, 0, -60 ); - - snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LR1110 FIRMWARE - 0x%04x", this->version_handler->version_chip_fw ); - lv_obj_t* lbl_version_fw = lv_label_create( this->screen, NULL ); - lv_obj_set_style( lbl_version_fw, &( GuiCommon::screen_style ) ); - lv_label_set_long_mode( lbl_version_fw, LV_LABEL_LONG_BREAK ); - lv_label_set_align( lbl_version_fw, LV_LABEL_ALIGN_CENTER ); - lv_label_set_text( lbl_version_fw, buffer ); - lv_obj_set_width( lbl_version_fw, 240 ); - lv_obj_align( lbl_version_fw, NULL, LV_ALIGN_CENTER, 0, -40 ); - - lv_obj_t* lbl_copyrights_lvgl = lv_label_create( this->screen, NULL ); - lv_obj_set_style( lbl_copyrights_lvgl, &( GuiCommon::screen_style ) ); - lv_label_set_long_mode( lbl_copyrights_lvgl, LV_LABEL_LONG_BREAK ); - lv_label_set_align( lbl_copyrights_lvgl, LV_LABEL_ALIGN_CENTER ); - lv_label_set_text( lbl_copyrights_lvgl, "LVGL\nCopyright (c) 2016\nGabor Kiss-Vamosi" ); - lv_obj_set_width( lbl_copyrights_lvgl, 240 ); - lv_obj_align( lbl_copyrights_lvgl, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -110 ); - - lv_obj_t* lbl_copyrights_osm = lv_label_create( this->screen, NULL ); - lv_obj_set_style( lbl_copyrights_osm, &( GuiCommon::screen_style ) ); - lv_label_set_long_mode( lbl_copyrights_osm, LV_LABEL_LONG_BREAK ); - lv_label_set_align( lbl_copyrights_osm, LV_LABEL_ALIGN_CENTER ); - lv_label_set_text( lbl_copyrights_osm, "Data (c) OpenStreetMap\ncontributors, ODbL 1.0." ); - lv_obj_set_width( lbl_copyrights_osm, 240 ); - lv_obj_align( lbl_copyrights_osm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -60 ); + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "EVK DEMO APP - %s", DEMO_VERSION ); + this->createSection( buffer, -100 ); + + switch( this->version_handler->device_type ) + { + case VERSION_DEVICE_TRANSCEIVER: + { + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LR1110 TYPE - 0x%02x", + this->version_handler->transceiver.version_chip_type ); + this->createSection( buffer, -80 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LR1110 HARDWARE - 0x%02x", + this->version_handler->transceiver.version_chip_hw ); + this->createSection( buffer, -60 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LR1110 FIRMWARE - 0x%04x", + this->version_handler->transceiver.version_chip_fw ); + this->createSection( buffer, -40 ); + break; + } + + case VERSION_DEVICE_MODEM: + { + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "MODEM TYPE - 0x%02x", + this->version_handler->modem.version_chip_type ); + this->createSection( buffer, -80 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "MODEM BLOADER - 0x%08x", + this->version_handler->modem.version_chip_bootloader ); + this->createSection( buffer, -60 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "MODEM FIRMWARE - 0x%06x", + this->version_handler->modem.version_chip_fw ); + this->createSection( buffer, -40 ); + break; + } + + default: + break; + } + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "LVGL\nCopyright (c) 2016\nGabor Kiss-Vamosi" ); + this->createSection( buffer, 10 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "Data (c) OpenStreetMap\ncontributors, ODbL 1.0." ); + this->createSection( buffer, 80 ); this->createActionButton( &( this->btn_back ), "BACK", GuiAbout::callback, GUI_BUTTON_POS_CENTER, -5, true ); + + lv_scr_load( this->screen ); } GuiAbout::~GuiAbout( ) {} -void GuiAbout::draw( ) { lv_scr_load( this->screen ); } - void GuiAbout::callback( lv_obj_t* obj, lv_event_t event ) { GuiAbout* self = ( GuiAbout* ) lv_obj_get_user_data( obj ); diff --git a/embedded/gui/src/guiCommon.cpp b/embedded/gui/src/guiCommon.cpp index 36ccc1b..3c7cc75 100644 --- a/embedded/gui/src/guiCommon.cpp +++ b/embedded/gui/src/guiCommon.cpp @@ -44,20 +44,24 @@ #define GUI_COMMON_INFOFRAME_HEIGHT 150 #define GUI_COMMON_INFOFRAME_WIDTH 230 -bool GuiCommon::_is_host_connected = false; -bool GuiCommon::_is_gui_environment_init = false; -guiEvent_t GuiCommon::_event = GUI_EVENT_NONE; -lv_style_t GuiCommon::screen_style; -lv_style_t GuiCommon::note_style; -lv_style_t GuiCommon::title_style; -lv_style_t GuiCommon::info_frame_style_init; -lv_style_t GuiCommon::info_frame_style_ok; -lv_style_t GuiCommon::info_frame_style_ongoing; -lv_style_t GuiCommon::info_frame_style_error; -lv_style_t GuiCommon::sw_knob; -lv_style_t GuiCommon::sw_indic; -lv_style_t GuiCommon::table_cell1; -lv_style_t GuiCommon::tab; +bool GuiCommon::_is_host_connected = false; +bool GuiCommon::_is_gui_environment_init = false; +bool GuiCommon::_has_connectivity = false; +GuiNetworkConnectivityStatus_t GuiCommon::_network_connectivity_status = { .connectivity_state = + GUI_CONNECTIVITY_STATUS_NOT_CONNECTED, + .is_time_sync = false }; +guiEvent_t GuiCommon::_event = GUI_EVENT_NONE; +lv_style_t GuiCommon::screen_style; +lv_style_t GuiCommon::note_style; +lv_style_t GuiCommon::title_style; +lv_style_t GuiCommon::info_frame_style_init; +lv_style_t GuiCommon::info_frame_style_ok; +lv_style_t GuiCommon::info_frame_style_ongoing; +lv_style_t GuiCommon::info_frame_style_error; +lv_style_t GuiCommon::sw_knob; +lv_style_t GuiCommon::sw_indic; +lv_style_t GuiCommon::table_cell1; +lv_style_t GuiCommon::tab; GuiCommon::GuiCommon( guiPageType_t pageType ) : _pageType( pageType ) { @@ -190,7 +194,7 @@ void GuiCommon::createInfoFrame( lv_obj_t** info_frame, lv_obj_t** lbl_info_fram lv_obj_set_width( *info_frame, GUI_COMMON_INFOFRAME_WIDTH ); lv_cont_set_fit( *info_frame, LV_FIT_NONE ); lv_cont_set_layout( *info_frame, LV_LAYOUT_CENTER ); - lv_cont_set_style( *info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_ongoing ) ); + lv_cont_set_style( *info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_init ) ); *lbl_info_frame_1 = lv_label_create( *info_frame, NULL ); lv_label_set_align( *lbl_info_frame_1, LV_LABEL_ALIGN_CENTER ); @@ -268,17 +272,55 @@ void GuiCommon::createChoiceSwitch( lv_obj_t** sw, lv_obj_t* screen, const char* } } -void GuiCommon::updateHostConnectivityState( const bool is_connected ) +void GuiCommon::createNetworkConnectivityIcon( lv_obj_t** icon ) { - GuiCommon::_is_host_connected = is_connected; - this->updateHostConnectivityState( ); + *icon = lv_label_create( this->screen, NULL ); + lv_label_set_text( *icon, LV_SYMBOL_WIFI ); + lv_obj_align( *icon, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10 ); + lv_obj_set_hidden( *icon, ( GuiCommon::_has_connectivity == true ) ? false : true ); + + this->updateNetworkConnectivityIcon( *icon ); +} + +void GuiCommon::updateNetworkConnectivityIcon( lv_obj_t* icon ) +{ + switch( GuiCommon::_network_connectivity_status.connectivity_state ) + { + case GUI_CONNECTIVITY_STATUS_NOT_CONNECTED: + { + lv_obj_set_style( icon, &( GuiCommon::info_frame_style_error ) ); + break; + } + case GUI_CONNECTIVITY_STATUS_JOINING: + { + lv_obj_set_style( icon, &( GuiCommon::info_frame_style_ongoing ) ); + break; + } + case GUI_CONNECTIVITY_STATUS_CONNECTED: + { + lv_obj_set_style( icon, &( GuiCommon::info_frame_style_ok ) ); + break; + } + default: + { + break; + } + } } -guiEvent_t GuiCommon::touchEvent( uint16_t x, uint16_t y ) +void GuiCommon::updateNetworkConnectivityState( const GuiNetworkConnectivityStatus_t* new_connectivity_status ) { - guiEvent_t event = GUI_EVENT_NONE; + GuiCommon::_network_connectivity_status.connectivity_state = new_connectivity_status->connectivity_state; + GuiCommon::_network_connectivity_status.is_time_sync = new_connectivity_status->is_time_sync; - return event; + this->updateNetworkConnectivityIcon( this->_label_connectivity_icon ); + this->updateNetworkConnectivityState( ); +} + +void GuiCommon::updateHostConnectivityState( const bool is_connected ) +{ + GuiCommon::_is_host_connected = is_connected; + this->updateHostConnectivityState( ); } float GuiCommon::convertConsoToUah( const uint32_t conso_uas ) { return conso_uas / GUI_COMMON_DIVIDER_CONSO; } diff --git a/embedded/gui/src/guiConfigGnss.cpp b/embedded/gui/src/guiConfigGnss.cpp index d474969..d8ed1b1 100644 --- a/embedded/gui/src/guiConfigGnss.cpp +++ b/embedded/gui/src/guiConfigGnss.cpp @@ -32,10 +32,14 @@ #include "guiConfigGnss.h" GuiConfigGnss::GuiConfigGnss( guiPageType_t pageType, GuiGnssDemoSetting_t* settings_current, - const GuiGnssDemoSetting_t* settings_default ) + const GuiGnssDemoSetting_t* settings_default, version_handler_t* version_handler ) : GuiCommon( pageType ), settings_current( settings_current ), settings_default( settings_default ) { - this->createHeader( "GNSS - CONFIGURATION" ); + this->settings_temp = *( this->settings_current ); + + this->createHeader( "GNSS CONFIGURATION" ); + + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); this->createSection( "CONSTELLATIONS", -100 ); @@ -47,10 +51,16 @@ GuiConfigGnss::GuiConfigGnss( guiPageType_t pageType, GuiGnssDemoSetting_t* sett lv_obj_set_event_cb( this->btnm_constellations, GuiConfigGnss::callbackSettings ); lv_obj_set_user_data( this->btnm_constellations, this ); - this->createSection( "SCAN PARAMETERS", -10 ); + if( ( _pageType == GUI_PAGE_GNSS_ASSISTED_CONFIG ) || + ( ( _pageType == GUI_PAGE_GNSS_AUTONOMOUS_CONFIG ) && + ( ( version_handler->device_type == VERSION_DEVICE_TRANSCEIVER ) ) ) ) + { + this->createSection( "SCAN PARAMETERS", -10 ); + } this->createChoiceSwitch( &( this->sw_scan_mode ), this->screen, "Single", "Double", - GuiConfigGnss::callbackSettings, 30, true ); + GuiConfigGnss::callbackSettings, 30, + ( version_handler->device_type == VERSION_DEVICE_MODEM ) ? false : true ); this->createChoiceSwitch( &( this->sw_scan_option ), this->screen, "Low power", "Best effort", GuiConfigGnss::callbackSettings, 70, @@ -59,25 +69,21 @@ GuiConfigGnss::GuiConfigGnss( guiPageType_t pageType, GuiGnssDemoSetting_t* sett this->createActionButton( &( this->btn_cancel ), "CANCEL", GuiConfigGnss::callback, GUI_BUTTON_POS_LEFT, -5, true ); this->createActionButton( &( this->btn_default ), "DEFAULT", GuiConfigGnss::callback, GUI_BUTTON_POS_CENTER, -5, - true ); - - this->createActionButton( &( this->btn_save ), "SAVE", GuiConfigGnss::callback, GUI_BUTTON_POS_RIGHT, -5, false ); -} + ( this->IsConfigTempEqualTo( this->settings_default ) == true ) ? false : true ); -GuiConfigGnss::~GuiConfigGnss( ) {} - -void GuiConfigGnss::init( ) {} + this->createActionButton( &( this->btn_save ), "SAVE", GuiConfigGnss::callback, GUI_BUTTON_POS_RIGHT, -5, + ( this->IsConfigTempEqualTo( this->settings_current ) == true ) || + ( this->IsAtLeastOneConstellationSelected( ) == false ) + ? false + : true ); -void GuiConfigGnss::draw( ) -{ - this->settings_temp = *( this->settings_current ); - - this->ConfigActionButton( ); this->ConfigSettingsButton( ); lv_scr_load( this->screen ); } +GuiConfigGnss::~GuiConfigGnss( ) {} + void GuiConfigGnss::ConfigSettingsButton( ) { if( this->settings_temp.is_beidou_enabled == true ) diff --git a/embedded/gui/src/guiConfigGnssAssistancePosition.cpp b/embedded/gui/src/guiConfigGnssAssistancePosition.cpp new file mode 100644 index 0000000..011a949 --- /dev/null +++ b/embedded/gui/src/guiConfigGnssAssistancePosition.cpp @@ -0,0 +1,223 @@ +/** + * @file guiConfigGnssAssistancePosition.cpp + * + * @brief Implementation of the gui config assistance position GNSS page. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "guiConfigGnssAssistancePosition.h" +#include + +GuiConfigGnssAssistancePosition::GuiConfigGnssAssistancePosition( + GuiGnssDemoAssistancePosition_t* settings, const GuiGnssDemoAssistancePosition_t* settings_default ) + : GuiCommon( GUI_PAGE_GNSS_ASSISTANCE_POSITION_CONFIG ), + settings_current( settings ), + settings_default( settings_default ) +{ + this->settings_temp = *( this->settings_current ); + + this->createHeader( "GNSS ASSISTANCE" ); + + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + char str[12]; + snprintf( str, 10, "%f", this->settings_temp.latitude ); + this->create_ta( &( this->ta_latitude ), this->screen, 45, "Latitude", 9, str, + GuiConfigGnssAssistancePosition::callback_ta ); + snprintf( str, 10, "%f", this->settings_temp.longitude ); + this->create_ta( &( this->ta_longitude ), this->screen, 80, "Longitude", 9, str, + GuiConfigGnssAssistancePosition::callback_ta ); + + this->createActionButton( &( this->btn_cancel ), "CANCEL", GuiConfigGnssAssistancePosition::callback, + GUI_BUTTON_POS_LEFT, -5, true ); + + this->createActionButton( &( this->btn_default ), "DEFAULT", GuiConfigGnssAssistancePosition::callback, + GUI_BUTTON_POS_CENTER, -5, + ( this->IsConfigTempEqualTo( this->settings_default ) == true ) ? false : true ); + + this->createActionButton( &( this->btn_save ), "SAVE", GuiConfigGnssAssistancePosition::callback, + GUI_BUTTON_POS_RIGHT, -5, + ( this->IsConfigTempEqualTo( this->settings_current ) == true ) ? false : true ); + + /*Create a keyboard and apply the styles*/ + this->kb_num = lv_kb_create( this->screen, NULL ); + lv_kb_set_mode( this->kb_num, LV_KB_MODE_NUM ); + lv_kb_set_cursor_manage( this->kb_num, true ); + lv_kb_set_style( this->kb_num, LV_KB_STYLE_BG, &lv_style_transp_tight ); + lv_obj_set_event_cb( this->kb_num, GuiConfigGnssAssistancePosition::callback_kb ); + lv_obj_set_user_data( this->kb_num, this ); + lv_obj_move_foreground( this->kb_num ); + lv_obj_set_hidden( this->kb_num, true ); + + lv_scr_load( this->screen ); +} + +GuiConfigGnssAssistancePosition::~GuiConfigGnssAssistancePosition( ) {} + +void GuiConfigGnssAssistancePosition::ConfigActionButton( ) +{ + lv_btn_set_state( this->btn_default, ( ( this->IsConfigTempEqualTo( this->settings_default ) == true ) ) + ? LV_BTN_STATE_INA + : LV_BTN_STATE_REL ); + + lv_btn_set_state( this->btn_save, ( ( this->IsConfigTempEqualTo( this->settings_current ) == true ) ) + ? LV_BTN_STATE_INA + : LV_BTN_STATE_REL ); +} + +void GuiConfigGnssAssistancePosition::ConfigParam( ) +{ + char str[10]; + + snprintf( str, 5, "%f", this->settings_temp.latitude ); + lv_ta_set_text( this->ta_latitude, str ); + + snprintf( str, 5, "%f", this->settings_temp.longitude ); + lv_ta_set_text( this->ta_longitude, str ); +} + +bool GuiConfigGnssAssistancePosition::IsConfigTempEqualTo( const GuiGnssDemoAssistancePosition_t* settings_to_compare ) +{ + if( this->settings_temp.latitude != settings_to_compare->latitude ) + { + return false; + } + + if( this->settings_temp.longitude != settings_to_compare->longitude ) + { + return false; + } + + return true; +} + +void GuiConfigGnssAssistancePosition::create_ta( lv_obj_t** ta, lv_obj_t* screen, int16_t off_y, const char* lbl_name, + uint16_t max_length, const char* init_text, lv_event_cb_t event_cb ) +{ + lv_obj_t* lbl; + + lbl = lv_label_create( screen, NULL ); + lv_obj_set_style( lbl, &( GuiCommon::screen_style ) ); + lv_label_set_text( lbl, lbl_name ); + lv_obj_align( lbl, NULL, LV_ALIGN_IN_TOP_LEFT, 5, off_y ); + + *ta = lv_ta_create( screen, NULL ); + lv_obj_set_click( *ta, true ); + lv_obj_set_event_cb( *ta, event_cb ); + lv_obj_set_width( *ta, 100 ); + lv_obj_align( *ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, off_y ); + lv_ta_set_accepted_chars( *ta, "0123456789.-" ); + lv_ta_set_cursor_type( *ta, LV_CURSOR_LINE | LV_CURSOR_HIDDEN ); + lv_ta_set_one_line( *ta, true ); + lv_ta_set_max_length( *ta, max_length ); + lv_ta_set_text( *ta, init_text ); + lv_ta_set_text_align( *ta, LV_LABEL_ALIGN_RIGHT ); + lv_obj_set_user_data( *ta, this ); +} + +void GuiConfigGnssAssistancePosition::callback( lv_obj_t* obj, lv_event_t event ) +{ + GuiConfigGnssAssistancePosition* self = ( GuiConfigGnssAssistancePosition* ) lv_obj_get_user_data( obj ); + + if( ( event == LV_EVENT_RELEASED ) && ( lv_btn_get_state( obj ) != LV_BTN_STATE_INA ) ) + { + if( obj == self->btn_cancel ) + { + GuiCommon::_event = GUI_EVENT_BACK; + } + else if( obj == self->btn_default ) + { + self->settings_temp = *( self->settings_default ); + self->ConfigActionButton( ); + self->ConfigParam( ); + } + else if( obj == self->btn_save ) + { + *self->settings_current = self->settings_temp; + GuiCommon::_event = GUI_EVENT_SAVE; + } + } +} + +void GuiConfigGnssAssistancePosition::callback_ta( lv_obj_t* obj, lv_event_t event ) +{ + GuiConfigGnssAssistancePosition* self = ( GuiConfigGnssAssistancePosition* ) lv_obj_get_user_data( obj ); + + if( event == LV_EVENT_PRESSED ) + { + if( lv_kb_get_ta( self->kb_num ) == NULL ) + { + /*Assign the text area to the keyboard*/ + lv_kb_set_ta( self->kb_num, obj ); + lv_obj_set_hidden( self->kb_num, false ); + + const char* txt = lv_ta_get_text( obj ); + strcpy( self->ta_text, txt ); + } + } +} + +void GuiConfigGnssAssistancePosition::callback_kb( lv_obj_t* obj, lv_event_t event ) +{ + lv_obj_t* ta = lv_kb_get_ta( obj ); + + GuiConfigGnssAssistancePosition* self = ( GuiConfigGnssAssistancePosition* ) lv_obj_get_user_data( obj ); + + lv_kb_def_event_cb( obj, event ); + + if( event == LV_EVENT_CANCEL ) + { + lv_kb_set_ta( obj, NULL ); /*De-assign the text area*/ + lv_obj_set_hidden( obj, true ); + } + else if( event == LV_EVENT_APPLY ) + { + char str[10]; + const char* txt = lv_ta_get_text( ta ); + int len = strlen( txt ); + + if( len == 0 ) + { + lv_ta_set_text( ta, self->ta_text ); + } + + if( ta == self->ta_longitude ) + { + self->settings_temp.longitude = atof( txt ); + } + + else if( ta == self->ta_latitude ) + { + self->settings_temp.latitude = atof( txt ); + } + + self->ConfigActionButton( ); + + lv_kb_set_ta( obj, NULL ); /*De-assign the text area*/ + lv_obj_set_hidden( obj, true ); + } +} diff --git a/embedded/gui/src/guiConfigRadioTestModes.cpp b/embedded/gui/src/guiConfigRadioTestModes.cpp index 761ea5d..e825bce 100644 --- a/embedded/gui/src/guiConfigRadioTestModes.cpp +++ b/embedded/gui/src/guiConfigRadioTestModes.cpp @@ -38,12 +38,18 @@ #define TMP_BUFFER_CALLBACK_LENGTH ( 10 ) GuiConfigRadioTestModes::GuiConfigRadioTestModes( GuiRadioSetting_t* settings_current, - const GuiRadioSetting_t* settings_default ) + const GuiRadioSetting_t* settings_default, + version_handler_t* version_handler ) : GuiCommon( GUI_PAGE_RADIO_TEST_MODES_CONFIG ), settings_current( settings_current ), - settings_default( settings_default ) + settings_default( settings_default ), + device_type( version_handler->device_type ) { - this->createHeader( "RADIO - CONFIGURATION" ); + this->settings_temp = *( this->settings_current ); + + this->createHeader( "RADIO CONFIGURATION" ); + + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); /* Create a Tab view object and configure it */ this->tabview = lv_tabview_create( this->screen, NULL ); @@ -54,7 +60,11 @@ GuiConfigRadioTestModes::GuiConfigRadioTestModes( GuiRadioSetting_t* setti this->tab_generic = lv_tabview_add_tab( this->tabview, "Generic" ); this->tab_lora = lv_tabview_add_tab( this->tabview, "LoRa" ); - this->tab_gfsk = lv_tabview_add_tab( this->tabview, "GFSK" ); + + if( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + this->tab_gfsk = lv_tabview_add_tab( this->tabview, "GFSK" ); + } this->create_ta( &( this->ta_freq ), this->tab_generic, 10, "Frequency (Hz)", 9, "868000000", GuiConfigRadioTestModes::callback_ta ); @@ -62,8 +72,11 @@ GuiConfigRadioTestModes::GuiConfigRadioTestModes( GuiRadioSetting_t* setti this->create_ta( &( this->ta_pl_len ), this->tab_generic, 45, "Payload length", 3, "5", GuiConfigRadioTestModes::callback_ta ); - this->create_ta( &( this->ta_pkt ), this->tab_generic, 80, "Nb of packets", 5, "100", - GuiConfigRadioTestModes::callback_ta ); + if( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + this->create_ta( &( this->ta_pkt ), this->tab_generic, 80, "Nb of packets", 5, "100", + GuiConfigRadioTestModes::callback_ta ); + } this->create_ddlist( &( this->ddlist_pwr ), this->tab_generic, 115, "Power (dBm)", lp_pa_options, GuiConfigRadioTestModes::callback_ddlist ); @@ -72,18 +85,34 @@ GuiConfigRadioTestModes::GuiConfigRadioTestModes( GuiRadioSetting_t* setti GuiConfigRadioTestModes::callback_sw, 30, true ); this->createChoiceSwitch( &( this->sw_pa ), this->tab_generic, "LP PA", "HP PA", - GuiConfigRadioTestModes::callback_sw, 65, true ); - - this->create_ddlist( &( this->lora_ddlist_sf ), this->tab_lora, 20, "Spreading Factor", - "SF5\n" - "SF6\n" - "SF7\n" - "SF8\n" - "SF9\n" - "SF10\n" - "SF11\n" - "SF12", - GuiConfigRadioTestModes::callback_ddlist ); + GuiConfigRadioTestModes::callback_sw, 65, + ( this->device_type == VERSION_DEVICE_TRANSCEIVER ) ? true : false ); + + switch( device_type ) + { + case VERSION_DEVICE_TRANSCEIVER: + this->create_ddlist( &( this->lora_ddlist_sf ), this->tab_lora, 20, "Spreading Factor", + "SF5\n" + "SF6\n" + "SF7\n" + "SF8\n" + "SF9\n" + "SF10\n" + "SF11\n" + "SF12", + GuiConfigRadioTestModes::callback_ddlist ); + break; + case VERSION_DEVICE_MODEM: + this->create_ddlist( &( this->lora_ddlist_sf ), this->tab_lora, 20, "Spreading Factor", + "SF7\n" + "SF8\n" + "SF9\n" + "SF10\n" + "SF11\n" + "SF12", + GuiConfigRadioTestModes::callback_ddlist ); + break; + } this->create_ddlist( &( this->lora_ddlist_bw ), this->tab_lora, 50, "Bandwidth", "125kHz\n" @@ -98,44 +127,50 @@ GuiConfigRadioTestModes::GuiConfigRadioTestModes( GuiRadioSetting_t* setti "4/8", GuiConfigRadioTestModes::callback_ddlist ); - this->create_ddlist( &( this->lora_ddlist_iq ), this->tab_lora, 110, "IQ", - "Standard\n" - "Inverted", - GuiConfigRadioTestModes::callback_ddlist ); - - this->create_ddlist( &( this->lora_ddlist_crc ), this->tab_lora, 140, "CRC", - "OFF\n" - "ON", - GuiConfigRadioTestModes::callback_ddlist ); - - this->create_ddlist( &( this->lora_ddlist_hdr ), this->tab_lora, 170, "Header type", - "Implicit\n" - "Explicit", - GuiConfigRadioTestModes::callback_ddlist ); - - this->create_ta( &( this->gfsk_ta_br ), this->tab_gfsk, 10, "Bitrate (bps)", 6, "150000", - GuiConfigRadioTestModes::callback_ta ); - - this->create_ta( &( this->gfsk_ta_fdev ), this->tab_gfsk, 45, "Freq. dev. (Hz)", 6, "50000", - GuiConfigRadioTestModes::callback_ta ); - - this->create_ddlist( &( this->gfsk_ddlist_crc ), this->tab_gfsk, 80, "CRC", - "OFF\n" - "1B\n" - "2B\n" - "1B inv.\n" - "2B inv.", - GuiConfigRadioTestModes::callback_ddlist ); - - this->create_ddlist( &( this->gfsk_ddlist_hdr ), this->tab_gfsk, 110, "Header type", - "Implicit\n" - "Explicit", - GuiConfigRadioTestModes::callback_ddlist ); + if( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + this->create_ddlist( &( this->lora_ddlist_iq ), this->tab_lora, 110, "IQ", + "Standard\n" + "Inverted", + GuiConfigRadioTestModes::callback_ddlist ); + + this->create_ddlist( &( this->lora_ddlist_crc ), this->tab_lora, 140, "CRC", + "OFF\n" + "ON", + GuiConfigRadioTestModes::callback_ddlist ); + + this->create_ddlist( &( this->lora_ddlist_hdr ), this->tab_lora, 170, "Header type", + "Implicit\n" + "Explicit", + GuiConfigRadioTestModes::callback_ddlist ); + } - this->create_ddlist( &( this->gfsk_ddlist_dcfree ), this->tab_gfsk, 140, "DC free", - "OFF\n" - "ON", - GuiConfigRadioTestModes::callback_ddlist ); + if( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + this->create_ta( &( this->gfsk_ta_br ), this->tab_gfsk, 10, "Bitrate (bps)", 6, "150000", + GuiConfigRadioTestModes::callback_ta ); + + this->create_ta( &( this->gfsk_ta_fdev ), this->tab_gfsk, 45, "Freq. dev. (Hz)", 6, "50000", + GuiConfigRadioTestModes::callback_ta ); + + this->create_ddlist( &( this->gfsk_ddlist_crc ), this->tab_gfsk, 80, "CRC", + "OFF\n" + "1B\n" + "2B\n" + "1B inv.\n" + "2B inv.", + GuiConfigRadioTestModes::callback_ddlist ); + + this->create_ddlist( &( this->gfsk_ddlist_hdr ), this->tab_gfsk, 110, "Header type", + "Implicit\n" + "Explicit", + GuiConfigRadioTestModes::callback_ddlist ); + + this->create_ddlist( &( this->gfsk_ddlist_dcfree ), this->tab_gfsk, 140, "DC free", + "OFF\n" + "ON", + GuiConfigRadioTestModes::callback_ddlist ); + } this->createActionButton( &( this->btn_cancel ), "CANCEL", GuiConfigRadioTestModes::callback, GUI_BUTTON_POS_LEFT, -5, true ); @@ -155,25 +190,22 @@ GuiConfigRadioTestModes::GuiConfigRadioTestModes( GuiRadioSetting_t* setti lv_obj_set_user_data( this->kb_num, this ); lv_obj_move_foreground( this->kb_num ); lv_obj_set_hidden( this->kb_num, true ); -} - -GuiConfigRadioTestModes::~GuiConfigRadioTestModes( ) {} - -void GuiConfigRadioTestModes::init( ) {} - -void GuiConfigRadioTestModes::draw( ) -{ - this->settings_temp = *( this->settings_current ); this->ConfigActionButton( ); this->ConfigParamGeneric( ); this->ConfigParamLora( ); - this->ConfigParamGfsk( ); + + if( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + this->ConfigParamGfsk( ); + } lv_scr_load( this->screen ); } +GuiConfigRadioTestModes::~GuiConfigRadioTestModes( ) {} + void GuiConfigRadioTestModes::ConfigParamGeneric( ) { char str[TMP_BUFFER_CONFIG_PARAM_GENERIC_LENGTH]; @@ -181,8 +213,11 @@ void GuiConfigRadioTestModes::ConfigParamGeneric( ) snprintf( str, TMP_BUFFER_CONFIG_PARAM_GENERIC_LENGTH, "%d", this->settings_temp.rf_freq_in_hz ); lv_ta_set_text( this->ta_freq, str ); - snprintf( str, TMP_BUFFER_CONFIG_PARAM_GENERIC_LENGTH, "%d", this->settings_temp.nb_of_packets ); - lv_ta_set_text( this->ta_pkt, str ); + if( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + snprintf( str, TMP_BUFFER_CONFIG_PARAM_GENERIC_LENGTH, "%d", this->settings_temp.nb_of_packets ); + lv_ta_set_text( this->ta_pkt, str ); + } snprintf( str, TMP_BUFFER_CONFIG_PARAM_GENERIC_LENGTH, "%d", this->settings_temp.payload_length ); lv_ta_set_text( this->ta_pl_len, str ); @@ -241,17 +276,22 @@ void GuiConfigRadioTestModes::ConfigParamGeneric( ) void GuiConfigRadioTestModes::ConfigParamLora( ) { - lv_ddlist_set_selected( this->lora_ddlist_sf, this->settings_temp.lora.sf ); + lv_ddlist_set_selected( this->lora_ddlist_sf, ( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + ? this->settings_temp.lora.sf + : this->settings_temp.lora.sf - 2 ); lv_ddlist_set_selected( this->lora_ddlist_bw, this->settings_temp.lora.bw ); lv_ddlist_set_selected( this->lora_ddlist_cr, this->settings_temp.lora.cr ); - lv_ddlist_set_selected( this->lora_ddlist_iq, ( this->settings_temp.lora.is_iq_inverted == false ) ? 0 : 1 ); + if( this->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + lv_ddlist_set_selected( this->lora_ddlist_iq, ( this->settings_temp.lora.is_iq_inverted == false ) ? 0 : 1 ); - lv_ddlist_set_selected( this->lora_ddlist_crc, ( this->settings_temp.lora.is_crc_activated == false ) ? 0 : 1 ); + lv_ddlist_set_selected( this->lora_ddlist_crc, ( this->settings_temp.lora.is_crc_activated == false ) ? 0 : 1 ); - lv_ddlist_set_selected( this->lora_ddlist_hdr, ( this->settings_temp.lora.is_hdr_implicit == false ) ? 0 : 1 ); + lv_ddlist_set_selected( this->lora_ddlist_hdr, ( this->settings_temp.lora.is_hdr_implicit == false ) ? 0 : 1 ); + } } void GuiConfigRadioTestModes::ConfigParamGfsk( ) @@ -371,7 +411,10 @@ void GuiConfigRadioTestModes::callback( lv_obj_t* obj, lv_event_t event ) self->settings_temp = *( self->settings_default ); self->ConfigParamGeneric( ); self->ConfigParamLora( ); - self->ConfigParamGfsk( ); + if( self->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + self->ConfigParamGfsk( ); + } self->ConfigActionButton( ); } else if( obj == self->btn_save ) @@ -563,7 +606,8 @@ void GuiConfigRadioTestModes::callback_ddlist( lv_obj_t* obj, lv_event_t event ) else if( obj == self->lora_ddlist_sf ) { - self->settings_temp.lora.sf = id; + // The "+ 2" trick is done because modem and transceiver does not behave the same + self->settings_temp.lora.sf = ( self->device_type == VERSION_DEVICE_TRANSCEIVER ) ? id : id + 2; } else if( obj == self->lora_ddlist_bw ) diff --git a/embedded/gui/src/guiConfigWifi.cpp b/embedded/gui/src/guiConfigWifi.cpp index 2278e2c..8613e81 100644 --- a/embedded/gui/src/guiConfigWifi.cpp +++ b/embedded/gui/src/guiConfigWifi.cpp @@ -34,7 +34,11 @@ GuiConfigWifi::GuiConfigWifi( GuiWifiDemoSetting_t* settings_current, const GuiWifiDemoSetting_t* settings_default ) : GuiCommon( GUI_PAGE_WIFI_CONFIG ), settings_current( settings_current ), settings_default( settings_default ) { - this->createHeader( "Wi-Fi - CONFIGURATION" ); + this->settings_temp = *( this->settings_current ); + + this->createHeader( "Wi-Fi CONFIGURATION" ); + + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); this->createSection( "TYPES", -100 ); this->btnm_types = lv_btnm_create( this->screen, NULL ); @@ -59,25 +63,18 @@ GuiConfigWifi::GuiConfigWifi( GuiWifiDemoSetting_t* settings_current, const GuiW this->createActionButton( &( this->btn_cancel ), "CANCEL", GuiConfigWifi::callback, GUI_BUTTON_POS_LEFT, -5, true ); this->createActionButton( &( this->btn_default ), "DEFAULT", GuiConfigWifi::callback, GUI_BUTTON_POS_CENTER, -5, - true ); - - this->createActionButton( &( this->btn_save ), "SAVE", GuiConfigWifi::callback, GUI_BUTTON_POS_RIGHT, -5, false ); -} - -GuiConfigWifi::~GuiConfigWifi( ) {} - -void GuiConfigWifi::init( ) {} + ( this->IsConfigTempEqualTo( this->settings_default ) == true ) ? false : true ); -void GuiConfigWifi::draw( ) -{ - this->settings_temp = *( this->settings_current ); + this->createActionButton( &( this->btn_save ), "SAVE", GuiConfigWifi::callback, GUI_BUTTON_POS_RIGHT, -5, + ( this->IsConfigTempEqualTo( this->settings_current ) == true ) ? false : true ); - this->ConfigActionButton( ); this->ConfigSettingsButton( ); lv_scr_load( this->screen ); } +GuiConfigWifi::~GuiConfigWifi( ) {} + void GuiConfigWifi::ConfigSettingsButton( ) { if( this->settings_temp.is_type_b == true ) diff --git a/embedded/gui/src/guiConnectivity.cpp b/embedded/gui/src/guiConnectivity.cpp new file mode 100644 index 0000000..4e325c0 --- /dev/null +++ b/embedded/gui/src/guiConnectivity.cpp @@ -0,0 +1,255 @@ +/** + * @file guiConnectivity.cpp + * + * @brief Implementation of the GUI connectivity page + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "guiConnectivity.h" + +GuiConnectivity::GuiConnectivity( GuiNetworkConnectivitySettings_t* network_connectivity_settings ) + : GuiCommon( GUI_PAGE_CONNECTIVITY ), _network_connectivity_settings( network_connectivity_settings ) +{ + this->createHeader( "CONNECTIVITY" ); + + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + this->lbl_connectivity_state = lv_label_create( this->screen, NULL ); + lv_label_set_long_mode( this->lbl_connectivity_state, LV_LABEL_LONG_BREAK ); + lv_label_set_recolor( this->lbl_connectivity_state, true ); + lv_label_set_align( this->lbl_connectivity_state, LV_LABEL_ALIGN_CENTER ); + lv_label_set_text( this->lbl_connectivity_state, "State: Not connected" ); + lv_obj_set_width( this->lbl_connectivity_state, 150 ); + lv_obj_align( this->lbl_connectivity_state, NULL, LV_ALIGN_CENTER, 0, -100 ); + + this->btn_join = lv_btn_create( this->screen, NULL ); + lv_btn_set_state( this->btn_join, LV_BTN_STATE_REL ); + lv_obj_set_height( this->btn_join, 40 ); + lv_obj_set_width( this->btn_join, 150 ); + lv_obj_set_event_cb( this->btn_join, GuiConnectivity::callback ); + lv_obj_set_user_data( this->btn_join, this ); + lv_obj_align( this->btn_join, NULL, LV_ALIGN_CENTER, 0, -60 ); + this->lbl_btn_join = lv_label_create( this->btn_join, NULL ); + lv_label_set_text( this->lbl_btn_join, "JOIN" ); + + this->create_ddlist( &( this->ddlist_lorawan_region ), 140, "LoRaWAN region", "EU868\nUS915", + GuiConnectivity::callback_ddlist, 80 ); + + this->create_ddlist( &( this->ddlist_adr_profile ), 180, "ADR profile", "NS controlled\nMobile LR\nMobile LP", + GuiConnectivity::callback_ddlist, 130 ); + + if( this->_network_connectivity_settings->region == GUI_NETWORK_CONNECTIVITY_REGION_EU868 ) + { + lv_ddlist_set_selected( this->ddlist_lorawan_region, 0 ); + } + else if( this->_network_connectivity_settings->region == GUI_NETWORK_CONNECTIVITY_REGION_US915 ) + { + lv_ddlist_set_selected( this->ddlist_lorawan_region, 1 ); + } + + if( this->_network_connectivity_settings->adr_profile == GUI_NETWORK_CONNECTIVITY_ADR_NETWORK_SERVER_CONTROLLED ) + { + lv_ddlist_set_selected( this->ddlist_adr_profile, 0 ); + } + else if( this->_network_connectivity_settings->adr_profile == GUI_NETWORK_CONNECTIVITY_ADR_MOBILE_LONG_RANGE ) + { + lv_ddlist_set_selected( this->ddlist_adr_profile, 1 ); + } + else if( this->_network_connectivity_settings->adr_profile == GUI_NETWORK_CONNECTIVITY_ADR_MOBILE_LOW_POWER ) + { + lv_ddlist_set_selected( this->ddlist_adr_profile, 2 ); + } + + this->btn_restore = lv_btn_create( this->screen, NULL ); + lv_btn_set_state( this->btn_restore, LV_BTN_STATE_REL ); + lv_obj_set_height( this->btn_restore, 40 ); + lv_obj_set_width( this->btn_restore, 150 ); + lv_obj_set_event_cb( this->btn_restore, GuiConnectivity::callback ); + lv_obj_set_user_data( this->btn_restore, this ); + lv_obj_align( this->btn_restore, NULL, LV_ALIGN_CENTER, 0, 80 ); + this->lbl_btn_restore = lv_label_create( this->btn_restore, NULL ); + lv_label_set_text( this->lbl_btn_restore, "RESET EUI & KEYS" ); + + this->createActionButton( &( this->btn_back ), "BACK", GuiConnectivity::callback, GUI_BUTTON_POS_CENTER, -5, true ); + + this->updateNetworkConnectivityState( ); + + lv_scr_load( this->screen ); +} + +GuiConnectivity::~GuiConnectivity( ) {} + +void GuiConnectivity::updateNetworkConnectivityState( ) +{ + switch( GuiCommon::_network_connectivity_status.connectivity_state ) + { + case GUI_CONNECTIVITY_STATUS_NOT_CONNECTED: + { + lv_label_set_text( this->lbl_btn_join, "JOIN" ); + lv_label_set_text( this->lbl_connectivity_state, "State: Not connected" ); + lv_obj_set_click( this->ddlist_lorawan_region, true ); + break; + } + case GUI_CONNECTIVITY_STATUS_JOINING: + { + lv_label_set_text( this->lbl_btn_join, "ABORT" ); + lv_label_set_text( this->lbl_connectivity_state, "State: Joining..." ); + lv_obj_set_click( this->ddlist_lorawan_region, false ); + break; + } + case GUI_CONNECTIVITY_STATUS_CONNECTED: + { + lv_label_set_text( this->lbl_btn_join, "LEAVE" ); + lv_label_set_text( this->lbl_connectivity_state, "State: Connected" ); + lv_obj_set_click( this->ddlist_lorawan_region, false ); + break; + } + default: + break; + } +} + +void GuiConnectivity::callback( lv_obj_t* obj, lv_event_t event ) +{ + GuiConnectivity* self = ( GuiConnectivity* ) lv_obj_get_user_data( obj ); + + if( event == LV_EVENT_RELEASED ) + { + if( obj == self->btn_join ) + { + char text[10]; + strcpy( text, lv_label_get_text( self->lbl_btn_join ) ); + + if( memcmp( text, "JOIN", 4 ) == 0 ) + { + GuiCommon::_network_connectivity_status.connectivity_state = GUI_CONNECTIVITY_STATUS_JOINING; + GuiCommon::_event = GUI_EVENT_JOIN; + } + else if( memcmp( text, "ABORT", 4 ) == 0 ) + { + GuiCommon::_network_connectivity_status.connectivity_state = GUI_CONNECTIVITY_STATUS_NOT_CONNECTED; + GuiCommon::_event = GUI_EVENT_ABORT; + } + else if( memcmp( text, "LEAVE", 4 ) == 0 ) + { + GuiCommon::_network_connectivity_status.connectivity_state = GUI_CONNECTIVITY_STATUS_NOT_CONNECTED; + GuiCommon::_event = GUI_EVENT_LEAVE; + } + + self->updateNetworkConnectivityIcon( self->_label_connectivity_icon ); + self->updateNetworkConnectivityState( ); + } + else if( obj == self->btn_restore ) + { + GuiCommon::_event = GUI_EVENT_RESTORE_EUI_KEYS; + lv_btn_set_state( self->btn_restore, LV_BTN_STATE_INA ); + } + else if( obj == self->btn_back ) + { + GuiCommon::_event = GUI_EVENT_BACK; + } + } +} + +void GuiConnectivity::callback_ddlist( lv_obj_t* obj, lv_event_t event ) +{ + uint8_t id; + GuiConnectivity* self = ( GuiConnectivity* ) lv_obj_get_user_data( obj ); + + if( event == LV_EVENT_VALUE_CHANGED ) + { + id = lv_ddlist_get_selected( obj ); + + if( obj == self->ddlist_lorawan_region ) + { + switch( id ) + { + case 0: + { + self->_network_connectivity_settings->region = GUI_NETWORK_CONNECTIVITY_REGION_EU868; + break; + } + case 1: + { + self->_network_connectivity_settings->region = GUI_NETWORK_CONNECTIVITY_REGION_US915; + break; + } + default: + { + break; + } + } + } + else if( obj == self->ddlist_adr_profile ) + { + switch( id ) + { + case 0: + { + self->_network_connectivity_settings->adr_profile = + GUI_NETWORK_CONNECTIVITY_ADR_NETWORK_SERVER_CONTROLLED; + break; + } + case 1: + { + self->_network_connectivity_settings->adr_profile = GUI_NETWORK_CONNECTIVITY_ADR_MOBILE_LONG_RANGE; + break; + } + case 2: + { + self->_network_connectivity_settings->adr_profile = GUI_NETWORK_CONNECTIVITY_ADR_MOBILE_LOW_POWER; + break; + } + default: + { + break; + } + } + } + } +} + +void GuiConnectivity::create_ddlist( lv_obj_t** ddlist, int16_t off_y, const char* lbl_name, const char* options, + lv_event_cb_t event_cb, int16_t width ) +{ + lv_obj_t* lbl; + + lbl = lv_label_create( this->screen, NULL ); + lv_obj_set_style( lbl, &( GuiCommon::screen_style ) ); + lv_label_set_text( lbl, lbl_name ); + lv_obj_align( lbl, NULL, LV_ALIGN_IN_TOP_LEFT, 5, off_y ); + + *ddlist = lv_ddlist_create( this->screen, NULL ); + lv_ddlist_set_fix_width( *ddlist, width ); + lv_ddlist_set_draw_arrow( *ddlist, true ); + lv_ddlist_set_selected( *ddlist, 0 ); + lv_obj_align( *ddlist, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, off_y ); + lv_obj_set_top( *ddlist, true ); + lv_obj_set_event_cb( *ddlist, event_cb ); + lv_ddlist_set_options( *ddlist, options ); + lv_obj_set_user_data( *ddlist, this ); +} \ No newline at end of file diff --git a/embedded/gui/src/guiEui.cpp b/embedded/gui/src/guiEui.cpp new file mode 100644 index 0000000..ebb05e9 --- /dev/null +++ b/embedded/gui/src/guiEui.cpp @@ -0,0 +1,84 @@ +/** + * @file guiEui.cpp + * + * @brief Implementation of the GUI EUI page. + * + * Revised BSD License + * Copyright Semtech Corporation 2020. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Semtech corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "guiEui.h" + +#define GUI_ABOUT_BUFFER_LENGTH ( 40 ) + +GuiEui::GuiEui( version_handler_t* version_handler ) : GuiCommon( GUI_PAGE_EUI ) +{ + char buffer[GUI_ABOUT_BUFFER_LENGTH]; + + this->createHeader( "EUI" ); + + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "CHIP EUI\n%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X", + version_handler->chip_uid[0], version_handler->chip_uid[1], version_handler->chip_uid[2], + version_handler->chip_uid[3], version_handler->chip_uid[4], version_handler->chip_uid[5], + version_handler->chip_uid[6], version_handler->chip_uid[7] ); + this->createSection( buffer, -80 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "DEV EUI\n%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X", + version_handler->dev_eui[0], version_handler->dev_eui[1], version_handler->dev_eui[2], + version_handler->dev_eui[3], version_handler->dev_eui[4], version_handler->dev_eui[5], + version_handler->dev_eui[6], version_handler->dev_eui[7] ); + this->createSection( buffer, -30 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "JOIN EUI\n%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X", + version_handler->join_eui[0], version_handler->join_eui[1], version_handler->join_eui[2], + version_handler->join_eui[3], version_handler->join_eui[4], version_handler->join_eui[5], + version_handler->join_eui[6], version_handler->join_eui[7] ); + this->createSection( buffer, 20 ); + + snprintf( buffer, GUI_ABOUT_BUFFER_LENGTH, "PIN: %02X-%02X-%02X-%02X", version_handler->pin[0], + version_handler->pin[1], version_handler->pin[2], version_handler->pin[3] ); + this->createSection( buffer, 70 ); + + this->createActionButton( &( this->btn_back ), "BACK", GuiEui::callback, GUI_BUTTON_POS_CENTER, -5, true ); + + lv_scr_load( this->screen ); +} + +GuiEui::~GuiEui( ) {} + +void GuiEui::callback( lv_obj_t* obj, lv_event_t event ) +{ + GuiEui* self = ( GuiEui* ) lv_obj_get_user_data( obj ); + + if( event == LV_EVENT_RELEASED ) + { + if( obj == self->btn_back ) + { + GuiCommon::_event = GUI_EVENT_BACK; + } + } +} diff --git a/embedded/gui/src/guiMenu.cpp b/embedded/gui/src/guiMenu.cpp index 6dc0eab..cba545a 100644 --- a/embedded/gui/src/guiMenu.cpp +++ b/embedded/gui/src/guiMenu.cpp @@ -36,21 +36,34 @@ #define LABEL_WIDTH 150 #define MARGIN 10 -GuiMenu::GuiMenu( ) : GuiMenuCommon( GUI_PAGE_MENU ) +GuiMenu::GuiMenu( version_handler_t* version_handler ) : GuiMenuCommon( GUI_PAGE_MENU ) { + uint8_t index = 0; + this->createHeader( "MENU" ); - this->createTestEntry( -70, &( this->lbl_radio_test_modes ), &( this->btn_radio_test_modes ), + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + this->createTestEntry( index++, &( this->lbl_radio_test_modes ), &( this->btn_radio_test_modes ), &( this->lbl_btn_radio_test_modes ), "RADIO TEST MODES", true, GuiMenu::callback ); - this->createTestEntry( -0, &( this->lbl_demos ), &( this->btn_demos ), &( this->lbl_btn_demos ), "DEMONSTRATIONS", - true, GuiMenu::callback ); + this->createTestEntry( index++, &( this->lbl_demos ), &( this->btn_demos ), &( this->lbl_btn_demos ), + "DEMONSTRATIONS", true, GuiMenu::callback ); + + if( GuiCommon::_has_connectivity == true ) + { + this->createTestEntry( index++, &( this->lbl_connectivity ), &( this->btn_connectivity ), + &( this->lbl_btn_connectivity ), "CONNECTIVITY", true, GuiMenu::callback ); + } + + this->createTestEntry( index++, &( this->lbl_eui ), &( this->btn_eui ), &( this->lbl_btn_eui ), "EUI", true, + GuiMenu::callback ); + + lv_scr_load( this->screen ); } GuiMenu::~GuiMenu( ) {} -void GuiMenu::draw( ) { lv_scr_load( this->screen ); } - void GuiMenu::callback( lv_obj_t* obj, lv_event_t event ) { GuiMenu* self = ( GuiMenu* ) lv_obj_get_user_data( obj ); @@ -65,5 +78,13 @@ void GuiMenu::callback( lv_obj_t* obj, lv_event_t event ) { GuiCommon::_event = GUI_EVENT_LAUNCH_DEMO; } + else if( obj == self->btn_connectivity ) + { + GuiCommon::_event = GUI_EVENT_LAUNCH_CONNECTIVITY; + } + else if( obj == self->btn_eui ) + { + GuiCommon::_event = GUI_EVENT_EUI; + } } } diff --git a/embedded/gui/src/guiMenuCommon.cpp b/embedded/gui/src/guiMenuCommon.cpp index 43ca36d..8153f8b 100644 --- a/embedded/gui/src/guiMenuCommon.cpp +++ b/embedded/gui/src/guiMenuCommon.cpp @@ -36,11 +36,14 @@ #define LABEL_WIDTH 150 #define MARGIN 10 +#define TEST_ENTRY_BASE -80 +#define TEST_ENTRY_DISTANCE 60 + GuiMenuCommon::GuiMenuCommon( guiPageType_t pageType ) : GuiCommon( pageType ) {} GuiMenuCommon::~GuiMenuCommon( ) {} -void GuiMenuCommon::createTestEntry( int16_t y_pos, lv_obj_t** lbl, lv_obj_t** btn, lv_obj_t** lbl_btn, +void GuiMenuCommon::createTestEntry( uint8_t index, lv_obj_t** lbl, lv_obj_t** btn, lv_obj_t** lbl_btn, const char* lbl_name, bool is_clickable, lv_event_cb_t event_cb ) { // Create the label @@ -50,7 +53,7 @@ void GuiMenuCommon::createTestEntry( int16_t y_pos, lv_obj_t** lbl, lv_obj_t** b lv_label_set_align( *lbl, LV_LABEL_ALIGN_LEFT ); lv_label_set_text( *lbl, lbl_name ); lv_obj_set_width( *lbl, LABEL_WIDTH ); - lv_obj_align( *lbl, NULL, LV_ALIGN_IN_LEFT_MID, MARGIN, y_pos ); + lv_obj_align( *lbl, NULL, LV_ALIGN_IN_LEFT_MID, MARGIN, TEST_ENTRY_BASE + index * TEST_ENTRY_DISTANCE ); // Create the button *btn = lv_btn_create( this->screen, NULL ); @@ -59,7 +62,7 @@ void GuiMenuCommon::createTestEntry( int16_t y_pos, lv_obj_t** lbl, lv_obj_t** b lv_obj_set_width( *btn, BUTTON_WIDTH ); lv_obj_set_event_cb( *btn, event_cb ); lv_obj_set_user_data( *btn, this ); - lv_obj_align( *btn, NULL, LV_ALIGN_IN_RIGHT_MID, -MARGIN, y_pos ); + lv_obj_align( *btn, NULL, LV_ALIGN_IN_RIGHT_MID, -MARGIN, TEST_ENTRY_BASE + index * TEST_ENTRY_DISTANCE ); // Create the label attached to the button *lbl_btn = lv_label_create( *btn, NULL ); diff --git a/embedded/gui/src/guiMenuDemo.cpp b/embedded/gui/src/guiMenuDemo.cpp index 72e3429..7771499 100644 --- a/embedded/gui/src/guiMenuDemo.cpp +++ b/embedded/gui/src/guiMenuDemo.cpp @@ -33,20 +33,36 @@ #define MARGIN 10 -GuiMenuDemo::GuiMenuDemo( ) : GuiMenuCommon( GUI_PAGE_MENU_DEMO ) +GuiMenuDemo::GuiMenuDemo( version_handler_t* version_handler ) : GuiMenuCommon( GUI_PAGE_MENU_DEMO ) { - this->createHeader( "DEMONSTRATIONS" ); - - this->createTestEntry( -70, &( this->lbl_wifi ), &( this->btn_wifi ), &( this->lbl_btn_wifi ), "Wi-Fi scan", true, - GuiMenuDemo::callback ); + uint8_t index = 0; - this->createTestEntry( 0, &( this->lbl_gnss_autonomous ), &( this->btn_gnss_autonomous ), - &( this->lbl_btn_gnss_autonomous ), "GNSS autonomous", - ( GuiCommon::_is_host_connected == true ) ? true : false, GuiMenuDemo::callback ); + this->createHeader( "DEMONSTRATIONS" ); - this->createTestEntry( 70, &( this->lbl_gnss_assisted ), &( this->btn_gnss_assisted ), - &( this->lbl_btn_gnss_assisted ), "GNSS assisted", - ( GuiCommon::_is_host_connected == true ) ? true : false, GuiMenuDemo::callback ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + this->createTestEntry( index++, &( this->lbl_wifi ), &( this->btn_wifi ), &( this->lbl_btn_wifi ), "Wi-Fi scan", + true, GuiMenuDemo::callback ); + + this->createTestEntry( + index++, &( this->lbl_gnss_autonomous ), &( this->btn_gnss_autonomous ), &( this->lbl_btn_gnss_autonomous ), + ( GuiCommon::_is_host_connected == true ) || ( GuiCommon::_network_connectivity_status.is_time_sync == true ) + ? "GNSS autonomous" + : "GNSS autonomous*", + ( GuiCommon::_is_host_connected == true ) || ( GuiCommon::_network_connectivity_status.is_time_sync == true ) + ? true + : false, + GuiMenuDemo::callback ); + + this->createTestEntry( + index++, &( this->lbl_gnss_assisted ), &( this->btn_gnss_assisted ), &( this->lbl_btn_gnss_assisted ), + ( GuiCommon::_is_host_connected == true ) || ( GuiCommon::_network_connectivity_status.is_time_sync == true ) + ? "GNSS assisted" + : "GNSS assisted*", + ( GuiCommon::_is_host_connected == true ) || ( GuiCommon::_network_connectivity_status.is_time_sync == true ) + ? true + : false, + GuiMenuDemo::callback ); this->createActionButton( &( this->btn_back ), "BACK", GuiMenuDemo::callback, GUI_BUTTON_POS_CENTER, -5, true ); @@ -54,68 +70,41 @@ GuiMenuDemo::GuiMenuDemo( ) : GuiMenuCommon( GUI_PAGE_MENU_DEMO ) lv_obj_set_style( this->lbl_connectivity, &( GuiCommon::note_style ) ); lv_label_set_long_mode( this->lbl_connectivity, LV_LABEL_LONG_BREAK ); lv_label_set_align( this->lbl_connectivity, LV_LABEL_ALIGN_LEFT ); - lv_label_set_text( this->lbl_connectivity, "* Launch host app" ); - lv_obj_set_width( this->lbl_connectivity, 80 ); - lv_obj_align( this->lbl_connectivity, NULL, LV_ALIGN_IN_BOTTOM_LEFT, MARGIN, -10 ); - if( GuiCommon::_is_host_connected == true ) + switch( version_handler->device_type ) { - lv_obj_set_hidden( this->lbl_connectivity, true ); - } - else + case VERSION_DEVICE_TRANSCEIVER: { - lv_label_set_text( this->lbl_gnss_autonomous, "GNSS autonomous*" ); - lv_label_set_text( this->lbl_gnss_assisted, "GNSS assisted*" ); + lv_label_set_text( this->lbl_connectivity, "* Launch host app" ); + break; } -} - -GuiMenuDemo::~GuiMenuDemo( ) {} - -void GuiMenuDemo::draw( ) -{ - lv_btn_set_state( btn_gnss_autonomous, - ( GuiCommon::_is_host_connected == true ) ? LV_BTN_STATE_REL : LV_BTN_STATE_INA ); - - lv_btn_set_state( btn_gnss_assisted, - ( GuiCommon::_is_host_connected == true ) ? LV_BTN_STATE_REL : LV_BTN_STATE_INA ); - - if( GuiCommon::_is_host_connected == true ) + case VERSION_DEVICE_MODEM: { - lv_obj_set_hidden( this->lbl_connectivity, true ); - lv_label_set_text( this->lbl_gnss_autonomous, "GNSS autonomous" ); - lv_label_set_text( this->lbl_gnss_assisted, "GNSS assisted" ); + lv_label_set_text( this->lbl_connectivity, "* Wait for time sync" ); + break; } - else + default: { - lv_obj_set_hidden( this->lbl_connectivity, false ); - lv_label_set_text( this->lbl_gnss_autonomous, "GNSS autonomous*" ); - lv_label_set_text( this->lbl_gnss_assisted, "GNSS assisted*" ); + lv_label_set_text( this->lbl_connectivity, "* Error" ); + break; + } } + lv_obj_set_width( this->lbl_connectivity, 80 ); + lv_obj_align( this->lbl_connectivity, NULL, LV_ALIGN_IN_BOTTOM_LEFT, MARGIN, -10 ); + lv_obj_set_hidden( this->lbl_connectivity, ( ( GuiCommon::_is_host_connected == true ) || + ( GuiCommon::_network_connectivity_status.is_time_sync == true ) ) + ? true + : false ); + lv_scr_load( this->screen ); } -void GuiMenuDemo::updateHostConnectivityState( void ) -{ - lv_btn_set_state( btn_gnss_autonomous, - ( GuiCommon::_is_host_connected == true ) ? LV_BTN_STATE_REL : LV_BTN_STATE_INA ); +GuiMenuDemo::~GuiMenuDemo( ) {} - lv_btn_set_state( btn_gnss_assisted, - ( GuiCommon::_is_host_connected == true ) ? LV_BTN_STATE_REL : LV_BTN_STATE_INA ); +void GuiMenuDemo::updateHostConnectivityState( void ) { this->updateButtons( ); } - if( GuiCommon::_is_host_connected == true ) - { - lv_obj_set_hidden( this->lbl_connectivity, true ); - lv_label_set_text( this->lbl_gnss_autonomous, "GNSS autonomous" ); - lv_label_set_text( this->lbl_gnss_assisted, "GNSS assisted" ); - } - else - { - lv_obj_set_hidden( this->lbl_connectivity, false ); - lv_label_set_text( this->lbl_gnss_autonomous, "GNSS autonomous*" ); - lv_label_set_text( this->lbl_gnss_assisted, "GNSS assisted*" ); - } -} +void GuiMenuDemo::updateNetworkConnectivityState( ) { this->updateButtons( ); } void GuiMenuDemo::callback( lv_obj_t* obj, lv_event_t event ) { @@ -141,3 +130,29 @@ void GuiMenuDemo::callback( lv_obj_t* obj, lv_event_t event ) } } } + +void GuiMenuDemo::updateButtons( ) +{ + lv_btn_set_state( btn_gnss_autonomous, ( ( GuiCommon::_is_host_connected == true ) || + ( GuiCommon::_network_connectivity_status.is_time_sync == true ) ) + ? LV_BTN_STATE_REL + : LV_BTN_STATE_INA ); + + lv_btn_set_state( btn_gnss_assisted, ( ( GuiCommon::_is_host_connected == true ) || + ( GuiCommon::_network_connectivity_status.is_time_sync == true ) ) + ? LV_BTN_STATE_REL + : LV_BTN_STATE_INA ); + + if( ( GuiCommon::_is_host_connected == true ) || ( GuiCommon::_network_connectivity_status.is_time_sync == true ) ) + { + lv_obj_set_hidden( this->lbl_connectivity, true ); + lv_label_set_text( this->lbl_gnss_autonomous, "GNSS autonomous" ); + lv_label_set_text( this->lbl_gnss_assisted, "GNSS assisted" ); + } + else + { + lv_obj_set_hidden( this->lbl_connectivity, false ); + lv_label_set_text( this->lbl_gnss_autonomous, "GNSS autonomous*" ); + lv_label_set_text( this->lbl_gnss_assisted, "GNSS assisted*" ); + } +} diff --git a/embedded/gui/src/guiMenuRadioTestModes.cpp b/embedded/gui/src/guiMenuRadioTestModes.cpp index 94785ee..cbbf362 100644 --- a/embedded/gui/src/guiMenuRadioTestModes.cpp +++ b/embedded/gui/src/guiMenuRadioTestModes.cpp @@ -31,30 +31,38 @@ #include "guiMenuRadioTestModes.h" -GuiMenuRadioTestModes::GuiMenuRadioTestModes( ) : GuiMenuCommon( GUI_PAGE_MENU_RADIO_TEST_MODES ) +GuiMenuRadioTestModes::GuiMenuRadioTestModes( version_handler_t* version_handler ) + : GuiMenuCommon( GUI_PAGE_MENU_RADIO_TEST_MODES ) { + uint8_t index = 0; + this->createHeader( "RADIO TEST MODES" ); - this->createTestEntry( -70, &( this->lbl_radio_tx_cw ), &( this->btn_radio_tx_cw ), &( this->lbl_btn_radio_tx_cw ), - "TX Cont. Wave", true, GuiMenuRadioTestModes::callback ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + this->createTestEntry( index++, &( this->lbl_radio_tx_cw ), &( this->btn_radio_tx_cw ), + &( this->lbl_btn_radio_tx_cw ), "TX Cont. Wave", true, GuiMenuRadioTestModes::callback ); - this->createTestEntry( 0, &( this->lbl_radio_per ), &( this->btn_radio_per ), &( this->lbl_btn_radio_per ), + this->createTestEntry( index++, &( this->lbl_radio_per ), &( this->btn_radio_per ), &( this->lbl_btn_radio_per ), "Packet Error Rate", true, GuiMenuRadioTestModes::callback ); - this->createTestEntry( 70, &( this->lbl_radio_ping_pong ), &( this->btn_radio_ping_pong ), - &( this->lbl_btn_radio_ping_pong ), "Ping Pong", true, GuiMenuRadioTestModes::callback ); + if( version_handler->device_type == VERSION_DEVICE_TRANSCEIVER ) + { + this->createTestEntry( index++, &( this->lbl_radio_ping_pong ), &( this->btn_radio_ping_pong ), + &( this->lbl_btn_radio_ping_pong ), "Ping Pong", true, GuiMenuRadioTestModes::callback ); + } this->createActionButton( &( this->btn_back ), "BACK", GuiMenuRadioTestModes::callback, GUI_BUTTON_POS_CENTER, -5, true ); this->createActionButton( &( this->btn_config ), "CONFIG", GuiMenuRadioTestModes::callback, GUI_BUTTON_POS_RIGHT, -5, true ); + + lv_scr_load( this->screen ); } GuiMenuRadioTestModes::~GuiMenuRadioTestModes( ) {} -void GuiMenuRadioTestModes::draw( ) { lv_scr_load( this->screen ); } - void GuiMenuRadioTestModes::callback( lv_obj_t* obj, lv_event_t event ) { GuiMenuRadioTestModes* self = ( GuiMenuRadioTestModes* ) lv_obj_get_user_data( obj ); diff --git a/embedded/gui/src/guiRadioPer.cpp b/embedded/gui/src/guiRadioPer.cpp index 678637a..b100f70 100644 --- a/embedded/gui/src/guiRadioPer.cpp +++ b/embedded/gui/src/guiRadioPer.cpp @@ -38,8 +38,10 @@ GuiRadioPer::GuiRadioPer( const GuiRadioSetting_t* settings, const GuiRadioPerRe { this->createHeader( "PACKET ERROR RATE" ); - this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "", &( this->lbl_info_frame_2 ), "", - &( this->lbl_info_frame_3 ), "" ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "CHOOSE TX OR RX", + &( this->lbl_info_frame_2 ), "", &( this->lbl_info_frame_3 ), "" ); this->createActionButton( &( this->btn_start_tx ), "TX", GuiRadioPer::callback, GUI_BUTTON_POS_LEFT, -60, true ); @@ -52,19 +54,12 @@ GuiRadioPer::GuiRadioPer( const GuiRadioSetting_t* settings, const GuiRadioPerRe lv_obj_set_hidden( this->btn_start_tx, false ); lv_obj_set_hidden( this->btn_start_rx, false ); lv_obj_set_hidden( this->btn_stop, true ); + + lv_scr_load( this->screen ); } GuiRadioPer::~GuiRadioPer( ) {} -void GuiRadioPer::init( ) -{ - lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_init ) ); - - lv_label_set_text( this->lbl_info_frame_1, "CHOOSE TX OR RX" ); - lv_label_set_text( this->lbl_info_frame_2, "" ); - lv_label_set_text( this->lbl_info_frame_3, "" ); -} - void GuiRadioPer::start( ) { lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_ongoing ) ); @@ -119,8 +114,6 @@ void GuiRadioPer::refresh( ) } } -void GuiRadioPer::draw( ) { lv_scr_load( this->screen ); } - void GuiRadioPer::callback( lv_obj_t* obj, lv_event_t event ) { GuiRadioPer* self = ( GuiRadioPer* ) lv_obj_get_user_data( obj ); diff --git a/embedded/gui/src/guiRadioPingPong.cpp b/embedded/gui/src/guiRadioPingPong.cpp index 67f3f8f..3c03c19 100644 --- a/embedded/gui/src/guiRadioPingPong.cpp +++ b/embedded/gui/src/guiRadioPingPong.cpp @@ -31,15 +31,17 @@ #include "guiRadioPingPong.h" -#define TMP_BUFFER_REFRESH_LENGTH ( 30 ) +#define TMP_BUFFER_REFRESH_LENGTH ( 35 ) GuiRadioPingPong::GuiRadioPingPong( const GuiRadioSetting_t* settings, const GuiRadioPingPongResult_t* results ) : GuiCommon( GUI_PAGE_RADIO_PING_PONG ), settings( settings ), results( results ) { this->createHeader( "PING PONG" ); - this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "", &( this->lbl_info_frame_2 ), "", - &( this->lbl_info_frame_3 ), "" ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "PRESS START TO BEGIN", + &( this->lbl_info_frame_2 ), "", &( this->lbl_info_frame_3 ), "" ); this->createActionButton( &( this->btn_start ), "START", GuiRadioPingPong::callback, GUI_BUTTON_POS_CENTER, -60, true ); @@ -52,19 +54,12 @@ GuiRadioPingPong::GuiRadioPingPong( const GuiRadioSetting_t* settings, const Gui lv_obj_set_hidden( this->btn_start, false ); lv_obj_set_hidden( this->btn_stop, true ); + + lv_scr_load( this->screen ); } GuiRadioPingPong::~GuiRadioPingPong( ) {} -void GuiRadioPingPong::init( ) -{ - lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_init ) ); - - lv_label_set_text( this->lbl_info_frame_1, "PRESS START TO BEGIN" ); - lv_label_set_text( this->lbl_info_frame_2, "" ); - lv_label_set_text( this->lbl_info_frame_3, "" ); -} - void GuiRadioPingPong::start( ) { lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_ongoing ) ); @@ -98,8 +93,6 @@ void GuiRadioPingPong::refresh( ) lv_label_set_text( this->lbl_info_frame_3, buffer ); } -void GuiRadioPingPong::draw( ) { lv_scr_load( this->screen ); } - void GuiRadioPingPong::callback( lv_obj_t* obj, lv_event_t event ) { GuiRadioPingPong* self = ( GuiRadioPingPong* ) lv_obj_get_user_data( obj ); diff --git a/embedded/gui/src/guiRadioTxCw.cpp b/embedded/gui/src/guiRadioTxCw.cpp index 5dc4376..d398c37 100644 --- a/embedded/gui/src/guiRadioTxCw.cpp +++ b/embedded/gui/src/guiRadioTxCw.cpp @@ -36,10 +36,19 @@ GuiRadioTxCw::GuiRadioTxCw( const GuiRadioSetting_t* settings ) : GuiCommon( GUI_PAGE_RADIO_TX_CW ), settings( settings ) { + char buffer_1[TMP_BUFFER_REFRESH_LENGTH] = { 0 }; + char buffer_2[TMP_BUFFER_REFRESH_LENGTH] = { 0 }; + char buffer_3[TMP_BUFFER_REFRESH_LENGTH] = { 0 }; + this->createHeader( "TX CONTINUOUS WAVE" ); - this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "", &( this->lbl_info_frame_2 ), "", - &( this->lbl_info_frame_3 ), "" ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + + snprintf( buffer_1, TMP_BUFFER_REFRESH_LENGTH, "Freq = %i Hz", this->settings->rf_freq_in_hz ); + snprintf( buffer_2, TMP_BUFFER_REFRESH_LENGTH, "Power = %i dBm", this->settings->pwr_in_dbm ); + snprintf( buffer_3, TMP_BUFFER_REFRESH_LENGTH, "PRESS START TO BEGIN", this->settings->pwr_in_dbm ); + this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), buffer_1, &( this->lbl_info_frame_2 ), + buffer_2, &( this->lbl_info_frame_3 ), buffer_3 ); this->createActionButton( &( this->btn_start ), "START", GuiRadioTxCw::callback, GUI_BUTTON_POS_CENTER, -60, true ); @@ -49,25 +58,12 @@ GuiRadioTxCw::GuiRadioTxCw( const GuiRadioSetting_t* settings ) lv_obj_set_hidden( this->btn_start, false ); lv_obj_set_hidden( this->btn_stop, true ); + + lv_scr_load( this->screen ); } GuiRadioTxCw::~GuiRadioTxCw( ) {} -void GuiRadioTxCw::init( ) -{ - char buffer[30] = { 0 }; - - lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_init ) ); - - snprintf( buffer, TMP_BUFFER_REFRESH_LENGTH, "Freq = %i Hz", this->settings->rf_freq_in_hz ); - lv_label_set_text( this->lbl_info_frame_1, buffer ); - - snprintf( buffer, TMP_BUFFER_REFRESH_LENGTH, "Power = %i dBm", this->settings->pwr_in_dbm ); - lv_label_set_text( this->lbl_info_frame_2, buffer ); - - lv_label_set_text( this->lbl_info_frame_3, "PRESS START TO BEGIN" ); -} - void GuiRadioTxCw::start( ) { lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_ongoing ) ); @@ -82,12 +78,6 @@ void GuiRadioTxCw::stop( ) lv_label_set_text( this->lbl_info_frame_3, "PRESS START TO BEGIN" ); } -void GuiRadioTxCw::refresh( ) {} - -void GuiRadioTxCw::updateHostConnectivityState( void ) {} - -void GuiRadioTxCw::draw( ) { lv_scr_load( this->screen ); } - void GuiRadioTxCw::callback( lv_obj_t* obj, lv_event_t event ) { GuiRadioTxCw* self = ( GuiRadioTxCw* ) lv_obj_get_user_data( obj ); diff --git a/embedded/gui/src/guiResultsGnss.cpp b/embedded/gui/src/guiResultsGnss.cpp index 0668edd..0d09e75 100644 --- a/embedded/gui/src/guiResultsGnss.cpp +++ b/embedded/gui/src/guiResultsGnss.cpp @@ -48,11 +48,7 @@ GuiResultsGnss::GuiResultsGnss( const GuiGnssResult_t* results, guiPageType_t pa break; } - this->createActionButton( &( this->btn_back ), "BACK", GuiResultsGnss::callback, GUI_BUTTON_POS_CENTER, -5, true ); - - this->createActionButton( &( this->btn_left ), "<", GuiResultsGnss::callback, GUI_BUTTON_POS_LEFT, -5, false ); - - this->createActionButton( &( this->btn_right ), ">", GuiResultsGnss::callback, GUI_BUTTON_POS_RIGHT, -5, false ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); this->lbl_info_page = lv_label_create( this->screen, NULL ); lv_obj_set_style( this->lbl_info_page, &( GuiCommon::screen_style ) ); @@ -70,54 +66,37 @@ GuiResultsGnss::GuiResultsGnss( const GuiGnssResult_t* results, guiPageType_t pa lv_table_set_col_width( this->table, 0, 150 ); lv_table_set_col_width( this->table, 1, 80 ); lv_obj_align( this->table, NULL, LV_ALIGN_IN_TOP_MID, 0, 80 ); -} -GuiResultsGnss::~GuiResultsGnss( ) {} - -void GuiResultsGnss::draw( ) -{ this->_pageCurrent = 0; this->_pageTotal = ( _results->nb_satellites % GUI_GNSS_MAX_RESULTS == 0 ) ? _results->nb_satellites / GUI_GNSS_MAX_RESULTS : _results->nb_satellites / GUI_GNSS_MAX_RESULTS + 1; - // Update navigation button states - if( _pageTotal > 1 ) - { - lv_btn_set_state( this->btn_left, LV_BTN_STATE_REL ); - lv_btn_set_state( this->btn_right, LV_BTN_STATE_REL ); - } - else - { - lv_btn_set_state( this->btn_left, LV_BTN_STATE_INA ); - lv_btn_set_state( this->btn_right, LV_BTN_STATE_INA ); - } + this->createActionButton( &( this->btn_back ), "BACK", GuiResultsGnss::callback, GUI_BUTTON_POS_CENTER, -5, true ); + + this->createActionButton( &( this->btn_left ), "<", GuiResultsGnss::callback, GUI_BUTTON_POS_LEFT, -5, + ( this->_pageTotal > 1 ) ? true : false ); + + this->createActionButton( &( this->btn_right ), ">", GuiResultsGnss::callback, GUI_BUTTON_POS_RIGHT, -5, + ( this->_pageTotal > 1 ) ? true : false ); this->setResults( ); lv_scr_load( this->screen ); } -void GuiResultsGnss::updateResults( guiEvent_t event ) +GuiResultsGnss::~GuiResultsGnss( ) {} + +void GuiResultsGnss::findAndDisplayNextPage( bool up ) { - switch( event ) - { - case GUI_EVENT_LEFT: + if( up == false ) { - _event = GUI_EVENT_NONE; - _pageCurrent = ( _pageCurrent == 0 ) ? ( _pageTotal - 1 ) : ( _pageCurrent - 1 ); - break; + this->_pageCurrent = ( this->_pageCurrent == 0 ) ? ( this->_pageTotal - 1 ) : ( this->_pageCurrent - 1 ); } - - case GUI_EVENT_RIGHT: - _event = GUI_EVENT_NONE; - _pageCurrent = ( _pageCurrent + 1 ) % _pageTotal; - - break; - - default: - break; + else + { + this->_pageCurrent = ( this->_pageCurrent + 1 ) % this->_pageTotal; } this->setResults( ); @@ -175,11 +154,11 @@ void GuiResultsGnss::callback( lv_obj_t* obj, lv_event_t event ) } else if( obj == self->btn_left ) { - GuiCommon::_event = GUI_EVENT_LEFT; + self->findAndDisplayNextPage( false ); } else if( obj == self->btn_right ) { - GuiCommon::_event = GUI_EVENT_RIGHT; + self->findAndDisplayNextPage( true ); } } } diff --git a/embedded/gui/src/guiResultsWifi.cpp b/embedded/gui/src/guiResultsWifi.cpp index 41d3ee3..75a2c09 100644 --- a/embedded/gui/src/guiResultsWifi.cpp +++ b/embedded/gui/src/guiResultsWifi.cpp @@ -31,18 +31,14 @@ #include "guiResultsWifi.h" -#define TMP_BUFFER_SET_CHANNEL_RESULTS_LENGTH ( 25 ) +#define TMP_BUFFER_CHANNEL_RESULTS_LENGTH ( 25 ) GuiResultsWifi::GuiResultsWifi( const GuiWifiResult_t* results ) - : GuiCommon( GUI_PAGE_WIFI_RESULTS ), _results( results ) + : GuiCommon( GUI_PAGE_WIFI_RESULTS ), _results( results ), _current_chan( NULL ) { this->createHeader( "Wi-Fi SCANNING - RESULTS" ); - this->createActionButton( &( this->btn_back ), "BACK", GuiResultsWifi::callback, GUI_BUTTON_POS_CENTER, -5, true ); - - this->createActionButton( &( this->btn_left ), "<", GuiResultsWifi::callback, GUI_BUTTON_POS_LEFT, -5, false ); - - this->createActionButton( &( this->btn_right ), ">", GuiResultsWifi::callback, GUI_BUTTON_POS_RIGHT, -5, false ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); this->lbl_info_page = lv_label_create( this->screen, NULL ); lv_obj_set_style( this->lbl_info_page, &( GuiCommon::screen_style ) ); @@ -60,120 +56,115 @@ GuiResultsWifi::GuiResultsWifi( const GuiWifiResult_t* results ) lv_table_set_col_width( this->table, 0, 150 ); lv_table_set_col_width( this->table, 1, 80 ); lv_obj_align( this->table, NULL, LV_ALIGN_IN_TOP_MID, 0, 80 ); -} -GuiResultsWifi::~GuiResultsWifi( ) {} + this->findAndDisplayFirstNonEmptyChannel( ); -void GuiResultsWifi::draw( ) -{ - const GuiWifiResultChannel_t* chan = NULL; + this->createActionButton( &( this->btn_back ), "BACK", GuiResultsWifi::callback, GUI_BUTTON_POS_CENTER, -5, true ); - // Find the first non - empty channel - for( uint8_t index = 0; index < GUI_WIFI_CHANNELS * 2; index++ ) - { - if( index < GUI_WIFI_CHANNELS ) - { - if( _results->typeB.channel[index].nbMacAddr > 0 ) - { - chan = &_results->typeB.channel[index]; - _index = index; - break; - } - } - else - { - if( _results->typeG.channel[index % GUI_WIFI_CHANNELS].nbMacAddr > 0 ) - { - chan = &_results->typeG.channel[index % GUI_WIFI_CHANNELS]; - _index = index; - break; - } - } - } + this->createActionButton( + &( this->btn_left ), "<", GuiResultsWifi::callback, GUI_BUTTON_POS_LEFT, -5, + ( this->_current_chan != NULL ) && ( this->_current_chan->nbMacAddr != this->_results->nbMacAddrTotal ) + ? true + : false ); - // Update navigation button states - if( ( chan != NULL ) && ( chan->nbMacAddr != _results->nbMacAddrTotal ) ) - { - lv_btn_set_state( this->btn_left, LV_BTN_STATE_REL ); - lv_btn_set_state( this->btn_right, LV_BTN_STATE_REL ); - } - else - { - lv_btn_set_state( this->btn_left, LV_BTN_STATE_INA ); - lv_btn_set_state( this->btn_right, LV_BTN_STATE_INA ); - } - - this->setChannelResults( ); + this->createActionButton( + &( this->btn_right ), ">", GuiResultsWifi::callback, GUI_BUTTON_POS_RIGHT, -5, + ( this->_current_chan != NULL ) && ( this->_current_chan->nbMacAddr != this->_results->nbMacAddrTotal ) + ? true + : false ); lv_scr_load( this->screen ); } -void GuiResultsWifi::updateResults( guiEvent_t event ) -{ - this->findNextChannel( ( event == GUI_EVENT_LEFT ) ? false : true ); - this->setChannelResults( ); -} +GuiResultsWifi::~GuiResultsWifi( ) {} void GuiResultsWifi::setChannelResults( ) { - char buffer[TMP_BUFFER_SET_CHANNEL_RESULTS_LENGTH]; - const GuiWifiResultChannel_t* chan; + char buffer[TMP_BUFFER_CHANNEL_RESULTS_LENGTH]; - // Create page information if( this->_index < GUI_WIFI_CHANNELS ) { - chan = &_results->typeB.channel[this->_index]; - snprintf( buffer, TMP_BUFFER_SET_CHANNEL_RESULTS_LENGTH, "Wi-Fi B Ch%i", ( this->_index + 1 ) ); + snprintf( buffer, TMP_BUFFER_CHANNEL_RESULTS_LENGTH, "Wi-Fi B Ch%i", ( this->_index + 1 ) ); } else { - chan = &_results->typeG.channel[this->_index % GUI_WIFI_CHANNELS]; - snprintf( buffer, TMP_BUFFER_SET_CHANNEL_RESULTS_LENGTH, "Wi-Fi G Ch%i", ( _index + 1 ) % GUI_WIFI_CHANNELS ); + snprintf( buffer, TMP_BUFFER_CHANNEL_RESULTS_LENGTH, "Wi-Fi G Ch%i", ( this->_index + 1 ) % GUI_WIFI_CHANNELS ); } lv_label_set_text( this->lbl_info_page, buffer ); - lv_table_set_row_cnt( this->table, chan->nbMacAddr ); + lv_table_set_row_cnt( this->table, this->_current_chan->nbMacAddr ); - for( uint8_t index = 0; index < chan->nbMacAddr; index++ ) + for( uint8_t index = 0; index < this->_current_chan->nbMacAddr; index++ ) { - lv_table_set_cell_value( table, index, 0, chan->data[index].macAddr ); - lv_table_set_cell_align( table, index, 0, LV_LABEL_ALIGN_LEFT ); + lv_table_set_cell_value( this->table, index, 0, this->_current_chan->data[index].macAddr ); + lv_table_set_cell_align( this->table, index, 0, LV_LABEL_ALIGN_LEFT ); - snprintf( buffer, TMP_BUFFER_SET_CHANNEL_RESULTS_LENGTH, "%idBm", chan->data[index].rssi ); - lv_table_set_cell_value( table, index, 1, buffer ); - lv_table_set_cell_align( table, index, 1, LV_LABEL_ALIGN_RIGHT ); + snprintf( buffer, TMP_BUFFER_CHANNEL_RESULTS_LENGTH, "%idBm", this->_current_chan->data[index].rssi ); + lv_table_set_cell_value( this->table, index, 1, buffer ); + lv_table_set_cell_align( this->table, index, 1, LV_LABEL_ALIGN_RIGHT ); } } -void GuiResultsWifi::findNextChannel( bool up ) +void GuiResultsWifi::findAndDisplayFirstNonEmptyChannel( ) +{ + for( uint8_t index = 0; index < GUI_WIFI_CHANNELS * 2; index++ ) + { + if( index < GUI_WIFI_CHANNELS ) + { + if( this->_results->typeB.channel[index].nbMacAddr > 0 ) + { + this->_current_chan = &_results->typeB.channel[index]; + this->_index = index; + break; + } + } + else + { + if( this->_results->typeG.channel[index % GUI_WIFI_CHANNELS].nbMacAddr > 0 ) + { + this->_current_chan = &_results->typeG.channel[index % GUI_WIFI_CHANNELS]; + this->_index = index; + break; + } + } + } + + this->setChannelResults( ); +} + +void GuiResultsWifi::findAndDisplayNextChannel( bool up ) { while( true ) { if( up == true ) { - _index = ( _index + 1 ) % ( GUI_WIFI_CHANNELS * 2 ); + this->_index = ( this->_index + 1 ) % ( GUI_WIFI_CHANNELS * 2 ); } else { - _index = ( _index == 0 ) ? ( GUI_WIFI_CHANNELS * 2 - 1 ) : ( _index - 1 ); + this->_index = ( this->_index == 0 ) ? ( GUI_WIFI_CHANNELS * 2 - 1 ) : ( this->_index - 1 ); } - if( _index < GUI_WIFI_CHANNELS ) + if( this->_index < GUI_WIFI_CHANNELS ) { - if( _results->typeB.channel[_index].nbMacAddr > 0 ) + if( this->_results->typeB.channel[this->_index].nbMacAddr > 0 ) { + this->_current_chan = &_results->typeB.channel[this->_index]; break; } } else { - if( _results->typeG.channel[_index % GUI_WIFI_CHANNELS].nbMacAddr > 0 ) + if( this->_results->typeG.channel[this->_index % GUI_WIFI_CHANNELS].nbMacAddr > 0 ) { + this->_current_chan = &_results->typeG.channel[this->_index % GUI_WIFI_CHANNELS]; break; } } } + + this->setChannelResults( ); } void GuiResultsWifi::callback( lv_obj_t* obj, lv_event_t event ) @@ -188,11 +179,11 @@ void GuiResultsWifi::callback( lv_obj_t* obj, lv_event_t event ) } else if( obj == self->btn_left ) { - GuiCommon::_event = GUI_EVENT_LEFT; + self->findAndDisplayNextChannel( false ); } else if( obj == self->btn_right ) { - GuiCommon::_event = GUI_EVENT_RIGHT; + self->findAndDisplayNextChannel( true ); } } } diff --git a/embedded/gui/src/guiSplashScreen.cpp b/embedded/gui/src/guiSplashScreen.cpp index bb4164f..1742216 100644 --- a/embedded/gui/src/guiSplashScreen.cpp +++ b/embedded/gui/src/guiSplashScreen.cpp @@ -30,10 +30,9 @@ */ #include "guiSplashScreen.h" -#include "version.h" #include "semtech_logo.h" -GuiSplashScreen::GuiSplashScreen( ) : GuiCommon( GUI_PAGE_SPLASHSCREEN ) +GuiSplashScreen::GuiSplashScreen( version_handler_t* version_handler ) : GuiCommon( GUI_PAGE_SPLASHSCREEN ) { lv_obj_t* icon = lv_img_create( this->screen, NULL ); lv_obj_align( icon, NULL, LV_ALIGN_IN_TOP_LEFT, 17, 0 ); @@ -43,9 +42,26 @@ GuiSplashScreen::GuiSplashScreen( ) : GuiCommon( GUI_PAGE_SPLASHSCREEN ) lv_obj_set_style( lbl_title, &( GuiCommon::title_style ) ); lv_label_set_long_mode( lbl_title, LV_LABEL_LONG_BREAK ); lv_label_set_align( lbl_title, LV_LABEL_ALIGN_CENTER ); - lv_label_set_text( lbl_title, "LR1110\nEVALUATION KIT" ); + switch( version_handler->device_type ) + { + case VERSION_DEVICE_TRANSCEIVER: + { + lv_label_set_text( lbl_title, "LR1110\nDEMO APPLICATION" ); + break; + } + case VERSION_DEVICE_MODEM: + { + lv_label_set_text( lbl_title, "LoRa BASICS MODEM-E\nDEMO APPLICATION" ); + break; + } + default: + { + lv_label_set_text( lbl_title, "ERROR\nERROR" ); + break; + } + } lv_obj_set_width( lbl_title, 240 ); - lv_obj_align( lbl_title, NULL, LV_ALIGN_CENTER, 0, 0 ); + lv_obj_align( lbl_title, NULL, LV_ALIGN_CENTER, 0, -20 ); lv_obj_t* lbl_version = lv_label_create( screen, NULL ); lv_obj_set_style( lbl_version, &( GuiCommon::screen_style ) ); @@ -59,12 +75,12 @@ GuiSplashScreen::GuiSplashScreen( ) : GuiCommon( GUI_PAGE_SPLASHSCREEN ) true ); this->createActionButton( &( this->btn_about ), "ABOUT", GuiSplashScreen::callback, GUI_BUTTON_POS_LEFT, -5, true ); + + lv_scr_load( this->screen ); } GuiSplashScreen::~GuiSplashScreen( ) {} -void GuiSplashScreen::draw( ) { lv_scr_load( this->screen ); } - void GuiSplashScreen::callback( lv_obj_t* obj, lv_event_t event ) { GuiSplashScreen* self = ( GuiSplashScreen* ) lv_obj_get_user_data( obj ); diff --git a/embedded/gui/src/guiTestGnss.cpp b/embedded/gui/src/guiTestGnss.cpp index 8316fb3..de7d2ab 100644 --- a/embedded/gui/src/guiTestGnss.cpp +++ b/embedded/gui/src/guiTestGnss.cpp @@ -34,7 +34,7 @@ #define TMP_BUFFERS_REFRESH_LENGTH ( 30 ) #define TMP_BUFFER_REVERSE_GEO_LOC_REFRESH_LENGTH ( 80 ) -GuiTestGnss::GuiTestGnss( const GuiGnssResult_t* results, guiPageType_t pageType ) +GuiTestGnss::GuiTestGnss( const GuiGnssResult_t* results, guiPageType_t pageType, bool at_least_one_scan_done ) : GuiCommon( pageType ), _results( results ) { switch( pageType ) @@ -49,6 +49,8 @@ GuiTestGnss::GuiTestGnss( const GuiGnssResult_t* results, guiPageType_t pageType break; } + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + this->createActionButton( &( this->btn_start_stop ), "START", GuiTestGnss::callback, GUI_BUTTON_POS_CENTER, -60, true ); @@ -61,24 +63,25 @@ GuiTestGnss::GuiTestGnss( const GuiGnssResult_t* results, guiPageType_t pageType this->createActionButton( &( this->btn_config ), "CONFIG", GuiTestGnss::callback, GUI_BUTTON_POS_RIGHT, -5, true ); - this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "SCAN IN PROGRESS...", - &( this->lbl_info_frame_2 ), "", &( this->lbl_info_frame_3 ), "" ); -} - -GuiTestGnss::~GuiTestGnss( ) {} + if( pageType == GUI_PAGE_GNSS_ASSISTED_TEST ) + { + this->createActionButton( &( this->btn_assist ), "ASSIST", GuiTestGnss::callback, GUI_BUTTON_POS_LEFT, -5, + true ); + } -void GuiTestGnss::init( ) -{ - lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_init ) ); + this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "PRESS START TO BEGIN", + &( this->lbl_info_frame_2 ), "", &( this->lbl_info_frame_3 ), "" ); - lv_label_set_text( this->lbl_info_frame_1, "PRESS START TO BEGIN" ); - lv_label_set_text( this->lbl_info_frame_2, "" ); - lv_label_set_text( this->lbl_info_frame_3, "" ); + if( at_least_one_scan_done == true ) + { + this->refresh( ); + } - lv_btn_set_state( this->btn_send, LV_BTN_STATE_INA ); - lv_btn_set_state( this->btn_results, LV_BTN_STATE_INA ); + lv_scr_load( this->screen ); } +GuiTestGnss::~GuiTestGnss( ) {} + void GuiTestGnss::start( ) { lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_ongoing ) ); @@ -155,7 +158,7 @@ void GuiTestGnss::refresh( ) { if( strlen( _results->reverse_geo_loc.country ) != 0 ) { - snprintf( buffer_3, TMP_BUFFER_REVERSE_GEO_LOC_REFRESH_LENGTH, "%s, %s\n%s - %s\n%s", + snprintf( buffer_3, TMP_BUFFER_REVERSE_GEO_LOC_REFRESH_LENGTH, "%s %s\n%s - %s\n%s", _results->reverse_geo_loc.latitude, _results->reverse_geo_loc.longitude, _results->reverse_geo_loc.country, _results->reverse_geo_loc.city, _results->reverse_geo_loc.street ); @@ -171,21 +174,13 @@ void GuiTestGnss::refresh( ) lv_label_set_text( this->lbl_info_frame_1, buffer_1 ); lv_label_set_text( this->lbl_info_frame_2, buffer_2 ); lv_label_set_text( this->lbl_info_frame_3, buffer_3 ); + + this->updateButtons( ); } -void GuiTestGnss::draw( ) { lv_scr_load( this->screen ); } +void GuiTestGnss::updateHostConnectivityState( void ) { this->updateButtons( ); } -void GuiTestGnss::updateHostConnectivityState( void ) -{ - if( ( GuiCommon::_is_host_connected == true ) && ( _results->nb_satellites > 0 ) ) - { - lv_btn_set_state( this->btn_send, LV_BTN_STATE_REL ); - } - else - { - lv_btn_set_state( this->btn_send, LV_BTN_STATE_INA ); - } -} +void GuiTestGnss::updateNetworkConnectivityState( ) { this->updateButtons( ); } void GuiTestGnss::callback( lv_obj_t* obj, lv_event_t event ) { @@ -223,5 +218,23 @@ void GuiTestGnss::callback( lv_obj_t* obj, lv_event_t event ) { GuiCommon::_event = GUI_EVENT_CONFIG; } + else if( obj == self->btn_assist ) + { + GuiCommon::_event = GUI_EVENT_ASSISTANCE_POSITION; + } + } +} + +void GuiTestGnss::updateButtons( ) +{ + if( ( ( GuiCommon::_network_connectivity_status.connectivity_state == GUI_CONNECTIVITY_STATUS_CONNECTED ) || + ( GuiCommon::_is_host_connected == true ) ) && + ( _results->nb_satellites > 0 ) ) + { + lv_btn_set_state( this->btn_send, LV_BTN_STATE_REL ); + } + else + { + lv_btn_set_state( this->btn_send, LV_BTN_STATE_INA ); } } diff --git a/embedded/gui/src/guiTestWifi.cpp b/embedded/gui/src/guiTestWifi.cpp index 830fd78..703d971 100644 --- a/embedded/gui/src/guiTestWifi.cpp +++ b/embedded/gui/src/guiTestWifi.cpp @@ -34,10 +34,13 @@ #define TMP_BUFFERS_REFRESH_LENGTH ( 30 ) #define TMP_BUFFER_REVERSE_GEO_LOC_REFRESH_LENGTH ( 80 ) -GuiTestWifi::GuiTestWifi( const GuiWifiResult_t* results ) : GuiCommon( GUI_PAGE_WIFI_TEST ), _results( results ) +GuiTestWifi::GuiTestWifi( const GuiWifiResult_t* results, bool at_least_one_scan_done ) + : GuiCommon( GUI_PAGE_WIFI_TEST ), _results( results ) { this->createHeader( "Wi-Fi SCANNING" ); + this->createNetworkConnectivityIcon( &( this->_label_connectivity_icon ) ); + this->createActionButton( &( this->btn_start_stop ), "START", GuiTestWifi::callback, GUI_BUTTON_POS_CENTER, -60, true ); @@ -50,24 +53,19 @@ GuiTestWifi::GuiTestWifi( const GuiWifiResult_t* results ) : GuiCommon( GUI_PAGE this->createActionButton( &( this->btn_config ), "CONFIG", GuiTestWifi::callback, GUI_BUTTON_POS_RIGHT, -5, true ); - this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "SCAN IN PROGRESS...", + this->createInfoFrame( &( this->info_frame ), &( this->lbl_info_frame_1 ), "PRESS START TO BEGIN", &( this->lbl_info_frame_2 ), "", &( this->lbl_info_frame_3 ), "" ); -} -GuiTestWifi::~GuiTestWifi( ) {} - -void GuiTestWifi::init( ) -{ - lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_init ) ); - - lv_label_set_text( this->lbl_info_frame_1, "PRESS START TO BEGIN" ); - lv_label_set_text( this->lbl_info_frame_2, "" ); - lv_label_set_text( this->lbl_info_frame_3, "" ); + if( at_least_one_scan_done == true ) + { + this->refresh( ); + } - lv_btn_set_state( this->btn_send, LV_BTN_STATE_INA ); - lv_btn_set_state( this->btn_results, LV_BTN_STATE_INA ); + lv_scr_load( this->screen ); } +GuiTestWifi::~GuiTestWifi( ) {} + void GuiTestWifi::start( ) { lv_cont_set_style( this->info_frame, LV_CONT_STYLE_MAIN, &( GuiCommon::info_frame_style_ongoing ) ); @@ -122,7 +120,7 @@ void GuiTestWifi::refresh( ) { if( strlen( _results->reverse_geo_loc.country ) != 0 ) { - snprintf( buffer_3, TMP_BUFFER_REVERSE_GEO_LOC_REFRESH_LENGTH, "%s, %s\n%s - %s\n%s", + snprintf( buffer_3, TMP_BUFFER_REVERSE_GEO_LOC_REFRESH_LENGTH, "%s %s\n%s - %s\n%s", _results->reverse_geo_loc.latitude, _results->reverse_geo_loc.longitude, _results->reverse_geo_loc.country, _results->reverse_geo_loc.city, _results->reverse_geo_loc.street ); @@ -137,21 +135,13 @@ void GuiTestWifi::refresh( ) lv_label_set_text( this->lbl_info_frame_1, buffer_1 ); lv_label_set_text( this->lbl_info_frame_2, buffer_2 ); lv_label_set_text( this->lbl_info_frame_3, buffer_3 ); + + this->updateButtons( ); } -void GuiTestWifi::draw( ) { lv_scr_load( this->screen ); } +void GuiTestWifi::updateHostConnectivityState( void ) { this->updateButtons( ); } -void GuiTestWifi::updateHostConnectivityState( void ) -{ - if( ( GuiCommon::_is_host_connected == true ) && ( _results->nbMacAddrTotal > 0 ) ) - { - lv_btn_set_state( this->btn_send, LV_BTN_STATE_REL ); - } - else - { - lv_btn_set_state( this->btn_send, LV_BTN_STATE_INA ); - } -} +void GuiTestWifi::updateNetworkConnectivityState( ) { this->updateButtons( ); } void GuiTestWifi::callback( lv_obj_t* obj, lv_event_t event ) { @@ -181,3 +171,17 @@ void GuiTestWifi::callback( lv_obj_t* obj, lv_event_t event ) } } } + +void GuiTestWifi::updateButtons( ) +{ + if( ( ( GuiCommon::_is_host_connected == true ) || + ( GuiCommon::_network_connectivity_status.connectivity_state == GUI_CONNECTIVITY_STATUS_CONNECTED ) ) && + ( _results->nbMacAddrTotal > 0 ) ) + { + lv_btn_set_state( this->btn_send, LV_BTN_STATE_REL ); + } + else + { + lv_btn_set_state( this->btn_send, LV_BTN_STATE_INA ); + } +} diff --git a/embedded/hci/Command/Inc/command_base.h b/embedded/hci/Command/Inc/command_base.h index 628ec53..daba9c1 100644 --- a/embedded/hci/Command/Inc/command_base.h +++ b/embedded/hci/Command/Inc/command_base.h @@ -33,7 +33,7 @@ #define __COMMAND_BASE_H__ #include "command_interface.h" -#include "device_base.h" +#include "device_interface.h" #include "hci.h" typedef enum @@ -48,19 +48,19 @@ typedef enum class CommandBase : public CommandInterface { public: - CommandBase( DeviceBase* device, Hci& hci ); + CommandBase( DeviceInterface* device, Hci& hci ); virtual ~CommandBase( ); virtual CommandEvent_t Execute( ); protected: - virtual bool Job( ) { return false; } - void SetEventStartDemo( CommandBaseDemoId_t demo_to_start ); - void SetEventStopDemo( ); - void SetEventResetDemo( void ); - void SetNoEvent( ); - void SendResponseBuffer( const uint8_t* buffer, const uint16_t buffer_length ); - DeviceBase* device; + virtual bool Job( ) { return false; } + void SetEventStartDemo( CommandBaseDemoId_t demo_to_start ); + void SetEventStopDemo( ); + void SetEventResetDemo( void ); + void SetNoEvent( ); + void SendResponseBuffer( const uint8_t* buffer, const uint16_t buffer_length ); + DeviceInterface* device; private: Hci* hci; diff --git a/embedded/hci/Command/Inc/command_check_almanac_update.h b/embedded/hci/Command/Inc/command_check_almanac_update.h index b4e87a5..15ee4ad 100644 --- a/embedded/hci/Command/Inc/command_check_almanac_update.h +++ b/embedded/hci/Command/Inc/command_check_almanac_update.h @@ -37,7 +37,7 @@ class CommandCheckAlmanacUpdate : public CommandBase { public: - CommandCheckAlmanacUpdate( DeviceBase* device, Hci& hci ); + CommandCheckAlmanacUpdate( DeviceInterface* device, Hci& hci ); virtual ~CommandCheckAlmanacUpdate( ); virtual uint16_t GetComCode( ); diff --git a/embedded/hci/Command/Inc/command_fetch_result.h b/embedded/hci/Command/Inc/command_fetch_result.h index 71d042f..9d0d9b4 100644 --- a/embedded/hci/Command/Inc/command_fetch_result.h +++ b/embedded/hci/Command/Inc/command_fetch_result.h @@ -34,12 +34,12 @@ #include "command_interface.h" #include "hci.h" -#include "demo.h" +#include "demo_manager_interface.h" class CommandFetchResult : public CommandInterface { public: - CommandFetchResult( Hci& hci, EnvironmentInterface& environment, Demo& demo_holder ); + CommandFetchResult( Hci& hci, EnvironmentInterface& environment, DemoManagerInterface& demo_holder ); virtual ~CommandFetchResult( ); virtual uint16_t GetComCode( ); @@ -72,7 +72,7 @@ class CommandFetchResult : public CommandInterface private: Hci& hci; EnvironmentInterface& environment; - Demo& demo_holder; + DemoManagerInterface& demo_holder; }; #endif // __COMMAND_FETCH_RESULT_H__ diff --git a/embedded/hci/Command/Inc/command_get_almanac_dates.h b/embedded/hci/Command/Inc/command_get_almanac_dates.h index 92c0c13..e6d2f86 100644 --- a/embedded/hci/Command/Inc/command_get_almanac_dates.h +++ b/embedded/hci/Command/Inc/command_get_almanac_dates.h @@ -34,13 +34,13 @@ #include "command_interface.h" #include "hci.h" -#include "device_base.h" +#include "device_interface.h" #include "lr1110_gnss_types.h" class CommandGetAlmanacDates : public CommandInterface { public: - CommandGetAlmanacDates( DeviceBase* device, Hci& hci ); + CommandGetAlmanacDates( DeviceInterface* device, Hci& hci ); virtual ~CommandGetAlmanacDates( ); virtual uint16_t GetComCode( ); @@ -52,8 +52,8 @@ class CommandGetAlmanacDates : public CommandInterface uint16_t* dates ); private: - Hci* hci; - DeviceBase* device; + Hci* hci; + DeviceInterface* device; }; #endif // __COMMAND_GET_ALMANAC_DATES_H__ diff --git a/embedded/hci/Command/Inc/command_reset.h b/embedded/hci/Command/Inc/command_reset.h index dcf26d6..82f21f6 100644 --- a/embedded/hci/Command/Inc/command_reset.h +++ b/embedded/hci/Command/Inc/command_reset.h @@ -38,7 +38,7 @@ class CommandReset : public CommandBase { public: - explicit CommandReset( DeviceBase* device, Hci& hci ); + explicit CommandReset( DeviceInterface* device, Hci& hci ); virtual ~CommandReset( ); virtual uint16_t GetComCode( ); diff --git a/embedded/hci/Command/Inc/command_set_date_loc.h b/embedded/hci/Command/Inc/command_set_date_loc.h index c5882f4..0917084 100644 --- a/embedded/hci/Command/Inc/command_set_date_loc.h +++ b/embedded/hci/Command/Inc/command_set_date_loc.h @@ -38,7 +38,7 @@ class CommandSetDateLoc : public CommandBase { public: - CommandSetDateLoc( DeviceBase* device, Hci& hci, EnvironmentInterface& environment ); + CommandSetDateLoc( DeviceInterface* device, Hci& hci, EnvironmentInterface& environment ); virtual ~CommandSetDateLoc( ); virtual uint16_t GetComCode( ); diff --git a/embedded/hci/Command/Inc/command_start_demo.h b/embedded/hci/Command/Inc/command_start_demo.h index 5aaa582..5fa5e29 100644 --- a/embedded/hci/Command/Inc/command_start_demo.h +++ b/embedded/hci/Command/Inc/command_start_demo.h @@ -34,12 +34,12 @@ #include "command_base.h" #include "hci.h" -#include "demo.h" +#include "demo_manager_interface.h" class CommandStartDemo : public CommandBase { public: - explicit CommandStartDemo( DeviceBase* device, Hci& hci, Demo& demo_holder ); + explicit CommandStartDemo( DeviceInterface* device, Hci& hci, DemoManagerInterface& demo_holder ); virtual ~CommandStartDemo( ); virtual uint16_t GetComCode( ); @@ -53,10 +53,13 @@ class CommandStartDemo : public CommandBase bool ConfigureGnssAssisted( const uint8_t* buffer, const uint16_t buffer_size ); bool ConfigureGnss( demo_gnss_settings_t* gnss_setting, const uint8_t* buffer, const uint16_t buffer_size ); + static demo_wifi_mode_t wifi_mode_from_value( const uint8_t& value ); + static demo_wifi_signal_type_scan_t wifi_signal_type_scan_from_val( const uint8_t& val ); + private: - CommandBaseDemoId_t demo_id_to_start; - demo_all_settings_t demo_settings; - Demo& demo_holder; + CommandBaseDemoId_t demo_id_to_start; + demo_all_settings_t demo_settings; + DemoManagerInterface& demo_holder; }; #endif // __COMMAND_START_DEMO_H__ diff --git a/embedded/hci/Command/Inc/command_update_almanac.h b/embedded/hci/Command/Inc/command_update_almanac.h index b84a903..a505bd4 100644 --- a/embedded/hci/Command/Inc/command_update_almanac.h +++ b/embedded/hci/Command/Inc/command_update_almanac.h @@ -40,7 +40,7 @@ class CommandUpdateAlmanac : public CommandBase { public: - CommandUpdateAlmanac( DeviceBase* device, Hci& hci ); + CommandUpdateAlmanac( DeviceInterface* device, Hci& hci ); virtual ~CommandUpdateAlmanac( ); virtual uint16_t GetComCode( ); diff --git a/embedded/hci/Command/Src/command_base.cpp b/embedded/hci/Command/Src/command_base.cpp index 9208863..002b082 100644 --- a/embedded/hci/Command/Src/command_base.cpp +++ b/embedded/hci/Command/Src/command_base.cpp @@ -31,7 +31,9 @@ #include "command_base.h" -CommandBase::CommandBase( DeviceBase* device, Hci& hci ) : device( device ), hci( &hci ), event( COMMAND_NO_EVENT ) {} +CommandBase::CommandBase( DeviceInterface* device, Hci& hci ) : device( device ), hci( &hci ), event( COMMAND_NO_EVENT ) +{ +} CommandBase::~CommandBase( ) {} diff --git a/embedded/hci/Command/Src/command_check_almanac_update.cpp b/embedded/hci/Command/Src/command_check_almanac_update.cpp index 67a4837..ef94349 100644 --- a/embedded/hci/Command/Src/command_check_almanac_update.cpp +++ b/embedded/hci/Command/Src/command_check_almanac_update.cpp @@ -34,7 +34,7 @@ #define COMMAND_CHECK_ALMANAC_UPDATE_BUFFER_SIZE ( 4 ) -CommandCheckAlmanacUpdate::CommandCheckAlmanacUpdate( DeviceBase* device, Hci& hci ) +CommandCheckAlmanacUpdate::CommandCheckAlmanacUpdate( DeviceInterface* device, Hci& hci ) : CommandBase( device, hci ), expected_crc( 0 ) { } diff --git a/embedded/hci/Command/Src/command_fetch_result.cpp b/embedded/hci/Command/Src/command_fetch_result.cpp index 112c277..cf0ba06 100644 --- a/embedded/hci/Command/Src/command_fetch_result.cpp +++ b/embedded/hci/Command/Src/command_fetch_result.cpp @@ -37,7 +37,7 @@ // later on #include "stm32l4xx_ll_utils.h" -CommandFetchResult::CommandFetchResult( Hci& hci, EnvironmentInterface& environment, Demo& demo_holder ) +CommandFetchResult::CommandFetchResult( Hci& hci, EnvironmentInterface& environment, DemoManagerInterface& demo_holder ) : hci( hci ), environment( environment ), demo_holder( demo_holder ) { } @@ -206,6 +206,11 @@ uint8_t CommandFetchResult::ConvertWifiTypeToSerial( const demo_wifi_signal_type } case DEMO_WIFI_TYPE_G: + { + value = 2; + break; + } + case DEMO_WIFI_TYPE_N: { value = 2; diff --git a/embedded/hci/Command/Src/command_get_almanac_dates.cpp b/embedded/hci/Command/Src/command_get_almanac_dates.cpp index 424c769..8125753 100644 --- a/embedded/hci/Command/Src/command_get_almanac_dates.cpp +++ b/embedded/hci/Command/Src/command_get_almanac_dates.cpp @@ -31,13 +31,13 @@ #include "command_get_almanac_dates.h" #include "com_code.h" -#include "demo.h" +#include "demo_manager_interface.h" #include #define N_SATELLITES ( 128 ) #define ALMANAC_DATES_STRING_MAX_LEN ( 3 * N_SATELLITES ) -CommandGetAlmanacDates::CommandGetAlmanacDates( DeviceBase* device, Hci& hci ) : hci( &hci ), device( device ) {} +CommandGetAlmanacDates::CommandGetAlmanacDates( DeviceInterface* device, Hci& hci ) : hci( &hci ), device( device ) {} CommandGetAlmanacDates::~CommandGetAlmanacDates( ) {} diff --git a/embedded/hci/Command/Src/command_get_version.cpp b/embedded/hci/Command/Src/command_get_version.cpp index 3427642..fbdf4c7 100644 --- a/embedded/hci/Command/Src/command_get_version.cpp +++ b/embedded/hci/Command/Src/command_get_version.cpp @@ -32,7 +32,7 @@ #include "command_get_version.h" #include "com_code.h" #include "version.h" -#include "demo.h" +#include "demo_manager_interface.h" #include #define VERSION_STRING_MAX_LEN 272 @@ -57,16 +57,41 @@ bool CommandGetVersion::ConfigureFromPayload( const uint8_t* buffer, const uint1 CommandEvent_t CommandGetVersion::Execute( ) { - char buffer_response[VERSION_STRING_MAX_LEN] = { 0 }; + char buffer_response[VERSION_STRING_MAX_LEN] = { 0 }; + uint8_t buffer_len; - const uint8_t buffer_len = - snprintf( buffer_response, VERSION_STRING_MAX_LEN, - "%s;%s;0x%02x;0x%02x;0x%04x;0x%04x;%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x", - version_handler->version_sw, version_handler->version_driver, version_handler->version_chip_hw, - version_handler->version_chip_type, version_handler->version_chip_fw, version_handler->almanac_crc, - version_handler->chip_uid[0], version_handler->chip_uid[1], version_handler->chip_uid[2], - version_handler->chip_uid[3], version_handler->chip_uid[4], version_handler->chip_uid[5], - version_handler->chip_uid[6], version_handler->chip_uid[7] ); + switch( version_handler->device_type ) + { + case VERSION_DEVICE_TRANSCEIVER: + { + buffer_len = snprintf( + buffer_response, VERSION_STRING_MAX_LEN, + "%s;%s;0x%02x;0x%02x;0x%04x;0x%04x;%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x", version_handler->version_sw, + version_handler->version_driver, version_handler->transceiver.version_chip_hw, + version_handler->transceiver.version_chip_type, version_handler->transceiver.version_chip_fw, + version_handler->almanac_crc, version_handler->chip_uid[0], version_handler->chip_uid[1], + version_handler->chip_uid[2], version_handler->chip_uid[3], version_handler->chip_uid[4], + version_handler->chip_uid[5], version_handler->chip_uid[6], version_handler->chip_uid[7] ); + break; + } + case VERSION_DEVICE_MODEM: + { + buffer_len = snprintf( buffer_response, VERSION_STRING_MAX_LEN, + "%s;%s;0x%08x;0x%02x;0x%06x;0x%04x;%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x", + version_handler->version_sw, version_handler->version_driver, + version_handler->modem.version_chip_bootloader, version_handler->modem.version_chip_type, + version_handler->modem.version_chip_fw, version_handler->almanac_crc, + version_handler->chip_uid[0], version_handler->chip_uid[1], version_handler->chip_uid[2], + version_handler->chip_uid[3], version_handler->chip_uid[4], version_handler->chip_uid[5], + version_handler->chip_uid[6], version_handler->chip_uid[7] ); + break; + } + default: + { + buffer_len = 0; + break; + } + } this->hci->SendResponse( this->GetComCode( ), ( uint8_t* ) buffer_response, buffer_len ); diff --git a/embedded/hci/Command/Src/command_reset.cpp b/embedded/hci/Command/Src/command_reset.cpp index c1a253f..13f5fa7 100644 --- a/embedded/hci/Command/Src/command_reset.cpp +++ b/embedded/hci/Command/Src/command_reset.cpp @@ -32,7 +32,7 @@ #include "command_reset.h" #include "com_code.h" -CommandReset::CommandReset( DeviceBase* device, Hci& hci ) : CommandBase( device, hci ) {} +CommandReset::CommandReset( DeviceInterface* device, Hci& hci ) : CommandBase( device, hci ) {} CommandReset::~CommandReset( ) {} diff --git a/embedded/hci/Command/Src/command_set_date_loc.cpp b/embedded/hci/Command/Src/command_set_date_loc.cpp index 8671cff..3c76fa4 100644 --- a/embedded/hci/Command/Src/command_set_date_loc.cpp +++ b/embedded/hci/Command/Src/command_set_date_loc.cpp @@ -33,7 +33,7 @@ #include "com_code.h" #include "lr1110_gnss_types.h" -CommandSetDateLoc::CommandSetDateLoc( DeviceBase* device, Hci& hci, EnvironmentInterface& environment ) +CommandSetDateLoc::CommandSetDateLoc( DeviceInterface* device, Hci& hci, EnvironmentInterface& environment ) : CommandBase( device, hci ), environment( environment ) { } diff --git a/embedded/hci/Command/Src/command_start_demo.cpp b/embedded/hci/Command/Src/command_start_demo.cpp index d273c2f..a673e20 100644 --- a/embedded/hci/Command/Src/command_start_demo.cpp +++ b/embedded/hci/Command/Src/command_start_demo.cpp @@ -32,7 +32,7 @@ #include "command_start_demo.h" #include "com_code.h" -CommandStartDemo::CommandStartDemo( DeviceBase* device, Hci& hci, Demo& demo_holder ) +CommandStartDemo::CommandStartDemo( DeviceInterface* device, Hci& hci, DemoManagerInterface& demo_holder ) : CommandBase( device, hci ), demo_id_to_start( COMMAND_BASE_NO_DEMO ), demo_holder( demo_holder ) { this->demo_settings.wifi_settings.channels = DEMO_WIFI_CHANNELS_DEFAULT >> 1; @@ -115,15 +115,15 @@ bool CommandStartDemo::ConfigureWifiScan( const uint8_t* buffer, const uint16_t bool success = false; if( buffer_size == 8 ) { - const uint16_t wifi_channel_mask = buffer[0] + buffer[1] * 256; - const uint8_t wifi_type_mask = buffer[2]; - const uint8_t wifi_nbr_retrials = buffer[3]; - const uint8_t wifi_max_results = buffer[4]; - const uint16_t wifi_timeout_ms = buffer[5] + ( buffer[6] * 256 ); - const lr1110_wifi_mode_t wifi_mode = ( lr1110_wifi_mode_t ) buffer[7]; + const uint16_t wifi_channel_mask = buffer[0] + buffer[1] * 256; + const uint8_t wifi_type_mask = buffer[2]; + const uint8_t wifi_nbr_retrials = buffer[3]; + const uint8_t wifi_max_results = buffer[4]; + const uint16_t wifi_timeout_ms = buffer[5] + ( buffer[6] * 256 ); + const demo_wifi_mode_t wifi_mode = CommandStartDemo::wifi_mode_from_value( buffer[7] ); - this->demo_settings.wifi_settings.channels = ( lr1110_wifi_channel_mask_t ) wifi_channel_mask; - this->demo_settings.wifi_settings.types = ( lr1110_wifi_signal_type_scan_t ) wifi_type_mask; + this->demo_settings.wifi_settings.channels = ( demo_wifi_channel_mask_t ) wifi_channel_mask; + this->demo_settings.wifi_settings.types = CommandStartDemo::wifi_signal_type_scan_from_val( wifi_type_mask ); this->demo_settings.wifi_settings.scan_mode = wifi_mode; this->demo_settings.wifi_settings.nbr_retrials = wifi_nbr_retrials; this->demo_settings.wifi_settings.max_results = wifi_max_results; @@ -188,10 +188,10 @@ bool CommandStartDemo::ConfigureGnss( demo_gnss_settings_t* gnss_setting, const // Check option value switch( gnss_option ) { - case LR1110_GNSS_OPTION_DEFAULT: - case LR1110_GNSS_OPTION_BEST_EFFORT: + case DEMO_GNSS_OPTION_DEFAULT: + case DEMO_GNSS_OPTION_BEST_EFFORT: { - gnss_setting->option = ( lr1110_gnss_search_mode_t ) gnss_option; + gnss_setting->option = ( demo_gnss_search_mode_t ) gnss_option; break; } default: @@ -201,10 +201,10 @@ bool CommandStartDemo::ConfigureGnss( demo_gnss_settings_t* gnss_setting, const // Check capture mode value switch( gnss_capture_mode ) { - case LR1110_GNSS_SINGLE_SCAN_MODE: - case LR1110_GNSS_DOUBLE_SCAN_MODE: + case DEMO_GNSS_SINGLE_SCAN_MODE: + case DEMO_GNSS_DOUBLE_SCAN_MODE: { - gnss_setting->capture_mode = ( lr1110_gnss_scan_mode_t ) gnss_capture_mode; + gnss_setting->capture_mode = ( demo_gnss_scan_mode_t ) gnss_capture_mode; break; } default: @@ -222,34 +222,90 @@ bool CommandStartDemo::ConfigureGnss( demo_gnss_settings_t* gnss_setting, const return success; } +demo_wifi_mode_t CommandStartDemo::wifi_mode_from_value( const uint8_t& value ) +{ + demo_wifi_mode_t wifi_mode = DEMO_WIFI_SCAN_MODE_BEACON; + switch( value ) + { + case 1: + { + wifi_mode = DEMO_WIFI_SCAN_MODE_BEACON; + break; + } + + case 2: + { + wifi_mode = DEMO_WIFI_SCAN_MODE_BEACON_AND_PACKET; + break; + } + } + return wifi_mode; +} + +demo_wifi_signal_type_scan_t CommandStartDemo::wifi_signal_type_scan_from_val( const uint8_t& val ) +{ + demo_wifi_signal_type_scan_t wifi_type = DEMO_WIFI_SETTING_TYPE_B; + switch( val ) + { + case 1: + { + wifi_type = DEMO_WIFI_SETTING_TYPE_B; + break; + } + case 2: + { + wifi_type = DEMO_WIFI_SETTING_TYPE_G; + break; + } + case 3: + { + wifi_type = DEMO_WIFI_SETTING_TYPE_B_G_N; + break; + } + } + return wifi_type; +} + bool CommandStartDemo::Job( ) { + bool success = false; switch( this->demo_id_to_start ) { case COMMAND_BASE_DEMO_WIFI_SCAN: { this->demo_holder.UpdateConfigWifiScan( &this->demo_settings.wifi_settings ); + success = true; break; } case COMMAND_BASE_DEMO_WIFI_COUNTRY_CODE: { this->demo_holder.UpdateConfigWifiCountryCode( &this->demo_settings.wifi_country_code_settings ); + success = true; break; } case COMMAND_BASE_DEMO_GNSS_AUTONOMOUS: { this->demo_holder.UpdateConfigAutonomousGnss( &this->demo_settings.gnss_autonomous_settings ); + success = true; break; } case COMMAND_BASE_DEMO_GNSS_ASSISTED: { this->demo_holder.UpdateConfigAssistedGnss( &this->demo_settings.gnss_assisted_settings ); + success = true; + break; + } + default: + { + // The demo id to start is unknown. Reset it to NO_DEMO and indicate failure of the job + this->demo_id_to_start = COMMAND_BASE_NO_DEMO; + success = false; break; } } this->SetEventStartDemo( this->demo_id_to_start ); - return true; + return success; } \ No newline at end of file diff --git a/embedded/hci/Command/Src/command_update_almanac.cpp b/embedded/hci/Command/Src/command_update_almanac.cpp index 4a33fa0..3556ace 100644 --- a/embedded/hci/Command/Src/command_update_almanac.cpp +++ b/embedded/hci/Command/Src/command_update_almanac.cpp @@ -32,7 +32,7 @@ #include "command_update_almanac.h" #include "com_code.h" -CommandUpdateAlmanac::CommandUpdateAlmanac( DeviceBase* device, Hci& hci ) : CommandBase( device, hci ) +CommandUpdateAlmanac::CommandUpdateAlmanac( DeviceInterface* device, Hci& hci ) : CommandBase( device, hci ) { for( uint16_t index_buffer = 0; index_buffer < COMMAND_UPDATE_ALMANAC_BUFFER_SIZE; index_buffer++ ) { diff --git a/embedded/keil/RTE/_stm32l476rg/RTE_Components.h b/embedded/keil/RTE/_stm32l476rg/RTE_Components.h deleted file mode 100644 index e3fc2c6..0000000 --- a/embedded/keil/RTE/_stm32l476rg/RTE_Components.h +++ /dev/null @@ -1,24 +0,0 @@ - -/* - * Auto generated Run-Time-Environment Configuration File - * *** Do not modify ! *** - * - * Project: 'lr1110_evk' - * Target: 'stm32l476rg' - */ - -#ifndef RTE_COMPONENTS_H -#define RTE_COMPONENTS_H - - -/* - * Define the Device Header File: - */ -#define CMSIS_device_header "stm32l4xx.h" - -/* Keil.ARM Compiler::Compiler:I/O:STDOUT:User:1.2.0 */ -#define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */ - #define RTE_Compiler_IO_STDOUT_User /* Compiler I/O: STDOUT User */ - - -#endif /* RTE_COMPONENTS_H */ diff --git a/embedded/keil/lr1110_evk.uvprojx b/embedded/keil/lr1110_evk.uvprojx index 38a71f0..b1c143f 100644 --- a/embedded/keil/lr1110_evk.uvprojx +++ b/embedded/keil/lr1110_evk.uvprojx @@ -10,7 +10,7 @@ stm32l476rg 0x4 ARM-ADS - 6120000::V6.12::.\ARMCLANG + 6140000::V6.14::ARMCLANG 1 @@ -185,6 +185,7 @@ 0 2 0 + 0 1 0 8 @@ -333,12 +334,12 @@ 1 0 0 - 0 + 1 -Wno-deprecated-register USE_FULL_LL_DRIVER, LV_CONF_INCLUDE_SIMPLE - ..\lr1110_driver\src;..\STM32L4xx_HAL_Driver\Inc;..\STM32L4xx_HAL_Driver\Inc\Legacy;..\CMSIS\Core\Include;..\CMSIS\Device\ST\STM32L4xx\Include;..\application\inc;..\system\inc;..\gui\inc;..\display_touch\inc;..\supervisor\inc;..\communication\inc;..\demo\inc;..\hci\Command\Inc;..\hci;..\lvgl;..\lvgl\src;..\lvgl\src\lv_core;..\lvgl\src\lv_draw;..\lvgl\src\lv_font;..\lvgl\src\lv_hal;..\lvgl\src\lv_misc;..\lvgl\src\lv_objx;..\lvgl\src\lv_themes + ..\lr1110_driver\src;..\STM32L4xx_HAL_Driver\Inc;..\STM32L4xx_HAL_Driver\Inc\Legacy;..\CMSIS\Core\Include;..\CMSIS\Device\ST\STM32L4xx\Include;..\application\inc;..\system\inc;..\gui\inc;..\display_touch\inc;..\supervisor\inc;..\demo\inc;..\hci\Command\Inc;..\hci;..\lvgl;..\lvgl\src;..\lvgl\src\lv_core;..\lvgl\src\lv_draw;..\lvgl\src\lv_font;..\lvgl\src\lv_hal;..\lvgl\src\lv_misc;..\lvgl\src\lv_objx;..\lvgl\src\lv_themes;..\communication\inc;..\lr1110_modem_driver\src;..\connectivity\inc;..\device\inc @@ -351,7 +352,7 @@ 0 0 0 - 0 + 4 @@ -397,6 +398,11 @@ 8 ..\application\src\timer_interface_implementation.cpp + + lr1110_modem_hal.c + 1 + ..\application\src\lr1110_modem_hal.c + @@ -692,40 +698,55 @@ 8 ..\gui\src\guiMenuCommon.cpp + + guiEui.cpp + 8 + ..\gui\src\guiEui.cpp + + + guiConnectivity.cpp + 8 + ..\gui\src\guiConnectivity.cpp + + + guiConfigGnssAssistancePosition.cpp + 8 + ..\gui\src\guiConfigGnssAssistancePosition.cpp + communication - communication_demo.cpp + communication_utils.cpp 8 - ..\communication\src\communication_demo.cpp + ..\communication\src\communication_utils.cpp - communication_field_test.cpp + communication_print_only.cpp 8 - ..\communication\src\communication_field_test.cpp + ..\communication\src\communication_print_only.cpp - communication_interface.cpp + communication_manager.cpp 8 - ..\communication\src\communication_interface.cpp + ..\communication\src\communication_manager.cpp - communication_manager.cpp + communication_interface.cpp 8 - ..\communication\src\communication_manager.cpp + ..\communication\src\communication_interface.cpp - communication_print_only.cpp + communication_field_test.cpp 8 - ..\communication\src\communication_print_only.cpp + ..\communication\src\communication_field_test.cpp - communication_utils.cpp + communication_demo.cpp 8 - ..\communication\src\communication_utils.cpp + ..\communication\src\communication_demo.cpp @@ -743,89 +764,139 @@ demo - demo_base.cpp + demo_manager_interface.cpp 8 - ..\demo\src\demo_base.cpp + ..\demo\src\demo_manager_interface.cpp - demo.cpp + demo_transceiver_gnss_autonomous.cpp 8 - ..\demo\src\demo.cpp + ..\demo\src\demo_transceiver_gnss_autonomous.cpp - demo_gnss_autonomous.cpp + demo_transceiver_gnss_assisted.cpp 8 - ..\demo\src\demo_gnss_autonomous.cpp + ..\demo\src\demo_transceiver_gnss_assisted.cpp - demo_gnss_assisted.cpp + environment_interface.cpp 8 - ..\demo\src\demo_gnss_assisted.cpp + ..\demo\src\environment_interface.cpp - demo_gnss_base.cpp + demo_transceiver_wifi_interface.cpp 8 - ..\demo\src\demo_gnss_base.cpp + ..\demo\src\demo_transceiver_wifi_interface.cpp - environment_interface.cpp + demo_transceiver_wifi_country_code.cpp 8 - ..\demo\src\environment_interface.cpp + ..\demo\src\demo_transceiver_wifi_country_code.cpp - demo_wifi_interface.cpp + demo_transceiver_wifi_scan.cpp 8 - ..\demo\src\demo_wifi_interface.cpp + ..\demo\src\demo_transceiver_wifi_scan.cpp - demo_wifi_country_code.cpp + demo_transceiver_radio_tx_cw.cpp 8 - ..\demo\src\demo_wifi_country_code.cpp + ..\demo\src\demo_transceiver_radio_tx_cw.cpp - demo_wifi_scan.cpp + demo_transceiver_radio_ping_pong.cpp 8 - ..\demo\src\demo_wifi_scan.cpp + ..\demo\src\demo_transceiver_radio_ping_pong.cpp - demo_tx_cw.cpp + demo_transceiver_radio_per.cpp 8 - ..\demo\src\demo_tx_cw.cpp + ..\demo\src\demo_transceiver_radio_per.cpp - demo_ping_pong.cpp + demo_transceiver_radio_interface.cpp 8 - ..\demo\src\demo_ping_pong.cpp + ..\demo\src\demo_transceiver_radio_interface.cpp - demo_radio_per.cpp + demo_interface.cpp 8 - ..\demo\src\demo_radio_per.cpp + ..\demo\src\demo_interface.cpp - demo_radio_interface.cpp + demo_transceiver_gnss_interface.cpp 8 - ..\demo\src\demo_radio_interface.cpp + ..\demo\src\demo_transceiver_gnss_interface.cpp - device_transceiver.cpp + demo_transceiver_interface.cpp + 8 + ..\demo\src\demo_transceiver_interface.cpp + + + demo_manager_transceiver.cpp + 8 + ..\demo\src\demo_manager_transceiver.cpp + + + interruption_irq.cpp + 8 + ..\demo\src\interruption_irq.cpp + + + interruption_modem.cpp 8 - ..\demo\src\device_transceiver.cpp + ..\demo\src\interruption_modem.cpp - demo_transceiver_base.cpp + demo_manager_modem.cpp 8 - ..\demo\src\demo_transceiver_base.cpp + ..\demo\src\demo_manager_modem.cpp - device_base.cpp + demo_modem_gnss_assisted.cpp 8 - ..\demo\src\device_base.cpp + ..\demo\src\demo_modem_gnss_assisted.cpp - demo_wifi_types.cpp + demo_modem_gnss_autonomous.cpp 8 - ..\demo\src\demo_wifi_types.cpp + ..\demo\src\demo_modem_gnss_autonomous.cpp + + + demo_modem_gnss_interface.cpp + 8 + ..\demo\src\demo_modem_gnss_interface.cpp + + + demo_modem_interface.cpp + 8 + ..\demo\src\demo_modem_interface.cpp + + + demo_modem_wifi.cpp + 8 + ..\demo\src\demo_modem_wifi.cpp + + + demo_modem_radio_converters.cpp + 8 + ..\demo\src\demo_modem_radio_converters.cpp + + + demo_modem_radio_rx_continuous.cpp + 8 + ..\demo\src\demo_modem_radio_rx_continuous.cpp + + + demo_modem_radio_tx_continuous.cpp + 8 + ..\demo\src\demo_modem_radio_tx_continuous.cpp + + + demo_modem_radio_tx_cw.cpp + 8 + ..\demo\src\demo_modem_radio_tx_cw.cpp @@ -1354,6 +1425,81 @@ + + device + + + device_transceiver.cpp + 8 + ..\device\src\device_transceiver.cpp + + + device_interface.cpp + 8 + ..\device\src\device_interface.cpp + + + device_modem.cpp + 8 + ..\device\src\device_modem.cpp + + + + + lr1110_modem_driver + + + lr1110_modem_driver_version.c + 1 + ..\lr1110_modem_driver\src\lr1110_modem_driver_version.c + + + lr1110_modem_gnss.c + 1 + ..\lr1110_modem_driver\src\lr1110_modem_gnss.c + + + lr1110_modem_lorawan.c + 1 + ..\lr1110_modem_driver\src\lr1110_modem_lorawan.c + + + lr1110_modem_system.c + 1 + ..\lr1110_modem_driver\src\lr1110_modem_system.c + + + lr1110_modem_wifi.c + 1 + ..\lr1110_modem_driver\src\lr1110_modem_wifi.c + + + + + connectivity_manager + + + connectivity_manager_interface.cpp + 8 + ..\connectivity\src\connectivity_manager_interface.cpp + + + connectivity_manager_modem.cpp + 8 + ..\connectivity\src\connectivity_manager_modem.cpp + + + connectivity_conversions.cpp + 8 + ..\connectivity\src\connectivity_conversions.cpp + + + connectivity_manager_transceiver.cpp + 8 + ..\connectivity\src\connectivity_manager_transceiver.cpp + + + ::Compiler @@ -1374,4 +1520,19 @@ + + + + <Project Info> + + + + + + 0 + 1 + + + + diff --git a/embedded/lr1110_driver/CHANGELOG.md b/embedded/lr1110_driver/CHANGELOG.md new file mode 100644 index 0000000..9f4bb8a --- /dev/null +++ b/embedded/lr1110_driver/CHANGELOG.md @@ -0,0 +1,214 @@ +# LR1110 driver changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v3.0.0] 2020-10-12 + +### Added + +* [bootloader] `lr1110_bootloader_read_chip_eui` function +* [bootloader] `lr1110_bootloader_read_join_eui` function +* [bootloader] `LR1110_BL_CHIP_EUI_LENGTH` constant +* [bootloader] `LR1110_BL_JOIN_EUI_LENGTH` constant +* [bootloader] `lr1110_bootloader_chip_eui_t` type definition +* [bootloader] `lr1110_bootloader_join_eui_t` type definition +* [GNSS] `lr1110_gnss_get_context_status` function +* [GNSS] `lr1110_gnss_parse_context_status_buffer` function +* [GNSS] `LR1110_GNSS_CONTEXT_STATUS_LENGTH` constant +* [GNSS] `lr1110_gnss_error_code_t` type definition +* [GNSS] `lr1110_gnss_freq_search_space_t` type definition +* [GNSS] `lr1110_gnss_context_status_bytestream_t` type definition +* [GNSS] `lr1110_gnss_context_status_t` type definition +* [radio] `lr1110_radio_set_rx_with_timeout_in_rtc_step` and `lr1110_radio_set_tx_with_timeout_in_rtc_step` functions +* [radio] `lr1110_radio_set_rx_duty_cycle_with_timings_in_rtc_step` function +* [radio] `lr1110_radio_convert_time_in_ms_to_rtc_step` function +* [system] `lr1110_system_wakeup` function +* [system] `lr1110_system_read_pin_custom_eui` function +* [system] `reset_status` field to `lr1110_system_stat2_t` +* [Wi-Fi] `lr1110_wifi_scan_time_limit` function +* [Wi-Fi] `lr1110_wifi_search_country_code_time_limit` function +* [Wi-Fi] `lr1110_wifi_read_extended_full_results` function +* [Wi-Fi] `LR1110_WIFI_CHANNEL_*_POS` and `LR1110_WIFI_CHANNEL_*_MASK` constants +* [Wi-Fi] `LR1110_WIFI_SCAN_MODE_FULL_BEACON` entry in `lr1110_wifi_mode_t` +* [Wi-Fi] `lr1110_wifi_extended_full_result_t` type definition +* [Wi-Fi] `LR1110_WIFI_RESULT_FORMAT_EXTENDED_FULL` entry in `lr1110_wifi_result_format_t` + +### Changed + +* [crypto] `LR1110_CRYPTO_COMPUTE_AES_CMAC_CMD_LENGTH` is now equal to ( 2 + 1 + 272 ) +* [GNSS] `LR1110_GNSS_FULL_ALMANAC_UPDATE_PACKET_LENGTH` is renamed `LR1110_GNSS_FULL_ALMANAC_UPDATE_PKT_LENGTH` +* [GNSS] `lr1110_gnss_scan_autonomous` takes also `effort_mode` as input parameter +* [radio] Implementation of time-on-air computation for LoRa modulation +* [radio] `lr1110_radio_set_lora_sync_word` takes a sync word as parameter instead of a network type +* [radio] `lr1110_radio_set_rx` and `lr1110_radio_set_tx` take a timeout parameter in millisecond instead of RTC step +* [radio] `lr1110_radio_set_rx_duty_cycle` takes a timeout parameter in millisecond instead of RTC step +* [radio] `LR1110_RADIO_PACKET_NONE` is renamed `LR1110_RADIO_PKT_NONE` +* [radio] `LR1110_RADIO_PA_REG_SUPPLY_DCDC` is renamed `LR1110_RADIO_PA_REG_SUPPLY_VREG` +* [radio] `lr1110_radio_pa_regulator_supply_t` is renamed `lr1110_radio_pa_reg_supply_t` +* [radio] `*_packet_*` is renamed `*_pkt_*` in `lr1110_radio_pkt_status_lora_t` +* [radio] `nb_packet_falsesync` is renamed `nb_pkt_falsesync` in `lr1110_radio_stats_lora_t` +* [Wi-Fi] `lr1110_extract_channel_info` is renamed `lr1110_wifi_parse_channel_info` +* [Wi-Fi] `lr1110_extract_channel_from_info_byte` is renamed `lr1110_wifi_extract_channel_from_info_byte` +* [Wi-Fi] `lr1110_extract_frame_type_info` is renamed `lr1110_wifi_parse_frame_type_info` +* [Wi-Fi] `lr1110_extract_data_rate_info` is renamed `lr1110_wifi_parse_data_rate_info` +* [Wi-Fi] `lr1110_wifi_n_results_max_per_chunk` is renamed `lr1110_wifi_get_nb_results_max_per_chunk` +* [Wi-Fi] `lr1110_extract_signal_type_from_data_rate_info` is renamed `lr1110_wifi_extract_signal_type_from_data_rate_info` +* [Wi-Fi] `LR1110_WIFI_ORIGIN_PACKET` is renamed `LR1110_WIFI_ORIGIN_UNKNWON` +* [Wi-Fi] `LR1110_WIFI_SCAN_MODE_BEACON_AND_PACKET` is renamed `LR1110_WIFI_SCAN_MODE_BEACON_AND_PKT` + +### Fixed + +* [all] Harmonized doxygen markups +* [all] Harmonized license header +* [all] Removed extraneous underscore in constants used for multiple inclusion protection +* [GNSS] Inversion of `LR1110_GNSS_BIT_CHANGE_MASK` and `LR1110_GNSS_IRQ_PSEUDO_RANGE_MASK` definitions +* [radio] Power amplifier ramp time values in lr1110_radio_ramp_time_t +* [system] `chip_mode` read from `stat2` value + +## [v2.0.1] 2020-05-04 + +### Fixed + +* [version] Enable c linkage driver version related functions + +## [v2.0.0] 2020-04-27 + +### Added + +* [all] All functions declared in .h files now return a status. +* [common] `lr1110_status_t` type definition +* [bootloader] `lr1110_bootloader_fill_cbuffer_opcode_offset_flash` static function +* [bootloader] `lr1110_bootloader_fill_cdata_flash` static function +* [bootloader] `lr1110_bootloader_fill_cbuffer_cdata_flash` static function +* [regmem] `lr1110_regmem_fill_cbuffer_opcode_address` static function +* [regmem] `lr1110_regmem_fill_cbuffer_opcode_address_length` static function +* [regmem] `lr1110_regmem_fill_cdata` static function +* [regmem] `lr1110_regmem_fill_cbuffer_cdata_opcode_address_data` static function +* [regmem] `lr1110_regmem_fill_out_buffer_from_raw_buffer` static function +* [system] `LR1110_SYSTEM_VERSION_LENGTH` constant +* [system] `lr1110_system_cal_mask_t` type definition +* [system] `lr1110_system_irq_mask_t` type definition +* [system] `lr1110_system_get_and_clear_irq_status` function +* [system] `lr1110_system_get_irq_status` function +* [crypto] `lr1110_crypto_fill_cbuffer_opcode_key_data` static function +* [GNSS] `lr1110_gnss_uint8_to_uint32` static function + +### Changed + +* [bootloader] `lr1110_bootloader_version_t` has now 3 fields: hardware, type, firmware +* [bootloader] `lr1110_bootloader_get_version` fills the updated `lr1110_bootloader_version_t` structure +* [system] `LR1110_SYSTEM_IRQ_NONE_MASK` is renamed `LR1110_SYSTEM_IRQ_NONE` +* [system] `LR1110_SYSTEM_IRQ_TXDONE_MASK` is renamed `LR1110_SYSTEM_IRQ_TX_DONE` +* [system] `LR1110_SYSTEM_IRQ_RXDONE_MASK` is renamed `LR1110_SYSTEM_IRQ_RX_DONE` +* [system] `LR1110_SYSTEM_IRQ_PREAMBLEDETECTED_MASK` is renamed `LR1110_SYSTEM_IRQ_PREAMBLE_DETECTED` +* [system] `LR1110_SYSTEM_IRQ_SYNCWORD_HEADERVALID_MASK` is renamed `LR1110_SYSTEM_IRQ_SYNC_WORD_HEADER_VALID` +* [system] `LR1110_SYSTEM_IRQ_HEADERERR_MASK` is renamed `LR1110_SYSTEM_IRQ_HEADER_ERROR` +* [system] `LR1110_SYSTEM_IRQ_CRCERR_MASK` is renamed `LR1110_SYSTEM_IRQ_CRC_ERROR` +* [system] `LR1110_SYSTEM_IRQ_CADDONE_MASK` is renamed `LR1110_SYSTEM_IRQ_CAD_DONE` +* [system] `LR1110_SYSTEM_IRQ_CADDETECTED_MASK` is renamed `LR1110_SYSTEM_IRQ_CAD_DETECTED` +* [system] `LR1110_SYSTEM_IRQ_TIMEOUT_MASK` is renamed `LR1110_SYSTEM_IRQ_TIMEOUT` +* [system] `LR1110_SYSTEM_IRQ_GNSSSCANDONE_MASK` is renamed `LR1110_SYSTEM_IRQ_GNSS_SCAN_DONE` +* [system] `LR1110_SYSTEM_IRQ_WIFISCANDONE_MASK` is renamed `LR1110_SYSTEM_IRQ_WIFI_SCAN_DONE` +* [system] `LR1110_SYSTEM_IRQ_EOL_MASK` is renamed `LR1110_SYSTEM_IRQ_EOL` +* [system] `LR1110_SYSTEM_IRQ_CMDERR_MASK` is renamed `LR1110_SYSTEM_IRQ_CMD_ERROR` +* [system] `LR1110_SYSTEM_IRQ_ERR_MASK` is renamed `LR1110_SYSTEM_IRQ_ERROR` +* [system] `LR1110_SYSTEM_IRQ_FSK_LENGTH_ERROR_MASK` is renamed `LR1110_SYSTEM_IRQ_FSK_LEN_ERROR` +* [system] `LR1110_SYSTEM_IRQ_FSK_ADDRESS_ERROR_MASK` is renamed `LR1110_SYSTEM_IRQ_FSK_ADDR_ERROR` +* [system] `LR1110_SYSTEM_CALIBRATE_*_MASK` are renamed `LR1110_SYSTEM_CALIB_*_MASK` +* [system] `lr1110_system_chip_mode_t` is renamed `lr1110_system_chip_modes_t` +* [system] In `lr1110_system_chip_modes_t`, `LR1110_SYSTEM_CHIP_MODE_RC` is renamed `LR1110_SYSTEM_CHIP_MODE_STBY_RC` +* [system] In `lr1110_system_chip_modes_t`, `LR1110_SYSTEM_CHIP_MODE_XOSC` is renamed `LR1110_SYSTEM_CHIP_MODE_STBY_XOSC` +* [system] `lr1110_system_lfclk_config_t` is renamed `lr1110_system_lfclk_cfg_t` +* [system] `lr1110_regmodes_t` is renamed `lr1110_system_reg_mode_t` +* [system] `LR1110_SYSTEM_REGMODE_NO_DCDC` is renamed `LR1110_SYSTEM_REG_MODE_LDO` +* [system] `LR1110_SYSTEM_REGMODE_DCDC_CONVERTER` is renamed `LR1110_SYSTEM_REG_MODE_DCDC` +* [system] `lr1110_system_rfswitch_config_t` is renamed `lr1110_system_rfswitch_cfg_t` +* [system] `lr1110_system_standby_config_t` is renamed `lr1110_system_standby_cfg_t` +* [system] `LR1110_SYSTEM_STDBY_CONFIG_*` are renamed `LR1110_SYSTEM_STANDBY_CFG_*` +* [system] `LR1110_SYSTEM_TCXO_SUPPLY_VOLTAGE_*V` are renamed `LR1110_SYSTEM_TCXO_CTRL_*V` +* [system] `lr1110_system_sleep_config_t` is renamed `lr1110_system_sleep_cfg_t` +* [system] `lr1110_system_set_regmode` is renamed `lr1110_system_set_reg_mode` +* [system] `lr1110_system_config_lfclk` is renamed `lr1110_system_cfg_lfclk` +* [system] `lr1110_system_clear_irq` is renamed `lr1110_system_clear_irq_status` +* [crypto] `lr1110_crypto_derive_and_store_key` is renamed `lr1110_crypto_derive_key` +* [crypto] `LR1110_CRYPTO_DERIVE_AND_STORE_KEY_OC` is renamed `LR1110_CRYPTO_DERIVE_KEY_OC` +* [crypto] `LR1110_CRYPTO_DERIVE_AND_STORE_KEY_CMD_LENGTH` is renamed `LR1110_CRYPTO_DERIVE_KEY_CMD_LENGTH` +* [radio] `lr1110_radio_rx_tx_fallback_mode_t` is renamed `lr1110_radio_fallback_modes_t` +* [radio] `LR1110_RADIO_RX_TX_FALLBACK_MODE_*` are renamed `LR1110_RADIO_FALLBACK_*` +* [radio] `LR1110_RADIO_RAMP_TIME_*` are renamed `LR1110_RADIO_RAMP_*` +* [radio] `LR1110_RADIO_LORA_BW*` are renamed `LR1110_RADIO_LORA_BW_*` +* [radio] `LR1110_RADIO_LORA_CRXY_LI` are renamed `LR1110_RADIO_LORA_CR_LI_X_Y` +* [radio] `LR1110_RADIO_LORA_CRXY` are renamed `LR1110_RADIO_LORA_CR_X_Y` +* [radio] `LR1110_RADIO_MODE_STANDBY*` are renamed `LR1110_RADIO_MODE_STANDBY_*` +* [radio] `LR1110_RADIO_GFSK_CRC_XBYTE` are renamed `LR1110_RADIO_GFSK_CRC_X_BYTE` +* [radio] `LR1110_RADIO_GFSK_CRC_XBYTES` are renamed `LR1110_RADIO_GFSK_CRC_X_BYTES` +* [radio] `LR1110_RADIO_GFSK_CRC_XBYTE_INV` are renamed `LR1110_RADIO_GFSK_CRC_X_BYTE_INV` +* [radio] `LR1110_RADIO_GFSK_CRC_XBYTES_INV` are renamed `LR1110_RADIO_GFSK_CRC_X_BYTES_INV` +* [radio] `LR1110_RADIO_GFSK_DCFREE_*` are renamed `LR1110_RADIO_GFSK_DC_FREE_*` +* [radio] `lr1110_radio_gfsk_header_type_t` is renamed `lr1110_radio_gfsk_pkt_len_modes_t` +* [radio] `LR1110_RADIO_GFSK_HEADER_TYPE_IMPLICIT` is renamed `LR1110_RADIO_GFSK_PKT_FIX_LEN` +* [radio] `LR1110_RADIO_GFSK_HEADER_TYPE_EXPLICIT` is renamed `LR1110_RADIO_GFSK_PKT_VAR_LEN` +* [radio] `lr1110_radio_gfsk_preamble_detect_length_t` is renamed `lr1110_radio_gfsk_preamble_detector_t` +* [radio] `LR1110_RADIO_GFSK_PREAMBLE_DETECTOR_LENGTH_*` are renamed `LR1110_RADIO_GFSK_PREAMBLE_DETECTOR_*` +* [radio] `lr1110_radio_lora_header_type_t` is renamed `lr1110_radio_lora_pkt_len_modes_t` +* [radio] `LR1110_RADIO_LORA_HEADER_*` are renamed `LR1110_RADIO_LORA_PKT_*` +* [radio] `lr1110_radio_packet_types_t` is renamed `lr1110_radio_pkt_type_t` +* [radio] `LR1110_RADIO_PACKET_*` are renamed `LR1110_RADIO_PKT_TYPE_*` +* [radio] `lr1110_radio_gfsk_rx_bw_t` is renamed `lr1110_radio_gfsk_bw_t` +* [radio] `LR1110_RADIO_GFSK_RX_BW_*` are renamed `LR1110_RADIO_GFSK_BW_*` +* [radio] `lr1110_radio_pulse_shape_t` is renamed `lr1110_radio_gfsk_pulse_shape_t` +* [radio] `LR1110_RADIO_PULSESHAPE_*` are renamed `LR1110_RADIO_GFSK_PULSE_SHAPE_*` +* [radio] In `lr1110_radio_cad_params_t`, `symbol_num` is renamed `cad_symb_nb` +* [radio] In `lr1110_radio_cad_params_t`, `det_peak` is renamed `cad_detect_peak` +* [radio] In `lr1110_radio_cad_params_t`, `det_min` is renamed `cad_detect_min` +* [radio] In `lr1110_radio_cad_params_t`, `exit_mode` is renamed `cad_exit_mode` +* [radio] In `lr1110_radio_cad_params_t`, `timeout` is renamed `cad_timeout` +* [radio] `lr1110_radio_packet_status_gfsk_t` is renamed `lr1110_radio_pkt_status_gfsk_t` +* [radio] In `lr1110_radio_pkt_status_gfsk_t`, `rx_length_in_bytes` is renamed `rx_len_in_bytes` +* [radio] `lr1110_radio_packet_status_lora_t` is renamed `lr1110_radio_pkt_status_lora_t` +* [radio] `lr1110_radio_rxbuffer_status_t` is renamed `lr1110_radio_rx_buffer_status_t` +* [radio] In `lr1110_radio_rx_buffer_status_t`, `rx_payload_length` is renamed `pld_len_in_bytes` +* [radio] In `lr1110_radio_rx_buffer_status_t`, `rx_start_buffer_pointer` is renamed `buffer_start_pointer` +* [radio] In `lr1110_radio_stats_gfsk_t`, `nb_packet_*` are renamed `nb_pkt_*` +* [radio] In `lr1110_radio_stats_lora_t`, `nb_packet_received` is renamed `nb_pkt_received` +* [radio] In `lr1110_radio_stats_lora_t`, `nb_packet_error_crc` is renamed `nb_pkt_error_crc` +* [radio] In `lr1110_radio_stats_lora_t`, `nb_packet_error_header` is renamed `nb_pkt_header_error` +* [radio] `lr1110_radio_modulation_param_*_t` are renamed `lr1110_radio_mod_params_*_t` +* [radio] In `lr1110_radio_mod_params_gfsk_t`, `bitrate` is renamed `br_in_bps` +* [radio] In `lr1110_radio_mod_params_gfsk_t`, `bandwidth` is renamed `bw_dsb_param` +* [radio] In `lr1110_radio_mod_params_gfsk_t`, `fdev` is renamed `fdev_in_hz` +* [radio] In `lr1110_radio_mod_params_lora_t`, `spreading_factor` is renamed `sf` +* [radio] In `lr1110_radio_mod_params_lora_t`, `coding_rate` is renamed `cr` +* [radio] In `lr1110_radio_mod_params_lora_t`, `ppm_offset` is renamed `ldro` +* [radio] `lr1110_radio_packet_param_*_t` are renamed `lr1110_radio_pkt_params_*_t` +* [radio] In `lr1110_radio_pkt_params_gfsk_t`, `preamble_length_tx_in_bit` is renamed `preamble_len_in_bits` +* [radio] In `lr1110_radio_pkt_params_gfsk_t`, `preamble_detect` is renamed `preamble_detector` +* [radio] In `lr1110_radio_pkt_params_gfsk_t`, `sync_word_length_in_bit` is renamed `sync_word_len_in_bits` +* [radio] In `lr1110_radio_pkt_params_gfsk_t`, `payload_length_in_byte` is renamed `pld_len_in_bytes` +* [radio] In `lr1110_radio_pkt_params_lora_t`, `preamble_length_in_symb` is renamed `preamble_len_in_symb` +* [radio] In `lr1110_radio_pkt_params_lora_t`, `payload_length_in_byte` is renamed `pld_len_in_bytes` +* [radio] `lr1110_radio_pa_config_t` are renamed `lr1110_radio_pa_cfg_t` +* [Wi-Fi] `lr1110_wifi_configure_hardware_debarker` is renamed `lr1110_wifi_cfg_hardware_debarker` + +### Fixed + +* [system] Enable c linkage for system-related functions + +### Removed + +* [system] `LR1110_SYSTEM_IRQ_FHSS_MASK` constant +* [system] `LR1110_SYSTEM_IRQ_INTERPACKET1_MASK` constant +* [system] `LR1110_SYSTEM_IRQ_INTERPACKET2_MASK` constant +* [system] `LR1110_SYSTEM_IRQ_RNGREQVLD_MASK` constant +* [system] `LR1110_SYSTEM_IRQ_RNGREQDISC_MASK` constant +* [system] `LR1110_SYSTEM_IRQ_RNGRESPDONE_MASK` constant +* [system] `LR1110_SYSTEM_IRQ_RNGEXCHVLD_MASK` constant +* [system] `LR1110_SYSTEM_IRQ_RNGTIMEOUT_MASK` constant + +## [v1.0.0] 2020-03-18 + +### Added + +* [all] Initial version diff --git a/embedded/lr1110_driver/LICENSE b/embedded/lr1110_driver/LICENSE new file mode 100644 index 0000000..02bc1c7 --- /dev/null +++ b/embedded/lr1110_driver/LICENSE @@ -0,0 +1,24 @@ +Revised BSD License +Copyright Semtech Corporation 2020. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Semtech corporation nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/embedded/lr1110_driver/doc/doxyfile b/embedded/lr1110_driver/doc/doxyfile deleted file mode 100644 index 9e002f0..0000000 --- a/embedded/lr1110_driver/doc/doxyfile +++ /dev/null @@ -1,2494 +0,0 @@ -# Doxyfile 1.8.13 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = "LR1110 Driver C" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "C implementation of LR1110 driver" - -# With the PROJECT_LOGO tag one can specify a logo or an icon that is included -# in the documentation. The maximum height of the logo should not exceed 55 -# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy -# the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = build_doc - -# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = YES - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new -# page for each member. If set to NO, the documentation of a member will be part -# of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note: For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up -# to that level are automatically included in the table of contents, even if -# they do not have an id attribute. -# Note: This feature currently applies only to Markdown headings. -# Minimum value: 0, maximum value: 99, default value: 0. -# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. - -TOC_INCLUDE_HEADINGS = 0 - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# If one adds a struct or class to a group and this option is enabled, then also -# any nested class or struct is added to the same group. By default this option -# is disabled and one has to add nested compounds explicitly via \ingroup. -# The default value is: NO. - -GROUP_NESTED_COMPOUNDS = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO, -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. If set to YES, local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO, only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO, these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES, the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will -# append additional text to a page's title, such as Class Reference. If set to -# YES the compound reference will be hidden. -# The default value is: NO. - -HIDE_COMPOUND_REFERENCE= NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo -# list. This list is created by putting \todo commands in the documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test -# list. This list is created by putting \test commands in the documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES, the -# list will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. -# The default value is: NO. - -WARN_AS_ERROR = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING -# Note: If this tag is empty the current directory is searched. - -INPUT = ../src - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# read by doxygen. -# -# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, -# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, -# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse-libclang=ON option for CMake. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefore more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra style sheet files is of importance (e.g. the last -# style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = NO - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler (hhc.exe). If non-empty, -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated -# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /