Commit Graph

65 Commits (master)

Author SHA1 Message Date
Charles deb09a3a9c allow to override antenna gain 2023-11-30 14:52:19 +01:00
Charles 9c3c88c96e Sleep Radio in between DC scheduled 2023-11-10 11:51:42 +01:00
Charles 394cbeec6b STM32WL fix set preamble length to 8 2023-10-24 10:23:44 +02:00
Danny Goossen 3508ec2b71
apply astyle patch 2022-08-18 00:25:21 -04:00
Danny Goossen 30a156056c
fix styling with astyle for LoRaPHYAS923.cpp 2022-08-11 11:08:40 -04:00
Danny Goossen 199c85629d LoRaWAN AS923 Add SUB_REGION AS1..AS4 2022-08-11 04:06:30 -04:00
Martin Kojtal 2d59c759bd
Merge pull request #15227 from zul00/fix/lora_timing/join_req_retransmission/call_in
lorawan: Fix Join Request retransmission timing (Interop test)
2022-02-16 16:36:30 +01:00
zul 61f83741b0 Fixed Join Request retransmission timing (Interop test)
On interop test 1.2.2.4, Join Request retransmission is expected to be 6
s + worst case air transmission. This delay is to accommodate for
JoinAccept through RX2.

The `call_in` in process_reception_timeout of RX2-window adds 500 ms
delay between RX2 symbol-interrupt-timeout and the next join request
retransmission. This is an isolated change and only affect the
retransmission of Join Request.

Adding this delay improves the chance of succeeding test
1.2.2.4 (subset of 1.2.2)
2022-02-14 12:07:29 +01:00
Zulkarnaen 1e9254387e Fixed issue in unconfirmed_retransmission behavior
Fixed issue on LoRaWANStack based on lorawan v1.0.2 specification page
24 line 25-27. The specification mentioned that that end-device shall
stop retransmission when receiving ANY downlink on RX1 or RX2 window.

- Removed conflicting behavior in
  LoRaWANStack::post_process_tx_with_reception()
- Updated comment section of nb_trials at lorawan_data_structures.h
2022-02-11 15:04:23 +01:00
Mikhail Isaev 352e6fbd23 Fix overflow at extremely low RSSI
Some LoRaWAN modem like SX1272 can receive downlink packets with RSSI level less than -127. So "int8_t" is not enough for store all possible RSSI values. For example, SX1272 has sensitivity at -137 dBm.
Problem was manifested in the file "SX1272_LoRaRadio.cpp" at SX1272_LoRaRadio::handle_dio0_irq() method.
When value of _rf_settings.lora_packet_handler.rssi_value calculated incorrect RSSI will be stored. Example case:

Value readen from register REG_LR_PKTSNRVALUE _rf_settings.lora_packet_handler.snr_value equals -47.
Value readen from register REG_LR_PKTRSSIVALUE equals 17.
RSSI_OFFSET equals "-139", snr equals "-11".

For case MODEM_LORA value calculated by formula:
_rf_settings.lora_packet_handler.rssi_value = RSSI_OFFSET + rssi + (rssi >> 4) + snr;
and result value will be "124" because of int8_t overflow so it's not correct value (too high).

Correct value must be:
-139 + 17 + (1) + (-11) = -132.

Another motivation: at all other places int16_t type used to store RSSI value.
2021-11-24 21:56:42 +03:00
Jerome Coutant fe1adbcc86 Lora drivers: explicit lib requirement 2021-09-10 09:07:15 +02:00
Robert Walton 7842320ab7 CMake: Add option to enable greentea tests
Add an option to enable the greentea tests independently from the unit
tests.

We can't just use the typical BUILD_TESTING option to enable greentea
tests. BUILD_TESTING enables unit tests and fetches googletest, which
are compiled for the host. Greentea tests are cross compiled and require
a toolchain file. For this reason we add a new option just to enable
greentea tests, preventing build failures triggered by the unit tests
and googletest.
2021-08-10 16:35:11 +01:00
Lingkai Dong dca2aa79a0 Unit tests: Remove redundant CMake target mbed-headers-base
Individual libraries' `target_h` stub headers have now all been moved
from `mbed-headers-base` to `mbed-headers-<library>`.

Note: Even though headers previously in `target_h` are technically
stubs/fakes too, they are used by not only unit tests but also regular
libraries when compiled for unit tests, because no target-specific HAL
implementation exists in this case. In order for regular library
sources to pick up `target_h` headers, those headers must

* have the same names as regular headers
* appear first in include paths

This is why those headers are part of `mbed-headers-<library>` and not
`mbed-stubs-<library>`. Before this refactoring, `mbed-headers-base`
was the first in unit tests' include paths.
2021-08-02 17:42:43 +01:00
Robert Walton 98e25f193e unittests: Test_LoRaWANStack.acquire_rx_metadata: Fix SEGFAULT
We failed to set `LoRaMac_stub::mlme_ind_ptr` to a valid pointer. When
we tried to dereference it in `LoRaWANStack::process_reception` we hit a
SEGFAULT.
2021-07-27 21:09:39 +01:00
Robert Walton 421adc9888 unittests: Fix Test_LoRaWANStack.acquire_tx_metadata
This test was relying on the state of `LoRaMac_stub::bool_true_counter`
to be set to 1 from a previous test. When the test was ran in isolation
the `LoRaWANStack::rx_timeout_interrupt_handler` callback would fail
because we weren't returning true from the stub implementation of
`LoRaMac::nwk_joined`. Due to this
`LoRaWANStack::post_process_tx_no_reception` was never called. This
caused the LoRaWANStack object to think the "tx_metadata" was "stale"
(i.e the data hadn't changed since any previous read). So, when we
attempted to call `LoRaWANStack::acquire_tx_metadata` it returned
`LORAWAN_STATUS_METADATA_NOT_AVAILABLE` as it thought we had no new
metadata to report, causing the test assertion to fail.
2021-07-27 21:09:39 +01:00
Robert Walton 9f3069f1e1 unittests: Test_LoRaMac.post_process_mcps_req: Fix segfault
We had commented out a line where we reset LoRaPHY_stub::uint16_value to
0. This was causing an invalid array access in
LoRaMac::handle_data_frame, when trying to extract the
_mps_indication.channel from list of channel_params_t returned by
lora_phy->get_phy_channels.
2021-07-27 21:09:39 +01:00
Robert Walton a09d08917b CMake: unittests: Show all tests in CTest report
Previously a test executable was recognised as a single test by CTest.
However, test executables usually contain multiple test cases, the
results of the test cases should be individually reported. With our
previous setup we could miss test case failures that didn't cause the
executable to return an error code.

This commit uses gtest_discover_test to discover all test cases in a
test executable. This enables CTest to match test passes and failures
from the googletest binary output.
2021-07-27 21:09:39 +01:00
Robert Walton 1e48a61d89 CMake: unittests: Remove trailing whitespace 2021-07-27 21:09:38 +01:00
Jaeden Amero 0a944f0ac4 test: lorawanstack: Use valid message type
We previously made up an invalid message type, which was roughly
`MCPS_MULTICAST | 0x40`. This causes an MBED_ASSERT failure in the
handle_rx function, as it uses an assert to validate the message type
passed to it (in convert_to_msg_flag()). Use the valid message type
MCPS_MULTICAST instead in the handle_rx unit test.
2021-07-27 10:28:12 +01:00
Robert Walton 07aefbc6bc unittests: Test_LoRaWANTimer.start: Fix test failure
We weren't initialising the mocks correctly, so an MBED_ASSERT failed in
`LoRaWANTimer::start` because the "timer_id" was not set.
2021-07-27 10:28:12 +01:00
Jaeden Amero b17ffaa68a cmake: Remove trailing whitespace
Remove trailing whitespace from lorawantimer's CMakeLists.txt.
2021-07-22 15:41:06 +01:00
Rajkumar Kanagaraj 86737bdb89 Remove mbed-headers-connectivity
Moved all the headers out of mbed-headers-connectivity, and these changes remove
that headers lib reference from lorawan and cellular unit tests
2021-07-21 01:56:29 -07:00
Hari Limaye db2042755c Unit tests: Make lorawan test header dependencies explicit
To quote @LDong-Arm - "The CMake target `mbed-headers` brings in all
headers, and we are gradually moving away from it and explicitly use
only headers needed by each unit test."
2021-07-14 15:27:30 +01:00
Rajkumar Kanagaraj ef7699d824 CMake: Update netsocket, lorawan unittest to use mbed-stubs-mbedtls
Update netsocket and lorawan unit tests to link with a mbed-stubs-mbedtls
library that it depends on instead of link with mbed-stubs
which is a group of stubs libraries.
2021-07-12 07:18:41 -07:00
Rajkumar Kanagaraj 66019cb80e CMake: Move mbedtls stubs to the mbedtls dir
Move the connectivity mbedtls stubs into the connectivity/mbedtls
component directory. So we can avoid duplicating the mbed-os source
tree in a central UNITTESTS folder.
2021-07-12 07:18:41 -07:00
Rajkumar Kanagaraj 46d4247b58 CMake: Move lorawan stub headers to the lorawan/tests/UNITTESTS/double dir
Previously all the lorawan stubs headers under mbed-stubs-headers,
so this PR move all lorawan stubs headers under
cellular/tests/UNITTESTS/double directory and update CMake to include
stubs headers into mbed-stubs-lorawan library to make lorawan stubs to be self-contained
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 728e183205 CMake: unit-tests: Make lorawan stub only depend on headers it uses
Previously the connectivity lorawan stub library depended on
`mbed-headers`, which is a collection of all available headers
in mbed-os. To make it easier to separate the library, only depend
on the headers we're using.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 8d7d173bb0 CMake: Update lorawan unittest to use mbed-headers-lorawan lib
Update lorawan unit test to link only with a mbed-headers-lorawan
library that it depends on instead of link with mbed-headers
which is a group of headers libraries.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 8c580489f6 CMake: unit-tests: Add mbed-headers-lorawan headers library
Previously, all lorawan headers made as a part of the
mbed-headers-connectivity library. To make it easier to separate all
the lorawan headers into the separate mbed-headers-lorawan library
and keep them, as part of lorawan stubs CMake. This makes the lorawan
stubs more self-contained and improves the composition of the library.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj fee7906b0c CMake: Update lorawan unittest to use mbed-stubs-lorawan
Update lorawan unit test to link only with a mbed-stubs-lorawan
library that it depends on instead of link with mbed-stubs
which is a group of stubs libraries.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 8f238f13b1 CMake: Move lorawan stubs to the lorawan dir
Move the connectivity lorawan stubs into the connectivity/lorawan
component directory. So we can avoid duplicating the mbed-os source
tree in a central UNITTESTS folder.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj ee67310922 CMake: unit-tests: Add mbed-headers-cellular headers library
- Previously all cellular header made as a part of the
mbed-headers-connectivity library. To make it easier to separate all
the cellular headers into the separate mbed-headers-cellular library
and keep them as part of cellular stub CMake. This makes the cellular
stubs more self-contained and improves the composition of the library.
- Update all unit test that depends on cellular headers with mbed-headers-cellular library
2021-06-30 06:01:42 -07:00
Hari Limaye f95052cf6f CMake: Require TEST_SOURCES in greentea CMake file
Assumption that greentea test file is always named main.cpp is
incorrect. Updated mbed_greentea_add_test() macro to make TEST_SOURCES
parameter compulsory, which is used to specify greentea test
file(s). This allows tests to use C, or have a different name.
Therefore also updated all pre-existing greentea test CMake files to
explicity add main.cpp to TEST_SOURCES.
2021-06-29 13:33:42 +01:00
Martin Kojtal 2dcd6c026d
Merge pull request #14767 from ghseb/early-test-skip
connectivity tests: early skip fix
2021-06-14 12:06:59 +02:00
Sebastian Stockhammer 3bee4917bb Early test skip
Adding mbed-os subdirectories that are not required for a specific project to .mbedignore is a good way to reduce compilation time. Sometimes it happens that tests depend on ignored files, which causes the test-build to fail even though the corresponding feature/component
is not configured. The reason is that the conditional that skips the test is placed after the includes.
2021-06-14 10:46:14 +02:00
Robert Walton a0befae2d4 CMake: Only build unit tests if Mbed OS is the current project
Typically when adding a unit test directory to a CMake project a check
will be used to ensure the subdirectory is added only if the following
are true:

* The BUILD_TESTING option is set to ON.
* The current CMake project is the top-level project.

The reason being, if a downstream project includes our project they
generally don't want to build our unit tests.

In mbed-os, we do correctly specify the above condition before adding
the central UNITTEST subdirectory, which fetches googletest and adds the
"stub" libraries the unit tests depend on. However, we only check if
CMAKE_CROSSCOMPILING is OFF (or undefined) before actually adding the
unit tests. This mismatched logic would lead to unexpected build
failures in various scenarios. One likely case could be: a downstream
project including mbed-os happens to set CMAKE_CROSSCOMPILING to
OFF/undefined for any reason (possibly to build its own unit tests).
mbed-os would go ahead and attempt to build its tests without fetching
googletest or adding the required stub targets.

To fix the issue replace the check for CMAKE_CROSSCOMPILING in the unit
tests with the same BUILD_TESTING idiom we use for adding the central
UNITTESTS subdirectory.
2021-06-10 23:34:14 +01:00
Martin Kojtal bc7fc2b2e7
Merge pull request #14708 from Patater/fix-test-function-return
test: Fix function does not return a value warnings
2021-05-31 12:20:00 +02:00
Jaeden Amero 7f7571657e test: Fix function does not return a value warnings
Many test stub functions are meant to return a value, but weren't. Clang
would generate a warning for each instance where we weren't returning
anything in a function that was meant to return a value.

    warning: non-void function does not return a value [-Wreturn-type]

For a specific example, my_radio::time_on_air() is supposed to return a
uint32_t, but wasn't returning anything. We'll return a zero instead of
relying on undefined behavior.

Without this, clang 11.0.1 was generating a virtual function
implementation with a `ud2` instruction to abort at run-time, causing
some execution of some unit tests to abort.

    Running main() from gmock_main.cc
    [==========] Running 10 tests from 1 test suite.
    [----------] Global test environment set-up.
    [----------] 10 tests from Test_LoRaPHYUS915
    [ RUN      ] Test_LoRaPHYUS915.constructor
    [       OK ] Test_LoRaPHYUS915.constructor (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.restore_default_channels
    [       OK ] Test_LoRaPHYUS915.restore_default_channels (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.rx_config
    [       OK ] Test_LoRaPHYUS915.rx_config (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.tx_config
    Process 35669 stopped
    * thread #1, name = 'lorawan-loraphy-', stop reason = signal SIGILL: privileged instruction
        frame #0: 0x0000000000276f73 lorawan-loraphy-us915-unittest`my_radio::time_on_air(this=0x0000000800c2b048, modem=MODEM_LORA, pkt_len='\0') at Test_LoRaPHYUS915.cpp:90:5
       87       };
       88
       89       virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len)
    -> 90       {
       91       };
       92
       93       virtual bool perform_carrier_sense(radio_modems_t modem,
    (lldb) disassemble --pc
    lorawan-loraphy-us915-unittest`my_radio::time_on_air:
    ->  0x276f73 <+67>: ud2
        0x276f75:       int3
        0x276f76:       int3
        0x276f77:       int3
    (lldb)
2021-05-27 09:38:18 +01:00
Rajkumar Kanagaraj 50fc85dc44 CMake: Remove all unittest.cmake script from test suite
- Remove redundant cmake script as already added the CMake configuration file
- Remove redundant empty_baseline as it is no longer needed with the help of CMake configuration file
2021-05-26 07:09:14 -07:00
Rajkumar Kanagaraj bf4ec4a290 CMake: Refactor lorawan unittest cmake
- Add CMakeLists.txt file to all lorawan test suite
2021-05-11 02:29:56 -07:00
Rajkumar Kanagaraj ba04c1cf76 CMake: Add add_subdirectory of unittests
- add every libraries unittest directory into respective CMake
  which allows to include unittest source into build based on
  MBED_BUILD_UNITTESTS flag
2021-05-11 02:29:56 -07:00
jeromecoutant b63ca7c800 STM32WL: update "lora.max-sys-rx-error" 2021-03-29 09:25:25 +02:00
Martin Kojtal 9e0495a770
LoRaWANTimer: add new line at the end of the file 2021-03-12 08:24:16 +00:00
Vincent Coubard 9781418e31 Lora: Clear callback ID when timer callback is executed. 2021-03-11 21:00:43 +00:00
Vincent Coubard 4885739c4e Lora: Add clear method to LoRaWANTimer.
This function must be called by the callback registered in init.
It clears the timer_id to prevent abusive use of the stop methods on expired timer.
2021-03-11 20:59:45 +00:00
jeromecoutant 7baae39ece STM32WL LORA : enable connectivity test 2021-02-09 11:56:50 +01:00
Ludovic Champsaur 08050839d5 STM32WL LORA : lorawan update 2021-02-09 11:56:41 +01:00
Martin Kojtal 733975220d
Merge pull request #14228 from ARMmbed/rename_greentea_test_macro
CMake: rename greentea test macro
2021-02-03 14:17:20 +00:00
Rajkumar Kanagaraj 6824b14e48 CMake: rename greentea test macro 2021-02-02 07:43:40 -08:00
jeromecoutant dd602689d2 LoraRadio test update for baremetal support 2021-01-26 14:47:56 +01:00