From c88c82ae86917cad91f41aa7a0af1224a4b1b5ad Mon Sep 17 00:00:00 2001 From: Maciej Janicki Date: Tue, 2 Feb 2021 16:08:30 +0100 Subject: [PATCH] [EGD-6319] Refactor cellular modem directory - Removed not used files from old implementations. - Renamed some classes to follow naming convention. - Renamed methods to use consistent styling. - Restructured code. --- .../board/linux/cellular/linux_cellular.cpp | 4 +- .../board/linux/cellular/linux_cellular.hpp | 12 +- module-cellular/CMakeLists.txt | 26 +- module-cellular/Modem/TS0710/DLC_channel.h | 86 ----- module-cellular/Modem/TS0710/TS0710_CLOSE.cpp | 18 - module-cellular/Modem/TS0710/TS0710_CLOSE.h | 30 -- .../Modem/TS0710/TS0710_CONTROL.cpp | 40 -- module-cellular/Modem/TS0710/TS0710_CONTROL.h | 88 ----- module-cellular/Modem/TS0710/TS0710_DATA.cpp | 91 ----- .../Modem/TS0710/TS0710_DLC_ESTABL.cpp | 147 -------- .../Modem/TS0710/TS0710_DLC_ESTABL.h | 77 ---- .../Modem/TS0710/TS0710_DLC_RELEASE.cpp | 31 -- .../Modem/TS0710/TS0710_DLC_RELEASE.h | 38 -- module-cellular/Modem/TS0710/TS0710_FLOW.cpp | 26 -- module-cellular/Modem/TS0710/TS0710_FLOW.h | 38 -- .../Modem/TS0710/TS0710_PARNEG.cpp | 42 --- module-cellular/Modem/TS0710/TS0710_PARNEG.h | 67 ---- .../Modem/TS0710/TS0710_PORTNEG.cpp | 56 --- module-cellular/Modem/TS0710/TS0710_PORTNEG.h | 120 ------ .../Modem/TS0710/TS0710_SERVNEG.cpp | 42 --- module-cellular/Modem/TS0710/TS0710_SERVNEG.h | 69 ---- module-cellular/Modem/TS0710/TS0710_SLEEP.cpp | 21 -- module-cellular/Modem/TS0710/TS0710_SLEEP.h | 33 -- module-cellular/Modem/TS0710/TS0710_START.cpp | 72 ---- module-cellular/Modem/TS0710/TS0710_START.h | 95 ----- module-cellular/Modem/TS0710/TS0710_TEST.cpp | 24 -- module-cellular/Modem/TS0710/TS0710_TEST.h | 31 -- .../Modem/TS0710/TS0710_WAKEUP.cpp | 18 - module-cellular/Modem/TS0710/TS0710_WAKEUP.h | 31 -- .../Modem/TS0710/tests/test-TS0710_CLOSE.cpp | 11 - .../TS0710/tests/test-TS0710_CONTROL.cpp | 11 - .../TS0710/tests/test-TS0710_DLC_RELEASE.cpp | 11 - .../Modem/TS0710/tests/test-TS0710_FLOW.cpp | 11 - .../Modem/TS0710/tests/test-TS0710_PARNEG.cpp | 11 - .../TS0710/tests/test-TS0710_PORTNEG.cpp | 11 - .../TS0710/tests/test-TS0710_SERVNEG.cpp | 11 - .../Modem/TS0710/tests/test-TS0710_SLEEP.cpp | 11 - .../Modem/TS0710/tests/test-TS0710_TEST.cpp | 11 - .../Modem/TS0710/tests/test-TS0710_WAKEUP.cpp | 11 - module-cellular/{Modem => modem}/ATCommon.cpp | 11 +- module-cellular/{Modem => modem}/ATCommon.hpp | 0 module-cellular/{Modem => modem}/ATParser.cpp | 19 +- module-cellular/{Modem => modem}/ATParser.hpp | 12 +- module-cellular/{Modem => modem}/ATStream.cpp | 2 +- module-cellular/{Modem => modem}/ATStream.hpp | 0 .../{Modem => modem}/ATURCStream.cpp | 0 .../{Modem => modem}/ATURCStream.hpp | 0 .../{Modem => modem}/BaseChannel.hpp | 8 +- module-cellular/{Modem => modem}/README.md | 5 - .../{Modem => modem}/doc/ATStream.md | 0 .../{Modem => modem}/doc/Images/at_mode.svg | 0 .../{Modem => modem}/doc/Images/at_mode.uml | 0 .../{Modem => modem}/doc/Images/atstream.png | Bin .../doc/Images/cellular_mux_read.png | Bin .../doc/Images/cellular_result_struct.png | Bin .../doc/Images/cellular_result_struct.uml | 0 .../doc/Images/class_channel.png | Bin .../{Modem => modem}/doc/Images/cmx_mode.uml | 0 .../doc/Images/current_volte_on.png | Bin .../doc/Images/dma_result_struct.png | Bin .../doc/Images/dma_result_struct.uml | 0 .../doc/Images/mudita_logo.png | Bin .../{Modem => modem}/doc/Images/mux_mode.svg | 0 .../doc/Images/single_cmd.uml | 0 .../doc/Images/single_cmd_transmission.png | Bin .../{Modem => modem}/doc/Images/volte_on.png | Bin .../{Modem => modem}/doc/scripts/atstream.pu | 0 .../doc/scripts/class_channel.pu | 4 +- .../TS0710.cpp => modem/mux/CellularMux.cpp} | 352 +++++++++++------- .../TS0710.h => modem/mux/CellularMux.h} | 240 ++++-------- module-cellular/modem/mux/CellularMuxData.cpp | 75 ++++ .../mux/CellularMuxData.h} | 28 +- .../mux/CellularMuxFrame.h} | 17 +- .../mux/CellularMuxTypes.h} | 4 +- .../mux/DLCChannel.cpp} | 81 ++-- module-cellular/modem/mux/DLCChannel.h | 77 ++++ module-cellular/modem/mux/MuxParameters.hpp | 16 + .../mux/tests/test-DLCChannel.cpp} | 4 +- .../mux}/tests/test-TS0710.cpp | 0 .../mux}/tests/test-TS0710_DATA.cpp | 0 .../mux}/tests/test-TS0710_DLC_ESTABL.cpp | 0 .../mux}/tests/test-TS0710_START.cpp | 0 .../test/mock/AtCommon_channel.hpp | 12 +- module-cellular/test/unittest_ATStream.cpp | 2 +- module-cellular/test/unittest_ATURCStream.cpp | 2 +- .../test/unittest_CellularResult.cpp | 2 +- module-cellular/test/unittest_URC.cpp | 2 +- module-cellular/test/unittest_cmux.cpp | 16 +- .../service-cellular/CellularServiceAPI.cpp | 6 +- .../service-cellular/CellularUrcHandler.cpp | 2 +- .../service-cellular/NetworkSettings.cpp | 26 +- .../service-cellular/PacketData.cpp | 2 +- .../service-cellular/PacketData.hpp | 3 +- .../service-cellular/QMBNManager.hpp | 5 +- .../service-cellular/ServiceCellular.cpp | 173 +++++---- module-services/service-cellular/SimCard.cpp | 14 +- .../service-cellular/checkSmsCenter.cpp | 2 +- .../ConnectionManagerCellularCommands.cpp | 8 +- .../doc/call_request_handling.puml | 4 +- .../doc/call_request_handling.svg | 20 +- .../service-cellular/handler/RawATHandler.cpp | 5 +- .../service-cellular/CellularMessage.hpp | 28 +- .../service-cellular/CellularServiceAPI.hpp | 4 +- .../service-cellular/RequestFactory.hpp | 2 +- .../service-cellular/ServiceCellular.hpp | 25 +- .../service-cellular/tests/CMakeLists.txt | 2 + .../tests/unittest_datatransfer.cpp | 1 - .../tests/unittest_simcard.cpp | 6 +- module-services/service-fota/ServiceFota.cpp | 23 +- .../service-fota/service-fota/ServiceFota.hpp | 10 +- module-utils/log/Logger.cpp | 4 +- 111 files changed, 774 insertions(+), 2175 deletions(-) delete mode 100644 module-cellular/Modem/TS0710/DLC_channel.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_CLOSE.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_CLOSE.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_CONTROL.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_CONTROL.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_DATA.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_FLOW.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_FLOW.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_PARNEG.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_PARNEG.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_PORTNEG.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_PORTNEG.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_SERVNEG.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_SERVNEG.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_SLEEP.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_SLEEP.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_START.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_START.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_TEST.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_TEST.h delete mode 100644 module-cellular/Modem/TS0710/TS0710_WAKEUP.cpp delete mode 100644 module-cellular/Modem/TS0710/TS0710_WAKEUP.h delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_CLOSE.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_CONTROL.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_DLC_RELEASE.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_FLOW.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_PARNEG.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_PORTNEG.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_SERVNEG.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_SLEEP.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_TEST.cpp delete mode 100644 module-cellular/Modem/TS0710/tests/test-TS0710_WAKEUP.cpp rename module-cellular/{Modem => modem}/ATCommon.cpp (94%) rename module-cellular/{Modem => modem}/ATCommon.hpp (100%) rename module-cellular/{Modem => modem}/ATParser.cpp (89%) rename module-cellular/{Modem => modem}/ATParser.hpp (73%) rename module-cellular/{Modem => modem}/ATStream.cpp (99%) rename module-cellular/{Modem => modem}/ATStream.hpp (100%) rename module-cellular/{Modem => modem}/ATURCStream.cpp (100%) rename module-cellular/{Modem => modem}/ATURCStream.hpp (100%) rename module-cellular/{Modem => modem}/BaseChannel.hpp (72%) rename module-cellular/{Modem => modem}/README.md (92%) rename module-cellular/{Modem => modem}/doc/ATStream.md (100%) rename module-cellular/{Modem => modem}/doc/Images/at_mode.svg (100%) rename module-cellular/{Modem => modem}/doc/Images/at_mode.uml (100%) rename module-cellular/{Modem => modem}/doc/Images/atstream.png (100%) rename module-cellular/{Modem => modem}/doc/Images/cellular_mux_read.png (100%) rename module-cellular/{Modem => modem}/doc/Images/cellular_result_struct.png (100%) rename module-cellular/{Modem => modem}/doc/Images/cellular_result_struct.uml (100%) rename module-cellular/{Modem => modem}/doc/Images/class_channel.png (100%) rename module-cellular/{Modem => modem}/doc/Images/cmx_mode.uml (100%) rename module-cellular/{Modem => modem}/doc/Images/current_volte_on.png (100%) rename module-cellular/{Modem => modem}/doc/Images/dma_result_struct.png (100%) rename module-cellular/{Modem => modem}/doc/Images/dma_result_struct.uml (100%) rename module-cellular/{Modem => modem}/doc/Images/mudita_logo.png (100%) rename module-cellular/{Modem => modem}/doc/Images/mux_mode.svg (100%) rename module-cellular/{Modem => modem}/doc/Images/single_cmd.uml (100%) rename module-cellular/{Modem => modem}/doc/Images/single_cmd_transmission.png (100%) rename module-cellular/{Modem => modem}/doc/Images/volte_on.png (100%) rename module-cellular/{Modem => modem}/doc/scripts/atstream.pu (100%) rename module-cellular/{Modem => modem}/doc/scripts/class_channel.pu (75%) rename module-cellular/{Modem/TS0710/TS0710.cpp => modem/mux/CellularMux.cpp} (70%) rename module-cellular/{Modem/TS0710/TS0710.h => modem/mux/CellularMux.h} (78%) create mode 100644 module-cellular/modem/mux/CellularMuxData.cpp rename module-cellular/{Modem/TS0710/TS0710_DATA.h => modem/mux/CellularMuxData.h} (63%) rename module-cellular/{Modem/TS0710/TS0710_Frame.h => modem/mux/CellularMuxFrame.h} (97%) rename module-cellular/{Modem/TS0710/TS0710_types.h => modem/mux/CellularMuxTypes.h} (97%) rename module-cellular/{Modem/TS0710/DLC_channel.cpp => modem/mux/DLCChannel.cpp} (62%) create mode 100644 module-cellular/modem/mux/DLCChannel.h create mode 100644 module-cellular/modem/mux/MuxParameters.hpp rename module-cellular/{Modem/TS0710/tests/test-DLC_channel.cpp => modem/mux/tests/test-DLCChannel.cpp} (95%) rename module-cellular/{Modem/TS0710 => modem/mux}/tests/test-TS0710.cpp (100%) rename module-cellular/{Modem/TS0710 => modem/mux}/tests/test-TS0710_DATA.cpp (100%) rename module-cellular/{Modem/TS0710 => modem/mux}/tests/test-TS0710_DLC_ESTABL.cpp (100%) rename module-cellular/{Modem/TS0710 => modem/mux}/tests/test-TS0710_START.cpp (100%) diff --git a/module-bsp/board/linux/cellular/linux_cellular.cpp b/module-bsp/board/linux/cellular/linux_cellular.cpp index 955b35bdadaedacfa5cd6fcd58b8f61921de9028..5b1f0dccacf011ed2392a5e6814a05510a354a7b 100644 --- a/module-bsp/board/linux/cellular/linux_cellular.cpp +++ b/module-bsp/board/linux/cellular/linux_cellular.cpp @@ -156,8 +156,8 @@ namespace bsp auto timeoutTicks = pdMS_TO_TICKS(timeoutMs.count()); uint32_t currentTime = cpp_freertos::Ticks::GetTicks(); - uint32_t timeoutNeeded = currentTime + timeoutTicks; - uint32_t timeElapsed = currentTime; + uint64_t timeoutNeeded = currentTime + timeoutTicks; + uint64_t timeElapsed = currentTime; for (;;) { if (timeElapsed >= timeoutNeeded) { diff --git a/module-bsp/board/linux/cellular/linux_cellular.hpp b/module-bsp/board/linux/cellular/linux_cellular.hpp index 18b029400ab90bf0c824ae72816f4a9732b65859..efa11b5e79e9f26835bf35d8de40fac74150dac4 100644 --- a/module-bsp/board/linux/cellular/linux_cellular.hpp +++ b/module-bsp/board/linux/cellular/linux_cellular.hpp @@ -8,9 +8,9 @@ #include #include -#include "termios.h" +#include #include -#include "mutex.hpp" +#include namespace bsp { @@ -24,25 +24,18 @@ namespace bsp ~LinuxCellular(); void powerUp() override final; - void powerDown() override final; - void restart() override final; uint32_t wait(std::chrono::milliseconds timeoutMs) override final; - ssize_t read(void *buf, size_t nbytes, std::chrono::milliseconds timeoutMs) override final; - ssize_t write(void *buf, size_t nbytes) override final; void informModemHostAsleep() override final; - void informModemHostWakeup() override final; void enterSleep() override final; - void exitSleep() override final; - void setSpeed(uint32_t portSpeed) override final; void setSendingAllowed(bool state) override final @@ -55,7 +48,6 @@ namespace bsp } void selectAntenna(bsp::cellular::antenna antenna) override final; - bsp::cellular::antenna getAntenna() override final; private: diff --git a/module-cellular/CMakeLists.txt b/module-cellular/CMakeLists.txt index 64a27c85c1b2375ea5455f60aa83020e78f683f3..7fbc2068edd453f0982aebf63cf9b5148d5243eb 100644 --- a/module-cellular/CMakeLists.txt +++ b/module-cellular/CMakeLists.txt @@ -8,25 +8,13 @@ include(SerialPort) module_is_test_entity() set(SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/ATParser.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/ATStream.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/ATURCStream.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/ATCommon.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/DLC_channel.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_CLOSE.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_CONTROL.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_DATA.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_DLC_ESTABL.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_DLC_RELEASE.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_FLOW.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_PARNEG.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_PORTNEG.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_SERVNEG.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_SLEEP.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_START.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_TEST.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Modem/TS0710/TS0710_WAKEUP.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modem/ATParser.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modem/ATStream.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modem/ATURCStream.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modem/ATCommon.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modem/mux/DLCChannel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modem/mux/CellularMux.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/modem/mux/CellularMuxData.cpp ${CMAKE_CURRENT_SOURCE_DIR}/at/src/Urc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/at/src/UrcQind.cpp ${CMAKE_CURRENT_SOURCE_DIR}/at/src/UrcCusd.cpp diff --git a/module-cellular/Modem/TS0710/DLC_channel.h b/module-cellular/Modem/TS0710/DLC_channel.h deleted file mode 100644 index 1483f8850a4207b7528e8a095323711d2022eb2d..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/DLC_channel.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#ifndef _DLC_CHANNEL_H -#define _DLC_CHANNEL_H - -#include -#include -#include - -#include "Modem/ATCommon.hpp" -#include "TS0710_types.h" -#include -#include -#include -#include - -class DLC_channel : public at::Channel -{ - public: - using Callback_t = std::function; - - private: - std::string pv_name; - DLCI_t pv_DLCI; - bool active = false; - DLC_ESTABL_SystemParameters_t chanParams{}; - Callback_t pv_callback; - bsp::Cellular *pv_cellular{}; - - public: - DLC_channel(DLCI_t DLCI, const std::string &name, bsp::Cellular *cellular, const Callback_t &callback = nullptr); - DLC_channel() : Channel{nullptr}, pv_name{"none"}, pv_DLCI{-1} - {} - - virtual ~DLC_channel(); - - bool init(); - bool establish(); - - void SendData(std::vector &data); - - DLCI_t getDLCI() - { - return pv_DLCI; - } - std::string getName() - { - return pv_name; - } - bool getActive() - { - return active; - } - - void setCallback(Callback_t callback) - { - LOG_DEBUG("[%s] Setting up callback for channel", pv_name.c_str()); - pv_callback = callback; - } - - virtual void cmd_init() override final; - virtual void cmd_send(std::string cmd) override final; - virtual size_t cmd_receive(std::uint8_t *result, - std::chrono::milliseconds timeout = std::chrono::milliseconds{300}) override final; - virtual void cmd_post() override final; - - std::vector SendCommandPrompt(const char *cmd, - size_t rxCount, - std::chrono::milliseconds timeout = std::chrono::milliseconds{300}); - - at::Result ParseInputData(bsp::cellular::CellularResult *cellularResult); - - bool evaluateEstablishResponse(bsp::cellular::CellularResult &response) const; - - void callback(std::string &data) - { - pv_callback(data); - } -}; - -#endif //_DLC_CHANNEL_H diff --git a/module-cellular/Modem/TS0710/TS0710_CLOSE.cpp b/module-cellular/Modem/TS0710/TS0710_CLOSE.cpp deleted file mode 100644 index 8aad8b0f865fe4325c3c70e49b1a7a3bddb3f426..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_CLOSE.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_CLOSE.h" - -/** - * TS0710_CLOSE implementation - */ - -void TS0710_CLOSE::request() -{} - -void TS0710_CLOSE::indication() -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_CLOSE.h b/module-cellular/Modem/TS0710/TS0710_CLOSE.h deleted file mode 100644 index 43ad8c89ac1821ae35c500e45e3f1fea61d848dd..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_CLOSE.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - * @brief When the request primitive is passed to the TS 0710 layer of the transmitting device close down of the - * multiplexer mode is initiated and a close down command is sent to the receiving device. On reception of the close - * down command the TS 0710 layer of the receiving device sends the indication primitive to the upper layer and the - * multiplexer mode is terminated. - */ - -#ifndef _TS0710_CLOSE_H -#define _TS0710_CLOSE_H - -// control channel - Multiplexer close down (CLD) -class TS0710_CLOSE -{ - public: - TS0710_CLOSE() - {} - ~TS0710_CLOSE() - {} - - private: - void request(); - - void indication(); -}; - -#endif //_TS0710_CLOSE_H \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_CONTROL.cpp b/module-cellular/Modem/TS0710/TS0710_CONTROL.cpp deleted file mode 100644 index 0a3209cf8159cc3be91178f11f98074d969f7a14..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_CONTROL.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_CONTROL.h" - -/** - * TS0710_CONTROL implementation - */ - -/** - * @param DLC - * @param Control_parameters - */ -void TS0710_CONTROL::request(DLCI_t DLC, ControlParameters_t Control_parameters) -{} - -/** - * @param DLC - * @param Control_parameters - */ -void TS0710_CONTROL::indication(DLCI_t DLC, ControlParameters_t Control_parameters) -{} - -/** - * @param DLC - * @param Control_parameters - */ -void TS0710_CONTROL::response(DLCI_t DLC, ControlParameters_t Control_parameters) -{} - -/** - * @param DLC - * @param Control_parameters - */ -void TS0710_CONTROL::confirm(DLCI_t DLC, ControlParameters_t Control_parameters) -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_CONTROL.h b/module-cellular/Modem/TS0710/TS0710_CONTROL.h deleted file mode 100644 index 16fc58143e11e0a41ecff3c1c5e508a3e5791ddf..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_CONTROL.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - * @brief The request primitive is used to convey control information to the remote port. The indication is sent to - * the other port emulation entity. The remote port emulation entity replies with a response which is sent to the - * originating 07.10 entity. A confirm is sent back to the port emulation entity. - */ - -#ifndef _TS0710_CONTROL_H -#define _TS0710_CONTROL_H - -#include "TS0710_PARNEG.h" -#include "TS0710_SERVNEG.h" -#include "TS0710_PORTNEG.h" -#include "TS0710_CONTROL.h" - -// control channel - Modem Status Command (MSC) - -class TS0710_CONTROL -{ - private: - TS0710_PARNEG *parneg; // control channel - DLC parameter negotiation (PN) - TS0710_SERVNEG *servneg; // control channel - Service Negotiation Command (SNC) - TS0710_PORTNEG *portneg; // control channel - Remote Port Negotiation Command (RPN) - // control channel - Remote Line Status Command(RLS) - TS0710_CONTROL *control; // control channel - Modem Status Command (MSC) - - public: - enum ModemSignal_e - { - DTR_DSR, - RTS_CTS, - RI, - DCD - }; - enum Buffers_e - { - DNDiscard, - Discard - }; - enum BreakSigSeq_e - { - ASAP, - INSEQ - }; - - struct ControlParameters_t - { - ModemSignal_e ModemSignal; //!< Modem Signal [DTR/DSR | RTS/CTS | RI | DCD ] - int BreakSignal; //!< Break Signal [0—3 s in steps of 200 ms, default 0ms ] - Buffers_e Buffers; //!< Buffers [do not discard buffers, discard buffer default: do not discard buffers] - BreakSigSeq_e BreakSigSeq; //!< Break signal sequence [ as soon as possible | in sequence, default: in sequence] - }; - - TS0710_CONTROL() - {} - ~TS0710_CONTROL() - {} - - private: - /** - * @param DLC - * @param Control_parameters - */ - void request(DLCI_t DLC, ControlParameters_t Control_parameters); - - /** - * @param DLC - * @param Control_parameters - */ - void indication(DLCI_t DLC, ControlParameters_t Control_parameters); - - /** - * @param DLC - * @param Control_parameters - */ - void response(DLCI_t DLC, ControlParameters_t Control_parameters); - - /** - * @param DLC - * @param Control_parameters - */ - void confirm(DLCI_t DLC, ControlParameters_t Control_parameters); -}; - -#endif //_TS0710_CONTROL_H \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_DATA.cpp b/module-cellular/Modem/TS0710/TS0710_DATA.cpp deleted file mode 100644 index c2e0679f25cc602791db6e30a1abb2b4ced211ef..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_DATA.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_DATA.h" -#include "TS0710_Frame.h" -#include - -#if defined(__cplusplus) -extern "C" -{ -#endif -//#include "uart.h" -#if defined(__cplusplus) -} -#endif - -/** - * TS0710_DATA implementation - */ -TS0710_DATA::TS0710_DATA(DLCI_t DLCI, - DLC_ESTABL_SystemParameters_t sysParams, - std::vector &User_data, - bsp::Cellular *cellular) -{ - assert(cellular != nullptr); - - pv_cellular = cellular; - - request(DLCI, sysParams, User_data); -} -/** - * @param DLCI - * @param User_data - */ -void TS0710_DATA::request(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t sysParams, std::vector User_data) -{ - /* - TE sends AT command "ATI" through DLC 1 - TE→MS F9 05 EF 09 41 54 49 0D 58 F9 UIH Frame - MS feeds back through DLC 1 - TE←MS F9 05 EF 09 41 54 49 0D 58 F9 - F9 05 EF 9B 0D 0A 53 49 4D 43 - 4F 4D 5F 4C 74 64 0D 0A 53 49 - 4D 43 4F 4D 5F 53 49 4D 33 30 - 30 0D 0A 52 65 76 69 73 69 6F 6E - 3A 53 49 4D 33 30 30 4D 33 32 28 - 53 50 41 4E 53 49 4F 4E 29 5F 56 - 31 30 2E 30 2E 38 5F 42 55 49 - 4C 44 30 33 0D 0A 0D 0A 47 F9 UIH Frame -*/ - auto constexpr maximumFrameLength = 127; - TS0710_Frame::frame_t frame; - frame.Address = static_cast(DLCI << 2) /*| (1 << 1)*/; // set C/R = 1 - command - frame.Control = static_cast(TypeOfFrame_e::UIH); - - if (User_data.size() <= static_cast(maximumFrameLength)) { - frame.data = User_data; - TS0710_Frame frame_c(frame); - // UartSend(frame_c.getSerData().data(), frame_c.getSerData().size()); - pv_cellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); - } - else { // if data size > max frame size - int dataLeft = User_data.size(); - std::vector::iterator i = User_data.begin(); - uint32_t parts = User_data.size() / maximumFrameLength + 1; // add reminder - LOG_DEBUG("SENDING %" PRIu32 " parts", parts); - while (parts--) { - std::vector::iterator last = - i + (dataLeft <= maximumFrameLength ? dataLeft : maximumFrameLength); // distinguish reminder - frame.data = std::vector(i, last); - i = last; - TS0710_Frame frame_c(frame); - // UartSend(frame_c.getSerData().data(), frame_c.getSerData().size()); - // while(!pv_cellular->GetSendingAllowed()); - pv_cellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); - // vTaskDelay(1); - dataLeft -= (dataLeft <= maximumFrameLength ? dataLeft : maximumFrameLength); - } - } -} - -/** - * @param DLCI - * @param User_data - */ -void TS0710_DATA::indication(DLCI_t DLCI, std::vector User_data) -{} diff --git a/module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.cpp b/module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.cpp deleted file mode 100644 index b947a601b000d6ddc4056d5c18417b4e864333e9..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_DLC_ESTABL.h" - -#if defined(__cplusplus) -extern "C" -{ -#endif -//#include "uart.h" -#if defined(__cplusplus) -} -#endif - -#include "TS0710_Frame.h" -#include "TS0710_types.h" -#include "log/log.hpp" -#include "FreeRTOS.h" - -#include - -/** - * TS0710_DLC_ESTABL implementation - */ -TS0710_DLC_ESTABL::TS0710_DLC_ESTABL(DLCI_t DLCI, bsp::Cellular *cellular) -{ - DLC_ESTABL_SystemParameters_t system_parameters; - system_parameters.TypeOfFrame = TypeOfFrame_e::UIH; - system_parameters.ConvergenceLayer = 1; - system_parameters.Priority = 1; - system_parameters.AckTime = 100; // 100ms default - system_parameters.MaxFrameSize = 128; - system_parameters.MaxNumOfRetransmissions = 3; // default 3 - system_parameters.ErrRecovWindowSize = 2; // default 2 - - pv_DLCI = DLCI; - pv_SystemParameters = system_parameters; - - pv_cellular = cellular; - - active = request(DLCI, system_parameters); -} - -/** - * @param DLCI - * @param system_parameters - */ -bool TS0710_DLC_ESTABL::request(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters) -{ - /* - TE requests to establish control channel DLCI 0 by SABM frame - TE→MS F9 03 3F 01 1C F9 SABM Frame - MS feeds back UA for receiving SABM and accepts to create DLCI 0 - TE←MS F9 03 73 01 D7 F9 UA Frame - */ - - /* - [send data] - |<-------------- - V | - -(is resp.)- | - |T F| | - | -(is t-out)- | - | |T F|-| - | | - | V - V {no resp.} - {resp.} - */ - - /* data flow : - TX: (data) -> queue[i] -> [ass. frame] -> [send to UART - mutex protected] - - frame type depends of data source - control/data[dlci] - RX: [receive from UART] -> [analyze frame] -> queue[i] -> (data) - - data sent to different queues - control/data[dlci] - */ - LOG_DEBUG("Sending %s frame to DLCI %i", TypeOfFrame_text[system_parameters.TypeOfFrame].c_str(), DLCI); - TS0710_Frame::frame_t frame; - frame.Address = static_cast(DLCI << 2) | (1 << 1); // set C/R = 1 - command - frame.Control = static_cast(system_parameters.TypeOfFrame); - TS0710_Frame frame_c(frame); - pv_cellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); - // return true; - int retries = system_parameters.MaxNumOfRetransmissions; - while (retries--) { - // UartSend(frame_c.getSerData().data(), frame_c.getSerData().size()); - pv_cellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); - vTaskDelay(system_parameters.AckTime); - if (response(DLCI, system_parameters)) { - LOG_DEBUG("Got response"); - return true; - } - } - - LOG_ERROR("Sending frame failed"); - return false; -} - -/** - * @param DLCI - * @param system_parameters - */ -void TS0710_DLC_ESTABL::indication(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters) -{} - -/** - * @param DLCI - * @param system_parameters - * @param accept - */ -bool TS0710_DLC_ESTABL::response(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters) -{ - constexpr size_t size = 256; - bsp::cellular::CellularDMAResultStruct result{}; - - ssize_t len = pv_cellular->read(&result, size, std::chrono::milliseconds{0}); - LOG_DEBUG("RX length = %d", static_cast(len)); - - if (len > 0) { - std::vector v(result.data, result.data + result.dataSize); - TS0710_Frame frame_c(v); - TS0710_Frame::frame_t frame = frame_c.getFrame(); - - if (((frame.Address & 0xFC) == (DLCI << 2)) && - (frame.Control == (static_cast(TypeOfFrame_e::UA) & ~(1 << 4)))) { - LOG_DEBUG("Frame correct"); - return true; - } - } - - LOG_DEBUG("ERROR - discarding frame !"); - return false; -} - -/** - * @param DLCI - * @param system_parameters - * @param accept - */ -bool TS0710_DLC_ESTABL::confirm(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters) -{ - return false; -} diff --git a/module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.h b/module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.h deleted file mode 100644 index e5dd65ef88a2e1d4efd26cc42d4b26ad9899016c..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_DLC_ESTABL.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#ifndef _TS0710_DLC_ESTABL_H -#define _TS0710_DLC_ESTABL_H - -#include "TS0710.h" - -class TS0710_DLC_ESTABL -{ - public: - // DLC_ESTABL_SystemParameters passed to Port Negotiation frame in control channel - - private: - DLC_ESTABL_SystemParameters_t pv_SystemParameters; - DLCI_t pv_DLCI; - bool active = false; - bsp::Cellular *pv_cellular; - - public: - TS0710_DLC_ESTABL(DLCI_t DLCI, bsp::Cellular *cellular); - TS0710_DLC_ESTABL(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters, bsp::Cellular *cellular) - { - pv_DLCI = DLCI; - pv_SystemParameters = system_parameters; - pv_cellular = cellular; - active = request(DLCI, system_parameters); - }; - ~TS0710_DLC_ESTABL() - {} - - bool getResponse() - { - return active; - } - DLC_ESTABL_SystemParameters_t getParams() - { - return pv_SystemParameters; - } - - private: - /** - * @param DLCI - * @param system_parameters - * @brief The transmitting device uses the request primitive initiate the establishment of a new DLC with a desired - * set of system parameters on the multiplexer channel. - */ - bool request(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters); - - /** - * @param DLCI - * @param system_parameters - * @brief The indication primitive is passed to the upper layer by the TS 0710 layer of the receiving device on - * reception of the DLC establishment request. - */ - void indication(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters); - - /** - * @param DLCI - * @param system_parameters - * @return accept - * @brief The receiving device uses the response primitive to either accept or reject the proposed DLCI with its - * system parameters. - */ - bool response(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters); - - /** - * @param DLCI - * @param system_parameters - * @return accept - * @brief The confirm primitive is passed to the upper layer of the transmitting device on reception of the response - * from the receiving device. - */ - bool confirm(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t system_parameters); -}; - -#endif //_TS0710_DLC_ESTABL_H diff --git a/module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.cpp b/module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.cpp deleted file mode 100644 index 9b95fac4afe0fff0214408484d7b359248f9e133..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_DLC_RELEASE.h" - -/** - * TS0710_DLC_RELEASE implementation - */ - -/** - * @param DLCI - */ -void TS0710_DLC_RELEASE::request(DLCI_t DLCI) -{ - /* - TE sends DISC frame to request for closing down DLC 1 - TE→MS F9 07 53 01 3f F9 - MS feeds back UA frame to accept - TE←MS F9 07 73 01 15 F9 - */ -} - -/** - * @param DLCI - */ -void TS0710_DLC_RELEASE::indication(DLCI_t DLCI) -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.h b/module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.h deleted file mode 100644 index 1e8c60a01aa506771a4b3df47129b141b32d3c4e..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_DLC_RELEASE.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - * @brief The request primitive is used by the upper layer in the transmitting device to initiate close down of the - * selected DLC in TS 0710. The TS 0710 layer of the receiving device uses the indication primitive to inform the upper - * layer that the DLC has been closed down. - */ - -#ifndef _TS0710_DLC_RELEASE_H -#define _TS0710_DLC_RELEASE_H - -#include "TS0710.h" - -class TS0710_DLC_RELEASE -{ - public: - TS0710_DLC_RELEASE(DLCI_t DLCI) - { - request(DLCI); - }; - ~TS0710_DLC_RELEASE() - {} - - private: - /** - * @param DLCI - */ - void request(DLCI_t DLCI); - - /** - * @param DLCI - */ - void indication(DLCI_t DLCI); -}; - -#endif //_TS0710_DLC_RELEASE_H \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_FLOW.cpp b/module-cellular/Modem/TS0710/TS0710_FLOW.cpp deleted file mode 100644 index e01a2294abbe39ec27de713d20b9741c7d4d41bb..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_FLOW.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_FLOW.h" - -/** - * TS0710_FLOW implementation - */ - -/** - * @param DLCI - * @param State - */ -void TS0710_FLOW::request(DLCI_t DLCI, State_e State) -{} - -/** - * @param DLCI - * @param State - */ -void TS0710_FLOW::indication(DLCI_t DLCI, State_e State) -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_FLOW.h b/module-cellular/Modem/TS0710/TS0710_FLOW.h deleted file mode 100644 index b61560331d324d1d2de05dd6786974403f8765f8..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_FLOW.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#ifndef _TS0710_FLOW_H -#define _TS0710_FLOW_H - -#include "TS0710.h" -// control channel - -class TS0710_FLOW -{ - public: - enum State_e - { - enable, - disable - }; - - TS0710_FLOW() - {} - ~TS0710_FLOW() - {} - - private: - /** - * @param DLCI - * @param State - */ - void request(DLCI_t DLCI, State_e State); - - /** - * @param DLCI - * @param State - */ - void indication(DLCI_t DLCI, State_e State); -}; - -#endif //_TS0710_FLOW_H diff --git a/module-cellular/Modem/TS0710/TS0710_PARNEG.cpp b/module-cellular/Modem/TS0710/TS0710_PARNEG.cpp deleted file mode 100644 index f7748c0d325fb5043877705aba57c2a606078f78..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_PARNEG.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_PARNEG.h" - -/** - * TS0710_PARNEG implementation - */ - -/** - * @param DLC - * @param DLC_parameters - */ -void TS0710_PARNEG::request(DLCI_t DLC, DLCParameters_t DLC_parameters) -{} - -/** - * @param DLC - * @param DLC_parameters - */ -void TS0710_PARNEG::indication(DLCI_t DLC, DLCParameters_t DLC_parameters) -{} - -/** - * @param DLC - * @param DLC_parameters - * @param accept - */ -void TS0710_PARNEG::response(DLCI_t DLC, DLCParameters_t DLC_parameters, bool accept) -{} - -/** - * @param DLC - * @param DLC_parameters - * @param accept - */ -void TS0710_PARNEG::confirm(DLCI_t DLC, DLCParameters_t DLC_parameters, bool accept) -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_PARNEG.h b/module-cellular/Modem/TS0710/TS0710_PARNEG.h deleted file mode 100644 index 138a3b1c015f8cbfbd320fc78284f654e03213e8..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_PARNEG.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - * @brief The request primitive is used to request that the remote 07.10 entity changes a specific DLC connection - * parameters. An indication is sent to the remote port emulation entity. The remote emulation entity replies with a - * response witch is forwarded as an confirmation to the originating port emulating entity. - */ - -#ifndef _TS0710_PARNEG_H -#define _TS0710_PARNEG_H - -#include "TS0710.h" -// control channel - DLC parameter negotiation (PN) - -class TS0710_PARNEG -{ - public: - struct DLCParameters_t - { - TypeOfFrame_e TypeOfFrame; //!< Type of frame [UIH | UI | I, default: UIH] - int ConvergenceLayer; //!< Convergence layer [1 - 4, default: 1] - int Priority; //!< Priority [0-63], default according to table in subclause 5.6 - int AckTime; //!< Acknowledgement Timer [10 ms - 25.5 sec, deault: 100 ms] - int MaxFrameSize; //!< Maximum Frame Size [1 – 32768, default: 31 for the basic option and 64 for the advanced - //!< option] - int MaxNumOfRetransmissions; //!< Maximum number of retransmissions [0 – 100, default : 3] - int MuxCtrlRespTime; //!< Response timer for the multiplexor control channel [0,01s-2,55s, default: 0,3s] - int WakeUpRespTime; //!< Wake up response timer [1s – 255s, default 10s] - int ErrRecovWindowSize; //!< Window size for error recovery mode [1 – 7, default : 2] - }; - - TS0710_PARNEG() - {} - ~TS0710_PARNEG() - {} - - private: - /** - * @param DLC - * @param DLC_parameters - */ - void request(DLCI_t DLC, DLCParameters_t DLC_parameters); - - /** - * @param DLC - * @param DLC_parameters - */ - void indication(DLCI_t DLC, DLCParameters_t DLC_parameters); - - /** - * @param DLC - * @param DLC_parameters - * @param accept - */ - void response(DLCI_t DLC, DLCParameters_t DLC_parameters, bool accept); - - /** - * @param DLC - * @param DLC_parameters - * @param accept - */ - void confirm(DLCI_t DLC, DLCParameters_t DLC_parameters, bool accept); -}; - -#endif //_TS0710_PARNEG_H \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_PORTNEG.cpp b/module-cellular/Modem/TS0710/TS0710_PORTNEG.cpp deleted file mode 100644 index 1ce844d6eeb1853f4d7506447052376e566b7e05..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_PORTNEG.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_PORTNEG.h" - -/** - * TS0710_PORTNEG implementation - */ - -/** - * @param DLC - * @param Port_parameters - */ -void TS0710_PORTNEG::request(DLCI_t DLC, PortParameters_t Port_parameters) -{} - -/** - * @param DLC - * @param Port_parameters - */ -void TS0710_PORTNEG::indication(DLCI_t DLC, PortParameters_t Port_parameters) -{} - -/** - * @param DLC - * @param Port_parameters - * @param accept - */ -void TS0710_PORTNEG::response(DLCI_t DLC, PortParameters_t Port_parameters, bool accept) -{} - -/** - * @param DLC - * @param Port_parameters - * @param accept - */ -void TS0710_PORTNEG::confirm(DLCI_t DLC, PortParameters_t Port_parameters, bool accept) -{} - -/** - * @param DLC - * @param LineStatusParameter - */ -void TS0710_PORTNEG::request(DLCI_t DLC, LineStatusParameter_e LineStatusParameter) -{} - -/** - * @param DLC - * @param LineStatusParameter - */ -void TS0710_PORTNEG::indication(DLCI_t DLC, LineStatusParameter_e LineStatusParameter) -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_PORTNEG.h b/module-cellular/Modem/TS0710/TS0710_PORTNEG.h deleted file mode 100644 index 69963f9c4a8f055b215fb8196c9af4749536f057..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_PORTNEG.h +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - * @brief The request primitive is used to request that the remote port changes its parameters. The indication is sent - * to the other port emulation entity. The remote port emulation entity replies with a response. A confirm is sent to - * the originating port entity. - */ - -#ifndef _TS0710_PORTNEG_H -#define _TS0710_PORTNEG_H - -#include "TS0710_types.h" - -// control channel - Remote Port Negotiation Command (RPN) -// control channel - Remote Line Status Command(RLS) - -class TS0710_PORTNEG -{ - public: - enum DataBits_e - { - DB5, - DB6, - DB7, - DB8 - }; - enum PortSpeed_e - { - PS2400, - PS4800, - PS7200, - PS9600, - PS19200, - PS38400, - PS57600, - PS115200, - PS230400 - }; - enum Parity_e - { - NoParity, - Parity - }; - enum ParityType_e - { - odd, - even, - mark, - space - }; - enum StopBits_e - { - SB1, - SB15 - }; - enum LineStatusParameter_e - { - NoErrors, - OverrunErr, - ParityErr, - FramingErr - }; //!< Port speed [no errors, overrun error, parity error, framing error] - - struct PortParameters_t - { - PortSpeed_e PortSpeed; - DataBits_e DataBits; - StopBits_e StopBits; - Parity_e Parity; - ParityType_e ParityType; - }; - - TS0710_PORTNEG() - {} - ~TS0710_PORTNEG() - {} - - private: - /** - * @param DLC - * @param Port_parameters - */ - void request(DLCI_t DLC, PortParameters_t Port_parameters); - - /** - * @param DLC - * @param Port_parameters - */ - void indication(DLCI_t DLC, PortParameters_t Port_parameters); - - /** - * @param DLC - * @param Port_parameters - * @param accept - */ - void response(DLCI_t DLC, PortParameters_t Port_parameters, bool accept); - - /** - * @param DLC - * @param Port_parameters - * @param accept - */ - void confirm(DLCI_t DLC, PortParameters_t Port_parameters, bool accept); - - /** - * @param DLC - * @param LineStatusParameter - */ - void request(DLCI_t DLC, LineStatusParameter_e LineStatusParameter); - - /** - * @param DLC - * @param LineStatusParameter - */ - void indication(DLCI_t DLC, LineStatusParameter_e LineStatusParameter); -}; - -#endif //_TS0710_PORTNEG_H \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_SERVNEG.cpp b/module-cellular/Modem/TS0710/TS0710_SERVNEG.cpp deleted file mode 100644 index b87d78a17876bd98822affcb3d59da425385320c..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_SERVNEG.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_SERVNEG.h" - -/** - * TS0710_SERVNEG implementation - */ - -/** - * @param DLC - * @param Service_parameters - */ -void TS0710_SERVNEG::request(DLCI_t DLC, ServiceParameters_t Service_parameters) -{} - -/** - * @param DLC - * @param Service_parameters - */ -void TS0710_SERVNEG::indication(DLCI_t DLC, ServiceParameters_t Service_parameters) -{} - -/** - * @param DLC - * @param Service_parameters - * @param accept - */ -void TS0710_SERVNEG::response(DLCI_t DLC, ServiceParameters_t Service_parameters, bool accept) -{} - -/** - * @param DLC - * @param Service_parameters - * @param accept - */ -void TS0710_SERVNEG::confirm(DLCI_t DLC, ServiceParameters_t Service_parameters, bool accept) -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_SERVNEG.h b/module-cellular/Modem/TS0710/TS0710_SERVNEG.h deleted file mode 100644 index 02ce6dfeb5e8c9bfb132eb94a8e798d6b9786384..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_SERVNEG.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#ifndef _TS0710_SERVNEG_H -#define _TS0710_SERVNEG_H - -#include "TS0710_types.h" - -// control channel - Service Negotiation Command (SNC) - -class TS0710_SERVNEG -{ - public: - enum Service_e - { - data, - voice, - reserved1, - reserved2 - }; - enum VoiceCodec_e - { - GSM0621, - PCM64k, - ADPCM32k, - CodedHalfRate, - PCM128k, - reserved - }; - struct ServiceParameters_t - { - Service_e Service; - VoiceCodec_e VoiceCodec; - }; - - TS0710_SERVNEG() - {} - ~TS0710_SERVNEG() - {} - - private: - /** - * @param DLC - * @param Service_parameters - */ - void request(DLCI_t DLC, ServiceParameters_t Service_parameters); - - /** - * @param DLC - * @param Service_parameters - */ - void indication(DLCI_t DLC, ServiceParameters_t Service_parameters); - - /** - * @param DLC - * @param Service_parameters - * @param accept - */ - void response(DLCI_t DLC, ServiceParameters_t Service_parameters, bool accept); - - /** - * @param DLC - * @param Service_parameters - * @param accept - */ - void confirm(DLCI_t DLC, ServiceParameters_t Service_parameters, bool accept); -}; - -#endif //_TS0710_SERVNEG_H diff --git a/module-cellular/Modem/TS0710/TS0710_SLEEP.cpp b/module-cellular/Modem/TS0710/TS0710_SLEEP.cpp deleted file mode 100644 index ffb894a21952eba01509f6137819e884355fa274..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_SLEEP.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_SLEEP.h" - -/** - * TS0710_SLEEP implementation - */ - -void TS0710_SLEEP::request() -{} - -void TS0710_SLEEP::indication() -{} - -void TS0710_SLEEP::confirm() -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_SLEEP.h b/module-cellular/Modem/TS0710/TS0710_SLEEP.h deleted file mode 100644 index 25d03614bbe57f70babb25de0f397dd206b93aca..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_SLEEP.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * @brief The request primitive is used to advice the receiving device that the transmitter wishes to enter a low - * power state. The TS 0710 layer of the receiving unit sends an indication primitive to the upper layer in order to - * inform that the transmitting unit has entered the power saving state. The TS 0710 layer will automatically transmit - * an acknowledge message to the transmitting device, thus no response primitive is required. The confirm primitive is - * sent to the upper layer of the transmitting device when the low power request has been received, and indicates that - * the TS 0710 layer has entered the low power mode. Note that the Receiving device is not required to enter a low power - * mode, but it will be considered to have done so by the TS 07.10 layer. - */ - -#ifndef _TS0710_SLEEP_H -#define _TS0710_SLEEP_H - -class TS0710_SLEEP -{ - public: - TS0710_SLEEP() - {} - ~TS0710_SLEEP() - {} - - private: - void request(); - - void indication(); - - void confirm(); -}; - -#endif //_TS0710_SLEEP_H diff --git a/module-cellular/Modem/TS0710/TS0710_START.cpp b/module-cellular/Modem/TS0710/TS0710_START.cpp deleted file mode 100644 index 45c7592825f263c4966fee1860e6c80dfb1ff031..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_START.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_START.h" -#include "DLC_channel.h" -#include "log/log.hpp" - -/** - * TS0710_START implementation - */ - -TS0710_START::TS0710_START(Mode_e mode, START_SystemParameters_t system_parameters, bsp::Cellular *cellular) -{ - pv_mode = mode; - pv_system_parameters = system_parameters; - pv_cellular = cellular; - - // assemble frame, send request, report connection status - request(pv_mode, pv_system_parameters); -} - -TS0710_START::~TS0710_START() -{} - -/** - * @param mode - * @param system_parameters - */ -void TS0710_START::request(Mode_e mode, START_SystemParameters_t system_parameters) -{ - // 1. start CMUX by AT command AT+CMUX=...(with given parameters) & get response - /* - AT+CMUX=[,[,[,[,[,[,[,[,]]]]]]]] - 0 Basic option. - This parameter defines the way in which the MUX control channel is set up. - Virtual channel may subsequently be set up differently, but in the absence of any - negotiation for the settings of a virtual channel, it shall be set up according to thecontrol channel - setting. 0 UIH frames used only. 1 UI frames used only. 2 I frames used only. 1 9600bit/s 2 19200bit/s - 3 38400bit/s - 4 57600bit/s - 5 115200bit/s - 6 230400bit/s - 7 460800bit/s - Maximum frame size, the range is 1-32768, 127 is the default value for basic option (see ). - The time UE waits for an acknowledgement before resorting to other action (e.g. - transmitting a frame).The step size is ten milliseconds, the range is 1-255. The default value is 100ms. - Maximum number of re-transmissions, the range is 0-255, the default value is 3. - Response timer for MUX control channel, the step size is ten milliseconds, the range is 2-255, 30 is the - default value. Wake up response timer in seconds. The range is 1-255, 10 is the default value. Window size - (It is not supported for UC20) - - PortSpeed_e PortSpeed; //!< Port speed - int MaxFrameSize; //!< Maximum Frame Size [ 1-128 in Basic mode, 1-512 in HDLC modes, default: 31 for - basic option & 64 for advanced ] int AckTimer; //!< Acknowledgement Timer [0,01s-2,55s, default: - 0,1s] int MaxNumOfRetransmissions; //!< Maximum number of retransmissions [0-100, default: 3] int - MaxCtrlRespTime; //!< Response timer for the multiplexer control channel [0,01s-2,55s, default: 0,3s] int - WakeUpRespTime; //!< Wake up response timer [1s-255s, default: 10s] int ErrRecovWindowSize; //!< - Window size for error recovery mode [1-7, default: 2] - */ - - // 2. Create channel DLCI0 - control - ctrlChannel = new DLC_channel(0, std::string("Control"), pv_cellular); - - // wait & check for active flag in channel - if (ctrlChannel->getActive()) { - connStatus = true; - } -} diff --git a/module-cellular/Modem/TS0710/TS0710_START.h b/module-cellular/Modem/TS0710/TS0710_START.h deleted file mode 100644 index 6b29c9a17c81e73b328d8fa0257f3a8480273b52..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_START.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#ifndef _TS0710_START_H -#define _TS0710_START_H - -#include -#include -#include "DLC_channel.h" - -class TS0710_START -{ - public: - enum class Mode_e - { - Basic, - HDLC_UIH_frames, - HDLC_UI_frames, - HDLC_frames - }; - - struct START_SystemParameters_t - { - PortSpeed_e PortSpeed; //!< Port speed - int MaxFrameSize; //!< Maximum Frame Size [ 1-128 in Basic mode, 1-512 in HDLC modes, default: 31 for basic - //!< option & 64 for advanced ] - int AckTimer; //!< Acknowledgement Timer [0,01s-2,55s, default: 0,1s] - int MaxNumOfRetransmissions; //!< Maximum number of retransmissions [0-100, default: 3] - int MaxCtrlRespTime; //!< Response timer for the multiplexer control channel [0,01s-2,55s, default: 0,3s] - int WakeUpRespTime; //!< Wake up response timer [1s-255s, default: 10s] - int ErrRecovWindowSize; //!< Window size for error recovery mode [1-7, default: 2] - }; - - private: - Mode_e pv_mode; - START_SystemParameters_t pv_system_parameters; - bool connStatus = false; //!< Connection status - false: GSM0710 not started, true: client responded - DLC_channel *ctrlChannel; - bsp::Cellular *pv_cellular; - - public: - TS0710_START(Mode_e mode, START_SystemParameters_t system_parameters, bsp::Cellular *cellular); - ~TS0710_START(); - - private: - /** - * @param mode - * @param system_parameters - * @brief The request primitive is used to request that the multiplexer mode to be turned on in the desired mode and - * system parameters. - */ - void request(Mode_e mode, START_SystemParameters_t system_parameters); - - /** - * @param mode - * @param system_parameters - * @brief The indication primitive transfers the request to start multiplexer operation along with the desired mode - * and system parameters to the upper layer of the target device. - */ - // void indication(Mode_e mode, START_SystemParameters_t system_parameters); - - /** - * @param mode - * @param system_parameters - * @param accept - * @brief If the target device accepts the request by issuing an affirmative response primitive, the suggested mode - * and system parameters will become valid. \ - * A successful establishment of the multiplexer mode is indicated by the accept parameter being set to “true”. \ - * If the accept parameter is set to “false” the returned values for the other parameters are those suggested by the - * responding device. - */ - // void response(Mode_e mode, START_SystemParameters_t system_parameters, bool accept); - - /** - * @param mode - * @param system_parameters - * @param accept - * @brief The confirm primitive is returned to the upper layer of the requesting device. \ - * A successful establishment of the multiplexer mode is indicated by the accept parameter being set to “true”. \ - * If the accept parameter is set to “false” the returned values for the other parameters are those suggested by the - * responding device. - */ - // void confirm(Mode_e mode, START_SystemParameters_t system_parameters, bool accept); - public: - bool ConnectionStatus() - { - return connStatus; - } - DLC_channel *getCtrlChannel() - { - return ctrlChannel; - } -}; - -#endif //_TS0710_START_H diff --git a/module-cellular/Modem/TS0710/TS0710_TEST.cpp b/module-cellular/Modem/TS0710/TS0710_TEST.cpp deleted file mode 100644 index 794fda8f1b9a741639048c9df586603b6f237039..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_TEST.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_TEST.h" - -/** - * TS0710_TEST implementation - */ - -/** - * @param TestData - */ -void TS0710_TEST::request(std::vector TestData) -{} - -/** - * @param TestData - */ -void TS0710_TEST::confirm(std::vector TestData) -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_TEST.h b/module-cellular/Modem/TS0710/TS0710_TEST.h deleted file mode 100644 index 50a6bf520f069c8331288bb99a7ee6b8cd7f7d91..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_TEST.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#ifndef _TS0710_TEST_H -#define _TS0710_TEST_H - -#include -#include "stdint.h" -// control channel - Test Command (Test) - -class TS0710_TEST -{ - public: - TS0710_TEST() - {} - ~TS0710_TEST() - {} - - private: - /** - * @param TestData - */ - void request(std::vector TestData); - - /** - * @param TestData - */ - void confirm(std::vector TestData); -}; - -#endif //_TS0710_TEST_H diff --git a/module-cellular/Modem/TS0710/TS0710_WAKEUP.cpp b/module-cellular/Modem/TS0710/TS0710_WAKEUP.cpp deleted file mode 100644 index 7157d9bc6376e264de8f7e8dcbd02f3dd56108d9..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_WAKEUP.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - */ - -#include "TS0710_WAKEUP.h" - -/** - * TS0710_WAKEUP implementation - */ - -void TS0710_WAKEUP::indication() -{} - -void TS0710_WAKEUP::response() -{} \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_WAKEUP.h b/module-cellular/Modem/TS0710/TS0710_WAKEUP.h deleted file mode 100644 index c43621fdea80d82393cc495da7efff13befbb1b5..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/TS0710_WAKEUP.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/** - * Project Untitled - * @brief The indication primitive is sent to the upper layer when the TS 0710 layer of the receiving unit receives a - * request to wake up from the power saving state. When the receiving device is ready to resume operation on the - * multiplexer channel this is indicated to the TS 0710 layer in the receiving unit by means of the response primitive. - * Sins the wakeup routine is initiated by the transmitting device attempting to communicate, neither request nor - * confirm primitives are provided for the wakeup service. The transmitting device instead uses the Data services - * described below. - */ - -#ifndef _TS0710_WAKEUP_H -#define _TS0710_WAKEUP_H - -class TS0710_WAKEUP -{ - public: - TS0710_WAKEUP() - {} - ~TS0710_WAKEUP() - {} - - private: - void indication(); - - void response(); -}; - -#endif //_TS0710_WAKEUP_H \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_CLOSE.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_CLOSE.cpp deleted file mode 100644 index ce13658d84c22f3572d621688f6183aa07f179c5..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_CLOSE.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_CLOSE.h" -TEST_CASE("test-TS0710_CLOSE") -{ - TS0710_CLOSE *_class = new TS0710_CLOSE(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_CONTROL.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_CONTROL.cpp deleted file mode 100644 index f279f3e8cb3e89d069f60d772dbe9eaab77214a6..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_CONTROL.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_CONTROL.h" -TEST_CASE("test-TS0710_CONTROL") -{ - TS0710_CONTROL *_class = new TS0710_CONTROL(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_DLC_RELEASE.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_DLC_RELEASE.cpp deleted file mode 100644 index 757550eb7c8dd8838f193cfb9ecac5f4bf9a96a1..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_DLC_RELEASE.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_DLC_RELEASE.h" -TEST_CASE("test-TS0710_DLC_RELEASE") -{ - TS0710_DLC_RELEASE *_class = new TS0710_DLC_RELEASE(0); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_FLOW.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_FLOW.cpp deleted file mode 100644 index 044ce57c5ce1802c157a067b722b8ce7677a9e0b..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_FLOW.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_FLOW.h" -TEST_CASE("test-TS0710_FLOW") -{ - TS0710_FLOW *_class = new TS0710_FLOW(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_PARNEG.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_PARNEG.cpp deleted file mode 100644 index 9c696c64c93f3e446be3791f8a4ee3015c828ac9..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_PARNEG.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_PARNEG.h" -TEST_CASE("test-TS0710_PARNEG") -{ - TS0710_PARNEG *_class = new TS0710_PARNEG(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_PORTNEG.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_PORTNEG.cpp deleted file mode 100644 index 23dd5d791b2c08118ba7366361f3abdfba541f3c..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_PORTNEG.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_PORTNEG.h" -TEST_CASE("test-TS0710_PORTNEG") -{ - TS0710_PORTNEG *_class = new TS0710_PORTNEG(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_SERVNEG.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_SERVNEG.cpp deleted file mode 100644 index 7ce4b0745158b5e08f518cc7f928a9cb544d50dc..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_SERVNEG.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_SERVNEG.h" -TEST_CASE("test-TS0710_SERVNEG") -{ - TS0710_SERVNEG *_class = new TS0710_SERVNEG(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_SLEEP.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_SLEEP.cpp deleted file mode 100644 index 50642a46008a2747bb10253508e8269ee0bf9d74..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_SLEEP.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_SLEEP.h" -TEST_CASE("test-TS0710_SLEEP") -{ - TS0710_SLEEP *_class = new TS0710_SLEEP(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_TEST.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_TEST.cpp deleted file mode 100644 index d4adfa46089b44962a810ada2c49026d28320aed..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_TEST.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_TEST.h" -TEST_CASE("test-TS0710_TEST") -{ - TS0710_TEST *_class = new TS0710_TEST(); - - delete _class; -} diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_WAKEUP.cpp b/module-cellular/Modem/TS0710/tests/test-TS0710_WAKEUP.cpp deleted file mode 100644 index 5f46998d83a73ee5b7c69d9a0fb136b6c288dafe..0000000000000000000000000000000000000000 --- a/module-cellular/Modem/TS0710/tests/test-TS0710_WAKEUP.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include "catch.hpp" -#include "TS0710_WAKEUP.h" -TEST_CASE("test-TS0710_WAKEUP") -{ - TS0710_WAKEUP *_class = new TS0710_WAKEUP(); - - delete _class; -} diff --git a/module-cellular/Modem/ATCommon.cpp b/module-cellular/modem/ATCommon.cpp similarity index 94% rename from module-cellular/Modem/ATCommon.cpp rename to module-cellular/modem/ATCommon.cpp index 8fb73a3aeefc099c936c4c6bb5a0686d4c22494f..4b3bd4ba9db72a94fd07357b545a377af98c12b8 100644 --- a/module-cellular/Modem/ATCommon.cpp +++ b/module-cellular/modem/ATCommon.cpp @@ -7,13 +7,12 @@ #include #include #include -#include -#include // for PRIu32 #include #include "ATStream.hpp" #include using namespace at; +using namespace std::chrono_literals; const std::string Channel::OK = "OK"; const std::string Channel::ERROR = "ERROR"; @@ -66,9 +65,9 @@ Result Channel::cmd(const std::string &cmd, std::chrono::milliseconds timeout, s awaitingResponseFlag.set(); - cmd_init(); + cmdInit(); std::string cmdFixed = formatCommand(cmd); - cmd_send(cmdFixed); + cmdSend(cmdFixed); auto startTime = std::chrono::steady_clock::now(); auto endTime = startTime + timeout; @@ -79,7 +78,7 @@ Result Channel::cmd(const std::string &cmd, std::chrono::milliseconds timeout, s break; } - if (size_t bytesRead = cmd_receive(receiveBuffer.get(), std::chrono::milliseconds{0}); bytesRead > 0) { + if (size_t bytesRead = cmdReceive(receiveBuffer.get(), 0ms); bytesRead > 0) { auto cellularResult = bsp::cellular::CellularResult{receiveBuffer.get(), bytesRead}; if (result = checkResult(cellularResult.getResultCode()); result.code != at::Result::Code::OK) { @@ -97,7 +96,7 @@ Result Channel::cmd(const std::string &cmd, std::chrono::milliseconds timeout, s awaitingResponseFlag.clear(); - cmd_post(); + cmdPost(); cmdLog(cmdFixed, result, timeout); return result; diff --git a/module-cellular/Modem/ATCommon.hpp b/module-cellular/modem/ATCommon.hpp similarity index 100% rename from module-cellular/Modem/ATCommon.hpp rename to module-cellular/modem/ATCommon.hpp diff --git a/module-cellular/Modem/ATParser.cpp b/module-cellular/modem/ATParser.cpp similarity index 89% rename from module-cellular/Modem/ATParser.cpp rename to module-cellular/modem/ATParser.cpp index 11408534a0a1e2d571e2c775811efe9436931ce1..195a1f3f244ac6b2725ac64abd77bf6655e61519 100644 --- a/module-cellular/Modem/ATParser.cpp +++ b/module-cellular/modem/ATParser.cpp @@ -6,17 +6,20 @@ #include "bsp/cellular/bsp_cellular.hpp" #include #include "ticks.hpp" -#include #include #include +using namespace std::chrono_literals; + ATParser::ATParser(bsp::Cellular *cellular) : Channel{new uint8_t[at::defaultReceiveBufferSize]}, cellular(cellular) { + assert(cellular != nullptr); + responseBuffer = xMessageBufferCreate(at::defaultMessageBufferSize); } /// plz see 12.7 summary of urc in documentation -std::vector ATParser::ParseURC() +std::vector ATParser::parseUrc() { size_t maxPos = 0, pos = 0; @@ -56,7 +59,7 @@ std::vector ATParser::ParseURC() return resp; } -at::Result ATParser::ProcessNewData(sys::Service *service, bsp::cellular::CellularResult &cellularResult) +at::Result ATParser::processNewData(sys::Service *service, const bsp::cellular::CellularResult &cellularResult) { at::Result result; @@ -65,7 +68,7 @@ at::Result ATParser::ProcessNewData(sys::Service *service, bsp::cellular::Cellul urcBuffer.append(cellularResult.getDataAsString()); } - auto ret = ParseURC(); + auto ret = parseUrc(); if (awaitingResponseFlag.state()) { if (!xMessageBufferSend(responseBuffer, @@ -109,23 +112,23 @@ at::Result ATParser::ProcessNewData(sys::Service *service, bsp::cellular::Cellul return result; } -void ATParser::cmd_init() +void ATParser::cmdInit() { cpp_freertos::LockGuard lock(mutex); urcBuffer.erase(); } -void ATParser::cmd_send(std::string cmd) +void ATParser::cmdSend(std::string cmd) { cellular->write(const_cast(cmd.c_str()), cmd.size()); } -size_t ATParser::cmd_receive(std::uint8_t *buffer, std::chrono::milliseconds timeout = std::chrono::milliseconds{0}) +size_t ATParser::cmdReceive(std::uint8_t *buffer, std::chrono::milliseconds timeout = 0ms) { return xMessageBufferReceive(responseBuffer, buffer, 256, pdMS_TO_TICKS(timeout.count())); } -void ATParser::cmd_post() +void ATParser::cmdPost() { cpp_freertos::LockGuard lock(mutex); urcBuffer.erase(); diff --git a/module-cellular/Modem/ATParser.hpp b/module-cellular/modem/ATParser.hpp similarity index 73% rename from module-cellular/Modem/ATParser.hpp rename to module-cellular/modem/ATParser.hpp index 16586aed68af38e4d0bb01549bcd5399f1f8ec5f..f1f96433b232bd60f7cdfbfeb780b1f51611ad47 100644 --- a/module-cellular/Modem/ATParser.hpp +++ b/module-cellular/modem/ATParser.hpp @@ -37,15 +37,15 @@ class ATParser : public at::Channel ATParser(bsp::Cellular *cellular); virtual ~ATParser() = default; - at::Result ProcessNewData(sys::Service *service, bsp::cellular::CellularResult &cellularResult); + at::Result processNewData(sys::Service *service, const bsp::cellular::CellularResult &cellularResult); - virtual void cmd_init() override final; - virtual void cmd_send(std::string cmd) override final; - virtual size_t cmd_receive(std::uint8_t *buffer, std::chrono::milliseconds timeout) override final; - virtual void cmd_post() override final; + virtual void cmdInit() override final; + virtual void cmdSend(std::string cmd) override final; + virtual size_t cmdReceive(std::uint8_t *buffer, std::chrono::milliseconds timeout) override final; + virtual void cmdPost() override final; private: - std::vector ParseURC(); + std::vector parseUrc(); bsp::Cellular *cellular = nullptr; MessageBufferHandle_t responseBuffer = nullptr; std::string urcBuffer = {}; diff --git a/module-cellular/Modem/ATStream.cpp b/module-cellular/modem/ATStream.cpp similarity index 99% rename from module-cellular/Modem/ATStream.cpp rename to module-cellular/modem/ATStream.cpp index 6a20dd26a5b595b27e91b0255275bbc50159e783..096fd119155730f621035d5135d0286e3662b2bf 100644 --- a/module-cellular/Modem/ATStream.cpp +++ b/module-cellular/modem/ATStream.cpp @@ -143,7 +143,7 @@ namespace at * the wrong one may result in returning incorrect / incomplete values. * It only applies to a group of specific commands like AT + QPING, in which the result (OK) * is returned at the beginning, followed by information. This could happen only if we not fit - * in one return of cmd_receive return. + * in one return of cmdReceive return. */ if (rxCount == 0) { return true; diff --git a/module-cellular/Modem/ATStream.hpp b/module-cellular/modem/ATStream.hpp similarity index 100% rename from module-cellular/Modem/ATStream.hpp rename to module-cellular/modem/ATStream.hpp diff --git a/module-cellular/Modem/ATURCStream.cpp b/module-cellular/modem/ATURCStream.cpp similarity index 100% rename from module-cellular/Modem/ATURCStream.cpp rename to module-cellular/modem/ATURCStream.cpp diff --git a/module-cellular/Modem/ATURCStream.hpp b/module-cellular/modem/ATURCStream.hpp similarity index 100% rename from module-cellular/Modem/ATURCStream.hpp rename to module-cellular/modem/ATURCStream.hpp diff --git a/module-cellular/Modem/BaseChannel.hpp b/module-cellular/modem/BaseChannel.hpp similarity index 72% rename from module-cellular/Modem/BaseChannel.hpp rename to module-cellular/modem/BaseChannel.hpp index cc23afd427ec0fe0df138be7b423cc0d471e1283..abdabceb46cb8c207d78d871927148dabee36544 100644 --- a/module-cellular/Modem/BaseChannel.hpp +++ b/module-cellular/modem/BaseChannel.hpp @@ -31,10 +31,10 @@ namespace at /// { virtual void cmdLog(std::string cmd, const Result &result, std::chrono::milliseconds timeout) {} - virtual void cmd_init() = 0; - virtual void cmd_send(std::string cmd) = 0; - virtual size_t cmd_receive(std::uint8_t *buffer, std::chrono::milliseconds timeoutMs) = 0; - virtual void cmd_post() = 0; + virtual void cmdInit() = 0; + virtual void cmdSend(std::string cmd) = 0; + virtual size_t cmdReceive(std::uint8_t *buffer, std::chrono::milliseconds timeoutMs) = 0; + virtual void cmdPost() = 0; /// } }; } // namespace at diff --git a/module-cellular/Modem/README.md b/module-cellular/modem/README.md similarity index 92% rename from module-cellular/Modem/README.md rename to module-cellular/modem/README.md index 231c1c9c4b1ec94458e13f37708dbf58088d654f..b6434db1e7b52ef82be5d244361da4fe4a786f03 100644 --- a/module-cellular/Modem/README.md +++ b/module-cellular/modem/README.md @@ -9,11 +9,6 @@ 5. [Cellular result structures](#result) 6. [Error codes](#errors) -## History -| Authors | Change description | Status | Modification date | -| ----------------- | ------------------------- | ------ | ----------------- | -| Maciej Janicki | Initial version | Draft | 2021.03.24 | - ## Modes Cellular operates in three modes: - AT, diff --git a/module-cellular/Modem/doc/ATStream.md b/module-cellular/modem/doc/ATStream.md similarity index 100% rename from module-cellular/Modem/doc/ATStream.md rename to module-cellular/modem/doc/ATStream.md diff --git a/module-cellular/Modem/doc/Images/at_mode.svg b/module-cellular/modem/doc/Images/at_mode.svg similarity index 100% rename from module-cellular/Modem/doc/Images/at_mode.svg rename to module-cellular/modem/doc/Images/at_mode.svg diff --git a/module-cellular/Modem/doc/Images/at_mode.uml b/module-cellular/modem/doc/Images/at_mode.uml similarity index 100% rename from module-cellular/Modem/doc/Images/at_mode.uml rename to module-cellular/modem/doc/Images/at_mode.uml diff --git a/module-cellular/Modem/doc/Images/atstream.png b/module-cellular/modem/doc/Images/atstream.png similarity index 100% rename from module-cellular/Modem/doc/Images/atstream.png rename to module-cellular/modem/doc/Images/atstream.png diff --git a/module-cellular/Modem/doc/Images/cellular_mux_read.png b/module-cellular/modem/doc/Images/cellular_mux_read.png similarity index 100% rename from module-cellular/Modem/doc/Images/cellular_mux_read.png rename to module-cellular/modem/doc/Images/cellular_mux_read.png diff --git a/module-cellular/Modem/doc/Images/cellular_result_struct.png b/module-cellular/modem/doc/Images/cellular_result_struct.png similarity index 100% rename from module-cellular/Modem/doc/Images/cellular_result_struct.png rename to module-cellular/modem/doc/Images/cellular_result_struct.png diff --git a/module-cellular/Modem/doc/Images/cellular_result_struct.uml b/module-cellular/modem/doc/Images/cellular_result_struct.uml similarity index 100% rename from module-cellular/Modem/doc/Images/cellular_result_struct.uml rename to module-cellular/modem/doc/Images/cellular_result_struct.uml diff --git a/module-cellular/Modem/doc/Images/class_channel.png b/module-cellular/modem/doc/Images/class_channel.png similarity index 100% rename from module-cellular/Modem/doc/Images/class_channel.png rename to module-cellular/modem/doc/Images/class_channel.png diff --git a/module-cellular/Modem/doc/Images/cmx_mode.uml b/module-cellular/modem/doc/Images/cmx_mode.uml similarity index 100% rename from module-cellular/Modem/doc/Images/cmx_mode.uml rename to module-cellular/modem/doc/Images/cmx_mode.uml diff --git a/module-cellular/Modem/doc/Images/current_volte_on.png b/module-cellular/modem/doc/Images/current_volte_on.png similarity index 100% rename from module-cellular/Modem/doc/Images/current_volte_on.png rename to module-cellular/modem/doc/Images/current_volte_on.png diff --git a/module-cellular/Modem/doc/Images/dma_result_struct.png b/module-cellular/modem/doc/Images/dma_result_struct.png similarity index 100% rename from module-cellular/Modem/doc/Images/dma_result_struct.png rename to module-cellular/modem/doc/Images/dma_result_struct.png diff --git a/module-cellular/Modem/doc/Images/dma_result_struct.uml b/module-cellular/modem/doc/Images/dma_result_struct.uml similarity index 100% rename from module-cellular/Modem/doc/Images/dma_result_struct.uml rename to module-cellular/modem/doc/Images/dma_result_struct.uml diff --git a/module-cellular/Modem/doc/Images/mudita_logo.png b/module-cellular/modem/doc/Images/mudita_logo.png similarity index 100% rename from module-cellular/Modem/doc/Images/mudita_logo.png rename to module-cellular/modem/doc/Images/mudita_logo.png diff --git a/module-cellular/Modem/doc/Images/mux_mode.svg b/module-cellular/modem/doc/Images/mux_mode.svg similarity index 100% rename from module-cellular/Modem/doc/Images/mux_mode.svg rename to module-cellular/modem/doc/Images/mux_mode.svg diff --git a/module-cellular/Modem/doc/Images/single_cmd.uml b/module-cellular/modem/doc/Images/single_cmd.uml similarity index 100% rename from module-cellular/Modem/doc/Images/single_cmd.uml rename to module-cellular/modem/doc/Images/single_cmd.uml diff --git a/module-cellular/Modem/doc/Images/single_cmd_transmission.png b/module-cellular/modem/doc/Images/single_cmd_transmission.png similarity index 100% rename from module-cellular/Modem/doc/Images/single_cmd_transmission.png rename to module-cellular/modem/doc/Images/single_cmd_transmission.png diff --git a/module-cellular/Modem/doc/Images/volte_on.png b/module-cellular/modem/doc/Images/volte_on.png similarity index 100% rename from module-cellular/Modem/doc/Images/volte_on.png rename to module-cellular/modem/doc/Images/volte_on.png diff --git a/module-cellular/Modem/doc/scripts/atstream.pu b/module-cellular/modem/doc/scripts/atstream.pu similarity index 100% rename from module-cellular/Modem/doc/scripts/atstream.pu rename to module-cellular/modem/doc/scripts/atstream.pu diff --git a/module-cellular/Modem/doc/scripts/class_channel.pu b/module-cellular/modem/doc/scripts/class_channel.pu similarity index 75% rename from module-cellular/Modem/doc/scripts/class_channel.pu rename to module-cellular/modem/doc/scripts/class_channel.pu index bf6050569b1f8c993fcf140ea0f3353ba55d1343..4acefac09fd840d3a26c41e7fc97e86bd4c18425 100644 --- a/module-cellular/Modem/doc/scripts/class_channel.pu +++ b/module-cellular/modem/doc/scripts/class_channel.pu @@ -6,7 +6,7 @@ BaseChannel <|-- Channel Channel ..> ATStream: Channel use ATStream -Channel <|-- DLC_channel +Channel <|-- DLCChannel Channel <|-- ATParser -@enduml \ No newline at end of file +@enduml diff --git a/module-cellular/Modem/TS0710/TS0710.cpp b/module-cellular/modem/mux/CellularMux.cpp similarity index 70% rename from module-cellular/Modem/TS0710/TS0710.cpp rename to module-cellular/modem/mux/CellularMux.cpp index a4d9efcd1b5f56fda22ae66aead8b6b00b1b6c51..34d96fb1dd05515cd891986422ae3a98ea3560d0 100644 --- a/module-cellular/Modem/TS0710/TS0710.cpp +++ b/module-cellular/modem/mux/CellularMux.cpp @@ -1,18 +1,22 @@ // Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md -#include "TS0710.h" +#include "CellularMux.h" + #include #include -#include "bsp/cellular/bsp_cellular.hpp" -#include "bsp/cellular/CellularResult.hpp" -#include "projdefs.h" -#include + +#include +#include +#include + #include #include -#include + +#include + +#include #include -#include #include #include @@ -47,33 +51,33 @@ std::map ATPortSpeeds_text = {{PortSpeed_e::PS9600, 9 static constexpr std::uint16_t threadSizeWords = 2048; -TS0710::TS0710(PortSpeed_e portSpeed, sys::Service *parent) +CellularMux::CellularMux(PortSpeed_e portSpeed, sys::Service *parent) { - Init(portSpeed, parent); + init(portSpeed, parent); } -TS0710::~TS0710() +CellularMux::~CellularMux() { for (auto it : channels) { delete it; } channels.clear(); - TS0710_CLOSE pv_TS0710_Close = TS0710_CLOSE(); - mode = Mode::AT; - if (taskHandle) { + + if (taskHandle != nullptr) { vTaskDelete(taskHandle); } + mode = Mode::AT; delete parser; } -void TS0710::Init(PortSpeed_e portSpeed, sys::Service *parent) +void CellularMux::init(PortSpeed_e portSpeed, sys::Service *parent) { - SetStartParams(portSpeed); + setStartParams(portSpeed); - pv_cellular = bsp::Cellular::create(SERIAL_PORT, portSpeed).value_or(nullptr); - parser = new ATParser(pv_cellular.get()); - pv_parent = parent; + cellular = bsp::Cellular::create(SERIAL_PORT, portSpeed).value_or(nullptr); + parser = new ATParser(cellular.get()); + parentService = parent; if (auto flushed = flushReceiveData(); flushed > 0) { LOG_INFO("Discarded initial %lu bytes sent by modem", @@ -83,17 +87,17 @@ void TS0710::Init(PortSpeed_e portSpeed, sys::Service *parent) LOG_DEBUG("Nothing to discard"); } - constexpr auto workerName = "TS0710Worker"; + constexpr auto workerName = "CellularMux"; - BaseType_t task_error = + BaseType_t taskError = xTaskCreate(workerTaskFunction, workerName, threadSizeWords, this, taskPriority, &taskHandle); - if (task_error != pdPASS) { + if (taskError != pdPASS) { LOG_ERROR("Failed to start %s task", workerName); return; } } -void TS0710::SetStartParams(PortSpeed_e portSpeed) +void CellularMux::setStartParams(PortSpeed_e portSpeed) { startParams.PortSpeed = portSpeed; startParams.MaxFrameSize = 127; // maximum for Basic mode @@ -104,9 +108,9 @@ void TS0710::SetStartParams(PortSpeed_e portSpeed) startParams.ErrRecovWindowSize = 2; // 2 default } -TS0710_Frame::frame_t createCMUXExitFrame() +CellularMuxFrame::frame_t createCMUXExitFrame() { - TS0710_Frame::frame_t frame; + CellularMuxFrame::frame_t frame; frame.Address = 0 | static_cast(MuxDefines ::GSM0710_CR); frame.Control = TypeOfFrame_e::UIH; frame.data.push_back(static_cast(MuxDefines::GSM0710_CONTROL_CLD) | @@ -140,7 +144,7 @@ const char *c_str(BaudTestStep step) } } -bool BaudDetectTestAT(ATParser *parser, BaudTestStep &step, BaudTestStep nextStep) +bool baudDetectTestAT(ATParser *parser, BaudTestStep &step, BaudTestStep nextStep) { if (parser != nullptr) { LOG_DEBUG("=> Baud detection step: %s -> %s", c_str(step), c_str(nextStep)); @@ -152,20 +156,20 @@ bool BaudDetectTestAT(ATParser *parser, BaudTestStep &step, BaudTestStep nextSte return false; } -void CloseCmux(std::unique_ptr &pv_cellular) +void closeCMux(std::unique_ptr &pv_cellular) { LOG_INFO("Closing mux mode"); - TS0710_Frame::frame_t frame = createCMUXExitFrame(); - pv_cellular->write((void *)frame.serialize().data(), frame.serialize().size()); + CellularMuxFrame::frame_t frame = createCMUXExitFrame(); + pv_cellular->write(static_cast(frame.serialize().data()), frame.serialize().size()); vTaskDelay(1000); // GSM module needs some time to close multiplexer } -void TS0710::setMode(TS0710::Mode mode) +void CellularMux::setMode(CellularMux::Mode newMode) { - this->mode = mode; + this->mode = newMode; } -TS0710::ConfState TS0710::BaudDetectOnce() +CellularMux::ConfState CellularMux::baudDetectOnce() { bool result = false; BaudTestStep lastStep = BaudTestStep::baud_NotFound; @@ -174,27 +178,27 @@ TS0710::ConfState TS0710::BaudDetectOnce() while (!result) { switch (step) { case BaudTestStep::baud460800_NoCmux: - pv_cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS460800]); + cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS460800]); lastStep = step; - result = BaudDetectTestAT(parser, step, BaudTestStep::baud460800_Cmux); + result = baudDetectTestAT(parser, step, BaudTestStep::baud460800_Cmux); break; case BaudTestStep::baud460800_Cmux: - CloseCmux(pv_cellular); + closeCMux(cellular); lastStep = step; - result = BaudDetectTestAT(parser, step, BaudTestStep::baud115200_NoCmux); + result = baudDetectTestAT(parser, step, BaudTestStep::baud115200_NoCmux); break; case BaudTestStep::baud115200_NoCmux: - pv_cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS115200]); + cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS115200]); lastStep = step; - result = BaudDetectTestAT(parser, step, BaudTestStep::baud115200_Cmux); + result = baudDetectTestAT(parser, step, BaudTestStep::baud115200_Cmux); break; case BaudTestStep::baud115200_Cmux: - CloseCmux(pv_cellular); + closeCMux(cellular); lastStep = step; - result = BaudDetectTestAT(parser, step, BaudTestStep::baud_NotFound); + result = baudDetectTestAT(parser, step, BaudTestStep::baud_NotFound); break; case BaudTestStep::baud_NotFound: - pv_cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS115200]); // set port speed to default 115200 + cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS115200]); // set port speed to default 115200 LOG_ERROR("No Baud found for modem."); return ConfState::Failure; break; @@ -204,29 +208,29 @@ TS0710::ConfState TS0710::BaudDetectOnce() return ConfState::Success; } -TS0710::ConfState TS0710::BaudDetectProcedure(uint16_t timeout_s) +CellularMux::ConfState CellularMux::baudDetectProcedure(uint16_t timeout_s) { at::Result ret; - bool timed_out = false; - auto timeout_ticks = cpp_freertos::Ticks::GetTicks() + pdMS_TO_TICKS(timeout_s * 1000); + bool timedOut = false; + auto timeoutTicks = cpp_freertos::Ticks::GetTicks() + pdMS_TO_TICKS(timeout_s * 1000); - while (!timed_out) { - auto baud_result = BaudDetectOnce(); - timed_out = cpp_freertos::Ticks::GetTicks() > timeout_ticks; + while (!timedOut) { + auto baud_result = baudDetectOnce(); + timedOut = cpp_freertos::Ticks::GetTicks() > timeoutTicks; if (baud_result == ConfState::Success) { return ConfState::Success; } } - pv_cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS115200]); // set port speed to default 115200 + cellular->setSpeed(ATPortSpeeds_text[PortSpeed_e::PS115200]); // set port speed to default 115200 LOG_ERROR("No Baud found."); return ConfState::Failure; } -TS0710::ConfState TS0710::ConfProcedure() +CellularMux::ConfState CellularMux::confProcedure() { LOG_DEBUG("Configuring modem..."); - auto flowCmd = hardwareControlFlowEnable ? (at::AT::FLOW_CTRL_ON) : (at::AT::FLOW_CTRL_OFF); + auto flowCmd = (at::AT::FLOW_CTRL_ON); if (!parser->cmd(flowCmd)) { return ConfState::Failure; } @@ -260,17 +264,18 @@ TS0710::ConfState TS0710::ConfProcedure() } } - bool timed_out = false; - constexpr uint32_t qsclkTmeout = 30; - const auto qsclkTmeoutTicks = - cpp_freertos::Ticks::GetTicks() + pdMS_TO_TICKS(qsclkTmeout * utils::time::milisecondsInSecond); - while (!timed_out) { + bool timedOut = false; + constexpr uint32_t qsclkTimeout = 30; + const auto qsclkTimeoutTicks = + cpp_freertos::Ticks::GetTicks() + pdMS_TO_TICKS(qsclkTimeout * utils::time::milisecondsInSecond); + + while (!timedOut) { if (parser->cmd(at::AT::QSCLK_ON)) { break; } vTaskDelay(pdMS_TO_TICKS(utils::time::milisecondsInSecond)); - timed_out = cpp_freertos::Ticks::GetTicks() > qsclkTmeoutTicks; - if (timed_out) { + timedOut = cpp_freertos::Ticks::GetTicks() > qsclkTimeoutTicks; + if (timedOut) { return ConfState::Failure; } } @@ -278,7 +283,7 @@ TS0710::ConfState TS0710::ConfProcedure() return ConfState ::Success; } -TS0710::ConfState TS0710::AudioConfProcedure() +CellularMux::ConfState CellularMux::audioConfProcedure() { auto ret = parser->cmd(at::AT::QDAI); // There is possibility for SendATCommand to capture invalid response (it can be ERROR or async URC) @@ -287,7 +292,7 @@ TS0710::ConfState TS0710::AudioConfProcedure() if (!ret) { return ConfState::Failure; } - else if (ret.response[0].compare("+QDAI: 1,0,0,3,0,1,1,1") == 0) { + else if (ret.response[0] == "+QDAI: 1,0,0,3,0,1,1,1") { if (!parser->cmd(at::AT::QRXGAIN)) { return ConfState::Failure; } @@ -304,14 +309,14 @@ TS0710::ConfState TS0710::AudioConfProcedure() return ConfState::Failure; } else { - pv_cellular->restart(); + cellular->restart(); LOG_DEBUG("GSM module first run, performing reset..."); return ConfState::ModemNeedsReset; } } } -TS0710::ConfState TS0710::StartMultiplexer() +CellularMux::ConfState CellularMux::startMultiplexer() { LOG_DEBUG("Configuring multiplexer..."); @@ -366,11 +371,7 @@ TS0710::ConfState TS0710::StartMultiplexer() mode = Mode::CMUX_SETUP; - TS0710_START TS0710_Start{TS0710_START::Mode_e::Basic, startParams, pv_cellular.get()}; - // wait for confirmation - if (TS0710_Start.ConnectionStatus()) { - channels.push_back(TS0710_Start.getCtrlChannel()); // store control channel - } + openChannel(Channel::Control); controlCallback = [this](std::string &data) { auto frameData = data; @@ -382,36 +383,40 @@ TS0710::ConfState TS0710::StartMultiplexer() switch (frameData[0]) { case 0xE3: { // MSC LOG_PRINTF("[MSC ch #%i] ", frameData[2] >> 2); - if (frameData[3] & 0x80) + if ((frameData[3] & static_cast(ControlSignal::DataValid)) != 0) { LOG_PRINTF("DV "); - if (frameData[3] & 0x40) + } + if ((frameData[3] & static_cast(ControlSignal::IncomingCallIndicator)) != 0) { LOG_PRINTF("IC "); - if (frameData[3] & 0x08) + } + if ((frameData[3] & static_cast(ControlSignal::ReadyToReceive)) != 0) { LOG_PRINTF("RTR "); - if (frameData[3] & 0x04) { + } + if ((frameData[3] & static_cast(ControlSignal::ReadyToCommunicate)) != 0) { LOG_PRINTF("RTC "); this->getCellular()->setSendingAllowed(true); } - else + else { this->getCellular()->setSendingAllowed(false); - if (frameData[3] & 0x02) + } + if ((frameData[3] & static_cast(ControlSignal::FlowControl)) != 0) { LOG_PRINTF("FC "); - + } LOG_PRINTF("\n"); } break; } }; - OpenChannel(Channel::Commands); - OpenChannel(Channel::Notifications); - OpenChannel(Channel::Data); - LOG_DEBUG("[TS0710] Channels open"); + openChannel(Channel::Commands); + openChannel(Channel::Notifications); + openChannel(Channel::Data); + LOG_DEBUG("Channels open"); mode = Mode::CMUX; if (auto channel = get(Channel::Commands); channel != nullptr) { // Route URCs to second (Notifications) MUX channel - LOG_DEBUG("[TS0710] Setting URC Channel"); + LOG_DEBUG("Setting URC Channel"); channel->cmd(at::AT::SET_URC_CHANNEL); LOG_DEBUG("Sending test ATI"); auto res = channel->cmd(at::AT::SW_INFO); @@ -420,8 +425,8 @@ TS0710::ConfState TS0710::StartMultiplexer() } res = channel->cmd(at::AT::CSQ); if (res) { - auto beg = res.response[0].find(" "); - auto end = res.response[0].find(",", 1); + auto beg = res.response[0].find(' '); + auto end = res.response[0].find(',', 1); auto input_val = res.response[0].substr(beg + 1, end - beg - 1); auto strength = 0; try { @@ -435,7 +440,7 @@ TS0710::ConfState TS0710::StartMultiplexer() if (signalStrength.isValid()) { Store::GSM::get()->setSignalStrength(signalStrength.data); auto msg = std::make_shared(); - pv_parent->bus.sendMulticast(msg, sys::BusChannel::ServiceCellularNotifications); + parentService->bus.sendMulticast(std::move(msg), sys::BusChannel::ServiceCellularNotifications); } } else { @@ -447,13 +452,13 @@ TS0710::ConfState TS0710::StartMultiplexer() return ConfState::Failure; } - LOG_DEBUG("[TS0710] Mux started"); + LOG_DEBUG("Mux started"); return ConfState::Success; } -void TS0710::sendFrameToChannel(bsp::cellular::CellularResult &resultStruct) +void CellularMux::sendFrameToChannel(bsp::cellular::CellularResult &resultStruct) { - auto frame = TS0710_Frame{resultStruct.getData()}; + auto frame = CellularMuxFrame{resultStruct.getData()}; for (auto chan : getChannels()) { if (frame.getFrameDLCI() == chan->getDLCI()) { @@ -465,23 +470,23 @@ void TS0710::sendFrameToChannel(bsp::cellular::CellularResult &resultStruct) resultStruct.setData(frame.getData()); } - if (frame.getFrameStatus() != TS0710_Frame::OK) { + if (frame.getFrameStatus() != CellularMuxFrame::OK) { resultStruct.setResultCode(bsp::cellular::CellularResultCode::CMUXFrameError); } - chan->ParseInputData(&resultStruct); + chan->parseInputData(&resultStruct); return; } } } -void TS0710::parseCellularResultCMUX(bsp::cellular::CellularDMAResultStruct &result) +void CellularMux::parseCellularResultCMUX(bsp::cellular::CellularDMAResultStruct &result) { static std::vector currentFrame; static bool frameStartDetected = false; for (auto i = 0U; i < result.dataSize; ++i) { - uint8_t character = result.data[i]; + uint8_t character = gsl::at(result.data, i); if (frameStartDetected || character == TS0710_FLAG) { currentFrame.push_back(character); @@ -490,7 +495,7 @@ void TS0710::parseCellularResultCMUX(bsp::cellular::CellularDMAResultStruct &res if (currentFrame.size() == 2) { currentFrame.erase(currentFrame.begin()); } - if (TS0710_Frame::isComplete(currentFrame)) { + if (CellularMuxFrame::isComplete(currentFrame)) { frameStartDetected = false; bsp::cellular::CellularResult cellularResult{{result.resultCode, currentFrame}}; sendFrameToChannel(cellularResult); @@ -504,36 +509,36 @@ void TS0710::parseCellularResultCMUX(bsp::cellular::CellularDMAResultStruct &res } } -size_t TS0710::flushReceiveData() +size_t CellularMux::flushReceiveData() { auto flushed = 0U; constexpr auto flushTimeout = std::chrono::milliseconds{20}; bsp::cellular::CellularDMAResultStruct dummyResult; do { - flushed += pv_cellular->read(&dummyResult, dummyResult.getMaxSize(), flushTimeout); + flushed += cellular->read(&dummyResult, bsp::cellular::CellularDMAResultStruct::getMaxSize(), flushTimeout); } while (dummyResult.resultCode == bsp::cellular::CellularResultCode::ReceivedAndFull); return flushed; } -void TS0710::processError(bsp::cellular::CellularDMAResultStruct &result) +void CellularMux::processError(bsp::cellular::CellularDMAResultStruct &result) { bsp::cellular::CellularResult cellularResult{{result.resultCode, {}}}; - if (mode == TS0710::Mode::AT) { - parser->ProcessNewData(pv_parent, cellularResult); + if (mode == CellularMux::Mode::AT) { + parser->processNewData(parentService, cellularResult); } - else if (mode == TS0710::Mode::CMUX || mode == TS0710::Mode::CMUX_SETUP) { + else if (mode == CellularMux::Mode::CMUX || mode == CellularMux::Mode::CMUX_SETUP) { sendFrameToChannel(cellularResult); } } -void TS0710::processData(bsp::cellular::CellularDMAResultStruct &result) +void CellularMux::processData(bsp::cellular::CellularDMAResultStruct &result) { - if (mode == TS0710::Mode::AT) { + if (mode == CellularMux::Mode::AT) { bsp::cellular::CellularResult cellularResult{result}; - parser->ProcessNewData(pv_parent, cellularResult); + parser->processNewData(parentService, cellularResult); } - else if (mode == TS0710::Mode::CMUX || mode == TS0710::Mode::CMUX_SETUP) { + else if (mode == CellularMux::Mode::CMUX || mode == CellularMux::Mode::CMUX_SETUP) { parseCellularResultCMUX(result); } } @@ -542,14 +547,15 @@ void TS0710::processData(bsp::cellular::CellularDMAResultStruct &result) { LOG_DEBUG("Worker start"); - constexpr auto readTimeout = std::chrono::minutes{3600}; - TS0710 *inst = static_cast(ptr); + constexpr auto readTimeout = std::chrono::seconds{1}; + CellularMux *inst = static_cast(ptr); + bsp::cellular::CellularDMAResultStruct result{}; while (true) { result.resultCode = bsp::cellular::CellularResultCode::ReceivedNoData; - inst->pv_cellular->read(&result, bsp::cellular::CellularDMAResultStruct::getMaxSize(), readTimeout); + inst->cellular->read(&result, bsp::cellular::CellularDMAResultStruct::getMaxSize(), readTimeout); switch (result.resultCode) { case bsp::cellular::CellularResultCode::ReceivedAndFull: @@ -577,68 +583,68 @@ void TS0710::processData(bsp::cellular::CellularDMAResultStruct &result) } } -void TS0710::SelectAntenna(bsp::cellular::antenna antenna) +void CellularMux::selectAntenna(bsp::cellular::antenna antenna) { - pv_cellular->selectAntenna(antenna); + cellular->selectAntenna(antenna); } -bsp::cellular::antenna TS0710::GetAntenna() +bsp::cellular::antenna CellularMux::getAntenna() { - return pv_cellular->getAntenna(); + return cellular->getAntenna(); } -void TS0710::InformModemHostWakeup(void) +void CellularMux::informModemHostWakeup(void) { - return pv_cellular->informModemHostWakeup(); + return cellular->informModemHostWakeup(); } -bool TS0710::IsModemActive(void) +bool CellularMux::isModemActive(void) { return bsp::cellular::status::getStatus() == bsp::cellular::status::value::ACTIVE; } -void TS0710::TurnOnModem(void) +void CellularMux::turnOnModem(void) { - return pv_cellular->powerUp(); + return cellular->powerUp(); } -void TS0710::ResetModem(void) +void CellularMux::resetModem(void) { - return pv_cellular->restart(); + return cellular->restart(); } -void TS0710::TurnOffModem(void) +void CellularMux::turnOffModem(void) { - return pv_cellular->powerDown(); + return cellular->powerDown(); } -void TS0710::EnterSleepMode(void) +void CellularMux::enterSleepMode(void) { - return pv_cellular->enterSleep(); + return cellular->enterSleep(); } -void TS0710::ExitSleepMode(void) +void CellularMux::exitSleepMode(void) { - return pv_cellular->exitSleep(); + return cellular->exitSleep(); } -void TS0710::RegisterCellularDevice(void) +void CellularMux::registerCellularDevice(void) { - auto deviceRegistrationMsg = std::make_shared(pv_cellular->getCellularDevice()); - pv_parent->bus.sendUnicast(std::move(deviceRegistrationMsg), service::name::system_manager); + auto deviceRegistrationMsg = std::make_shared(cellular->getCellularDevice()); + parentService->bus.sendUnicast(std::move(deviceRegistrationMsg), service::name::system_manager); } -[[nodiscard]] auto TS0710::getLastCommunicationTimestamp() const noexcept -> TickType_t +[[nodiscard]] auto CellularMux::getLastCommunicationTimestamp() const noexcept -> TickType_t { - return pv_cellular->getLastCommunicationTimestamp(); + return cellular->getLastCommunicationTimestamp(); } -[[nodiscard]] auto TS0710::isCellularInSleepMode() const noexcept -> bool +[[nodiscard]] auto CellularMux::isCellularInSleepMode() const noexcept -> bool { - return pv_cellular->isCellularInSleepMode(); + return cellular->isCellularInSleepMode(); } -TS0710::ConfState TS0710::setupEchoCanceller(EchoCancellerStrength strength) +CellularMux::ConfState CellularMux::setupEchoCanceller(EchoCancellerStrength strength) { switch (strength) { @@ -758,7 +764,99 @@ TS0710::ConfState TS0710::setupEchoCanceller(EchoCancellerStrength strength) if (!parser->cmd(at::factory(at::AT::QEEC) + "33,896")) { return ConfState::Failure; } - }; + } return ConfState::Success; } + +DLCChannel *CellularMux::get(Channel selectedChannel) +{ + for (auto channel : channels) { + if (channel != nullptr && static_cast(channel->getDLCI()) == selectedChannel) { + return channel; + } + } + return nullptr; +} + +std::vector &CellularMux::getChannels() +{ + return channels; +} + +bool CellularMux::openChannel(Channel channelIndex) +{ + auto channel = new DLCChannel(static_cast(channelIndex), name(channelIndex), cellular.get()); + channels.push_back(channel); + + if (!channel->init()) { + channels.pop_back(); + delete channel; + return false; + } + + return true; +} + +void CellularMux::closeChannels() +{ + for (auto &it : channels) { + delete it; + } + channels.clear(); + mode = Mode::AT; +} + +bool CellularMux::searchATCommandResponse(const std::vector &response, + const std::string &str, + size_t numberOfExpectedTokens, + logger_level level) +{ + const size_t numberOfTokens = response.size(); + if (searchForString(response, str) && (numberOfExpectedTokens == 0 || numberOfTokens == numberOfExpectedTokens)) { + return true; + } + + std::string resp; + for (const std::string &s : response) { + resp.append(s); + } + + LOG_CUSTOM(level, "Invalid response: %s", resp.c_str()); + // numberOfExpectedTokens == 0, means do not validate number of tokens + LOG_CUSTOM(level, + " - Number of tokens %u, number of expected tokens %u", + static_cast(numberOfTokens), + static_cast(numberOfExpectedTokens)); + return false; +} + +bool CellularMux::searchForString(const std::vector &response, const std::string &str) +{ + for (const auto &s : response) { + if (s == str) { + return true; + } + } + return false; +} + +MuxParameters CellularMux::getStartParams() const noexcept +{ + return startParams; +} + +bsp::Cellular *CellularMux::getCellular() +{ + return cellular.get(); +} + +ATParser *CellularMux::getParser() +{ + return parser; +} + +bool CellularMux::checkATCommandPrompt(const std::vector &response, logger_level level) +{ + return searchATCommandResponse(response, ">", 0, level); +} diff --git a/module-cellular/Modem/TS0710/TS0710.h b/module-cellular/modem/mux/CellularMux.h similarity index 78% rename from module-cellular/Modem/TS0710/TS0710.h rename to module-cellular/modem/mux/CellularMux.h index 1e12f7679ae0b55686a399d69cc3d333b3f2c6f0..92eb8e6689ed76e19970a1db7c8279b011dcc982 100644 --- a/module-cellular/Modem/TS0710/TS0710.h +++ b/module-cellular/modem/mux/CellularMux.h @@ -191,18 +191,14 @@ repeated until a response is obtained or action is taken by a higher layer. #include #include #include -#include - -#include "TS0710_START.h" -#include "TS0710_CLOSE.h" -#include "TS0710_SLEEP.h" -#include "TS0710_TEST.h" -#include "TS0710_WAKEUP.h" -#include "TS0710_types.h" -#include "TS0710_Frame.h" - -#include "DLC_channel.h" -#include "Modem/ATParser.hpp" +#include + +#include "CellularMuxTypes.h" +#include "CellularMuxFrame.h" +#include "MuxParameters.hpp" + +#include "DLCChannel.h" +#include "modem/ATParser.hpp" #include "Service/Service.hpp" #include @@ -224,75 +220,53 @@ namespace bsp [[noreturn]] void workerTaskFunction(void *ptr); -class TS0710 +class CellularMux { public: enum class Channel : unsigned char { - None = 0, + Control = 0, Commands = 1, Notifications = 2, Data = 3, + None = 4, }; - - static std::string name(enum Channel name) - { - switch (name) { - case Channel::None: - return "None"; - case Channel::Commands: - return "Commands"; - case Channel::Notifications: - return "Notifications"; - case Channel::Data: - return "Data"; - } - return ""; - } - enum class Mode { AT, /// AT raw text mode CMUX_SETUP, /// Modem is switching from AT to CMUX CMUX /// multiplexer mode enabled }; - enum class ConfState { Success, Failure, ModemNeedsReset, - PowerUp }; - - void setMode(Mode mode); + enum class ControlSignal : uint8_t + { + FlowControl = 0x02, + ReadyToCommunicate = 0x04, + ReadyToReceive = 0x08, + IncomingCallIndicator = 0x40, + DataValid = 0x80, + }; private: Mode mode = Mode::AT; - std::vector channels; + + MuxParameters startParams; + sys::Service *parentService{}; + std::unique_ptr cellular; + ATParser *parser{}; const uint32_t taskPriority = 0; xTaskHandle taskHandle = nullptr; - std::unique_ptr pv_cellular; - ATParser *parser; + std::vector channels; + DLCChannel::Callback_t controlCallback = nullptr; - int CloseMultiplexer(); - static constexpr auto hardwareControlFlowEnable = true; - - bool searchForString(const std::vector &response, std::string str) - { - for (std::string s : response) { - if (s == str) - return true; - } - return false; - } - - TS0710_START::START_SystemParameters_t startParams; - sys::Service *pv_parent; - - DLC_channel::Callback_t controlCallback = nullptr; + friend void workerTaskFunction(void *ptr); enum class EchoCancellerStrength { @@ -304,6 +278,7 @@ class TS0710 friend void workerTaskFunction(void *ptr); ConfState setupEchoCanceller(EchoCancellerStrength strength); + void parseCellularResultCMUX(bsp::cellular::CellularDMAResultStruct &result); size_t flushReceiveData(); void processData(bsp::cellular::CellularDMAResultStruct &result); @@ -311,71 +286,33 @@ class TS0710 void sendFrameToChannel(bsp::cellular::CellularResult &resultStruct); public: + CellularMux(PortSpeed_e portSpeed, sys::Service *parent); + CellularMux() = delete; + + ~CellularMux(); + + void init(PortSpeed_e portSpeed, sys::Service *parent); + void setStartParams(PortSpeed_e portSpeed); + void setMode(Mode mode); + /// @brief get Channel by index /// @param channel enum Channel /// @return pointer to channel or nullptr if such channel doesn't exist (nullptr return should never happen how - /// because all channels are opened once on start) - DLC_channel *get(Channel chanel_enum) - { - for (auto channel : channels) { - if (channel != nullptr && static_cast(channel->getDLCI()) == chanel_enum) { - return channel; - } - } - return nullptr; - } - - std::vector &getChannels() - { - return channels; - } + DLCChannel *get(Channel selectedChannel); + std::vector &getChannels(); + bool openChannel(Channel channelIndex); + void closeChannels(); - DLC_channel *OpenChannel(Channel channelIndex) - { - auto *channel = new DLC_channel(static_cast(channelIndex), name(channelIndex), pv_cellular.get()); - channels.push_back(channel); - - if (!channel->init()) { - channels.pop_back(); - delete channel; - } + ConfState baudDetectOnce(); + ConfState baudDetectProcedure(uint16_t timeout_s = 30); + ConfState confProcedure(); + ConfState audioConfProcedure(); + ConfState startMultiplexer(); - return channels.back(); - } - - void CloseChannels() - { - for (auto &it : channels) { - delete it; - } - channels.clear(); - TS0710_CLOSE pv_TS0710_Close = TS0710_CLOSE(); - mode = Mode::AT; - } - - DLCI_t GetLastDLCI() - { - return static_cast(channels.size() == 0 ? 0 : channels.size() - 1); - } - - ConfState BaudDetectOnce(); - ConfState BaudDetectProcedure(uint16_t timeout_s = 30); - ConfState ConfProcedure(); - ConfState AudioConfProcedure(); - ConfState StartMultiplexer(); - - bsp::Cellular *getCellular() - { - return pv_cellular.get(); - } - TS0710_START::START_SystemParameters_t getStartParams() - { - return startParams; - } - ATParser *getParser() - { - return parser; - } + MuxParameters getStartParams() const noexcept; + bsp::Cellular *getCellular(); + ATParser *getParser(); /// @brief It is searching the resposne for a string /// @@ -384,31 +321,11 @@ class TS0710 /// @param numberOfExpectedTokens - number of expected tokens, 0 means do not validate number of tokens /// @param level - determine how the errors are logged /// @return true - "OK" string is found, false - otherwise - bool SearchATCommandResponse(const std::vector &response, + bool searchATCommandResponse(const std::vector &response, const std::string &str, size_t numberOfExpectedTokens, - logger_level level) - { - const size_t numberOfTokens = response.size(); - if (searchForString(response, str) && - (numberOfExpectedTokens == 0 || numberOfTokens == numberOfExpectedTokens)) { - return true; - } - else { - std::string resp; - for (std::string s : response) { - resp.append(s); - } - - LOG_CUSTOM(level, "Invalid response: %s", resp.c_str()); - // numberOfExpectedTokens == 0, means do not validate number of tokens - LOG_CUSTOM(level, - " - Number of tokens %u, number of expected tokens %u", - static_cast(numberOfTokens), - static_cast(numberOfExpectedTokens)); - return false; - } - } + logger_level level); + bool searchForString(const std::vector &response, const std::string &str); /// @brief It is serching the resposne for ">" string /// @@ -417,30 +334,37 @@ class TS0710 /// @param response - tokenized resposne /// @param level - determine how the errors are logged /// @return true - str string is found, false - otherwise - bool CheckATCommandPrompt(const std::vector &response, logger_level level = LOGERROR) - { - return SearchATCommandResponse(response, ">", 0, level); - } + bool checkATCommandPrompt(const std::vector &response, logger_level level = LOGERROR); + + void selectAntenna(bsp::cellular::antenna antenna); + [[nodiscard]] bsp::cellular::antenna getAntenna(); + + void informModemHostWakeup(); + bool isModemActive(); + void turnOnModem(); + void resetModem(); + void turnOffModem(); + void enterSleepMode(); + void exitSleepMode(); + void registerCellularDevice(); - TS0710(PortSpeed_e portSpeed, sys::Service *parent); - TS0710() = delete; - ~TS0710(); - void Init(PortSpeed_e portSpeed, sys::Service *parent); - void SetStartParams(PortSpeed_e portSpeed); - void SelectAntenna(bsp::cellular::antenna antenna); - bsp::cellular::antenna GetAntenna(); - // Add error handling - only for Advanced mode. Leave for now - // Add callback for received frame (after error handling) - // Add frame routing to different channels - - void InformModemHostWakeup(void); // damn, it should be in ServiceCellular - bool IsModemActive(void); - void TurnOnModem(void); - void ResetModem(void); - void TurnOffModem(void); - void EnterSleepMode(void); - void ExitSleepMode(void); - void RegisterCellularDevice(void); [[nodiscard]] auto getLastCommunicationTimestamp() const noexcept -> TickType_t; [[nodiscard]] auto isCellularInSleepMode() const noexcept -> bool; + + static std::string name(enum Channel name) + { + switch (name) { + case Channel::None: + return "None"; + case Channel::Control: + return "Control"; + case Channel::Commands: + return "Commands"; + case Channel::Notifications: + return "Notifications"; + case Channel::Data: + return "Data"; + } + return ""; + } }; diff --git a/module-cellular/modem/mux/CellularMuxData.cpp b/module-cellular/modem/mux/CellularMuxData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0b569abee26c434f6134ef015309b54bca2accfe --- /dev/null +++ b/module-cellular/modem/mux/CellularMuxData.cpp @@ -0,0 +1,75 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "CellularMuxData.h" +#include "CellularMuxFrame.h" +#include + +CellularMuxData::CellularMuxData(DLCI_t DLCI, + DLC_ESTABL_SystemParameters_t sysParams, + const std::vector &userData, + bsp::Cellular *cellular) +{ + assert(cellular != nullptr); + + pvCellular = cellular; + + request(DLCI, sysParams, userData); +} +/** + * @param DLCI + * @param userData + */ +void CellularMuxData::request(DLCI_t DLCI, + DLC_ESTABL_SystemParameters_t sysParams, + const std::vector &userData) +{ + /* + TE sends AT command "ATI" through DLC 1 + TE→MS F9 05 EF 09 41 54 49 0D 58 F9 UIH Frame + MS feeds back through DLC 1 + TE←MS F9 05 EF 09 41 54 49 0D 58 F9 + F9 05 EF 9B 0D 0A 53 49 4D 43 + 4F 4D 5F 4C 74 64 0D 0A 53 49 + 4D 43 4F 4D 5F 53 49 4D 33 30 + 30 0D 0A 52 65 76 69 73 69 6F 6E + 3A 53 49 4D 33 30 30 4D 33 32 28 + 53 50 41 4E 53 49 4F 4E 29 5F 56 + 31 30 2E 30 2E 38 5F 42 55 49 + 4C 44 30 33 0D 0A 0D 0A 47 F9 UIH Frame +*/ + auto constexpr maximumFrameLength = 127; + CellularMuxFrame::frame_t frame; + frame.Address = static_cast(DLCI << 2) /*| (1 << 1)*/; // set C/R = 1 - command + frame.Control = static_cast(TypeOfFrame_e::UIH); + + if (userData.size() <= static_cast(maximumFrameLength)) { + frame.data = userData; + CellularMuxFrame frame_c(frame); + // UartSend(frame_c.getSerData().data(), frame_c.getSerData().size()); + pvCellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); + } + else { // if data size > max frame size + int dataLeft = userData.size(); + auto i = userData.begin(); + uint32_t parts = userData.size() / maximumFrameLength + 1; // add reminder + LOG_DEBUG("SENDING %" PRIu32 " parts", parts); + + while ((parts--) != 0u) { + auto last = i + (dataLeft <= maximumFrameLength ? dataLeft : maximumFrameLength); // distinguish reminder + frame.data = std::vector(i, last); + i = last; + + CellularMuxFrame frame_c(frame); + pvCellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); + dataLeft -= (dataLeft <= maximumFrameLength ? dataLeft : maximumFrameLength); + } + } +} + +/** + * @param DLCI + * @param User_data + */ +void CellularMuxData::indication(DLCI_t DLCI, std::vector User_data) +{} diff --git a/module-cellular/Modem/TS0710/TS0710_DATA.h b/module-cellular/modem/mux/CellularMuxData.h similarity index 63% rename from module-cellular/Modem/TS0710/TS0710_DATA.h rename to module-cellular/modem/mux/CellularMuxData.h index a3131ed4aa5e4bb4a663df748ed52aa808084345..422d1909b54982865b618045927811410acb6cef 100644 --- a/module-cellular/Modem/TS0710/TS0710_DATA.h +++ b/module-cellular/modem/mux/CellularMuxData.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md /** @@ -9,27 +9,25 @@ * take care of all mechanisms involved in the error checking and thus deliver data error free. */ -#ifndef _TS0710_DATA_H -#define _TS0710_DATA_H +#pragma once #include -#include "TS0710.h" +#include "CellularMux.h" -class TS0710_DATA +class CellularMuxData { public: - TS0710_DATA(DLCI_t DLCI, - DLC_ESTABL_SystemParameters_t sysParams, - std::vector &User_data, - bsp::Cellular *cellular); - ~TS0710_DATA() - {} + CellularMuxData(DLCI_t DLCI, + DLC_ESTABL_SystemParameters_t sysParams, + const std::vector &userData, + bsp::Cellular *cellular); + private: /** * @param DLCI - * @param User_data + * @param userData */ - void request(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t sysParams, std::vector User_data); + void request(DLCI_t DLCI, DLC_ESTABL_SystemParameters_t sysParams, const std::vector &userData); /** * @param DLCI @@ -38,7 +36,5 @@ class TS0710_DATA */ void indication(DLCI_t DLCI, std::vector User_data); - bsp::Cellular *pv_cellular; + bsp::Cellular *pvCellular; }; - -#endif //_TS0710_DATA_H \ No newline at end of file diff --git a/module-cellular/Modem/TS0710/TS0710_Frame.h b/module-cellular/modem/mux/CellularMuxFrame.h similarity index 97% rename from module-cellular/Modem/TS0710/TS0710_Frame.h rename to module-cellular/modem/mux/CellularMuxFrame.h index 7e3aad5bed5ea99eee0c8b7b16056aa12bbab437..6d5531a6ac0e23970ebefae1b4568a50bc460570 100644 --- a/module-cellular/Modem/TS0710/TS0710_Frame.h +++ b/module-cellular/modem/mux/CellularMuxFrame.h @@ -1,10 +1,9 @@ // Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md -#ifndef _TS0710_FRAME_H -#define _TS0710_FRAME_H +#pragma once -#include "TS0710_types.h" +#include "CellularMuxTypes.h" #include #include #include @@ -13,7 +12,7 @@ #define TS0710_FLAG 0xF9 #define TS0710_FRAME_HDR_LEN 6 // without extended address byte -class TS0710_Frame +class CellularMuxFrame { private: static constexpr unsigned char crctable[256] = { // reversed, 8-bit, poly=0x07 @@ -187,27 +186,27 @@ class TS0710_Frame std::vector pv_serData; public: - explicit TS0710_Frame(frame_t frame) + explicit CellularMuxFrame(frame_t frame) { // LOG_DEBUG("Serializing given frame"); pv_serData = frame.serialize(); pv_frame = frame; } - explicit TS0710_Frame(const std::vector &serData) + explicit CellularMuxFrame(const std::vector &serData) { // LOG_DEBUG("Deserializing serData"); pv_frame.deserialize(serData); pv_serData = serData; } - TS0710_Frame() + CellularMuxFrame() { LOG_DEBUG("Deserializing pv_serData"); pv_frame.deserialize(pv_serData); } - ~TS0710_Frame() + ~CellularMuxFrame() { pv_serData.clear(); pv_frame.data.clear(); @@ -283,5 +282,3 @@ class TS0710_Frame return pv_frame.frameStatus; } }; - -#endif /*_TS0710_FRAME_H*/ diff --git a/module-cellular/Modem/TS0710/TS0710_types.h b/module-cellular/modem/mux/CellularMuxTypes.h similarity index 97% rename from module-cellular/Modem/TS0710/TS0710_types.h rename to module-cellular/modem/mux/CellularMuxTypes.h index 782fe8e67fc9b056def045206bcce25bc8c05590..91300e69febebb6832a2f8a03b7ad9c596a1459e 100644 --- a/module-cellular/Modem/TS0710/TS0710_types.h +++ b/module-cellular/modem/mux/CellularMuxTypes.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #ifndef _TS0710_TYPES_H @@ -32,8 +32,6 @@ struct DLC_ESTABL_SystemParameters_t int ErrRecovWindowSize; //!< Window size for error recovery mode [1 – 7, default : 2] }; -#define TS0710_MAX_CHANNEL_NUM 4 - enum PortSpeed_e { PS2400, diff --git a/module-cellular/Modem/TS0710/DLC_channel.cpp b/module-cellular/modem/mux/DLCChannel.cpp similarity index 62% rename from module-cellular/Modem/TS0710/DLC_channel.cpp rename to module-cellular/modem/mux/DLCChannel.cpp index fdd58bdaef48efa7834706564ac4dc01cbd27687..9930c820e8ad704777e7a1e38a51bbb25b6ef101 100644 --- a/module-cellular/Modem/TS0710/DLC_channel.cpp +++ b/module-cellular/modem/mux/DLCChannel.cpp @@ -1,25 +1,23 @@ // Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md -#include "DLC_channel.h" +#include "DLCChannel.h" -#include "TS0710_DATA.h" -#include "TS0710_DLC_RELEASE.h" -#include "TS0710_Frame.h" +#include "CellularMuxData.h" +#include "CellularMuxFrame.h" #include #include #include - #include -DLC_channel::DLC_channel(DLCI_t DLCI, const std::string &name, bsp::Cellular *cellular, const Callback_t &callback) - : Channel{new uint8_t[at::defaultReceiveBufferSize]}, pv_name{name}, pv_DLCI{DLCI}, pv_cellular{cellular} +DLCChannel::DLCChannel(DLCI_t DLCI, const std::string &name, bsp::Cellular *cellular, const Callback_t &callback) + : Channel{new uint8_t[at::defaultReceiveBufferSize]}, name{name}, DLCI{DLCI}, pvCellular{cellular} { LOG_DEBUG("Creating DLCI %i channel \"%s\"", DLCI, name.c_str()); if (callback != nullptr) { - pv_callback = callback; + pvCallback = callback; } chanParams.TypeOfFrame = TypeOfFrame_e::SABM; @@ -33,37 +31,32 @@ DLC_channel::DLC_channel(DLCI_t DLCI, const std::string &name, bsp::Cellular *ce responseBuffer = xMessageBufferCreate(at::defaultMessageBufferSize); } -bool DLC_channel::init() +bool DLCChannel::init() { active = establish(); - LOG_INFO("create channel %s: %s", pv_name.c_str(), active ? "TRUE" : "FALSE"); + LOG_INFO("create channel %s: %s", name.c_str(), active ? "TRUE" : "FALSE"); return active; } -DLC_channel::~DLC_channel() +void DLCChannel::sendData(std::vector &data) { - TS0710_DLC_RELEASE release = TS0710_DLC_RELEASE(pv_DLCI); + CellularMuxData(DLCI, chanParams, data, pvCellular); } -void DLC_channel::SendData(std::vector &data) +bool DLCChannel::establish() { - TS0710_DATA _data = TS0710_DATA(pv_DLCI, chanParams, data, pv_cellular); -} + LOG_DEBUG("Sending %s frame to DLCI %i", TypeOfFrame_text[chanParams.TypeOfFrame].c_str(), DLCI); -bool DLC_channel::establish() -{ - LOG_DEBUG("Sending %s frame to DLCI %i", TypeOfFrame_text[chanParams.TypeOfFrame].c_str(), pv_DLCI); - - TS0710_Frame frame_c(TS0710_Frame::frame_t(static_cast(pv_DLCI << 2) | (1 << 1), - static_cast(chanParams.TypeOfFrame))); + CellularMuxFrame frame_c(CellularMuxFrame::frame_t(static_cast(DLCI << 2) | (1 << 1), + static_cast(chanParams.TypeOfFrame))); awaitingResponseFlag.set(); bool result = false; for (int retries = 0; retries < chanParams.MaxNumOfRetransmissions; ++retries) { - pv_cellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); + pvCellular->write(static_cast(frame_c.getSerData().data()), frame_c.getSerData().size()); auto startTime = std::chrono::steady_clock::now(); auto endTime = startTime + std::chrono::milliseconds{300}; @@ -74,7 +67,7 @@ bool DLC_channel::establish() break; } - if (size_t bytesRead = cmd_receive(receiveBuffer.get(), std::chrono::milliseconds{0}); bytesRead > 0) { + if (size_t bytesRead = cmdReceive(receiveBuffer.get(), std::chrono::milliseconds{0}); bytesRead > 0) { auto cellularResult = bsp::cellular::CellularResult{receiveBuffer.get(), bytesRead}; if (evaluateEstablishResponse(cellularResult)) { result = true; @@ -89,55 +82,50 @@ bool DLC_channel::establish() return result; } -void DLC_channel::cmd_init() +void DLCChannel::cmdInit() {} -void DLC_channel::cmd_send(std::string cmd) +void DLCChannel::cmdSend(std::string cmd) { std::vector data(cmd.begin(), cmd.end()); - SendData(data); + sendData(data); } -size_t DLC_channel::cmd_receive(uint8_t *result, std::chrono::milliseconds timeout) +size_t DLCChannel::cmdReceive(uint8_t *result, std::chrono::milliseconds timeout) { return xMessageBufferReceive(responseBuffer, result, 2 * chanParams.MaxFrameSize, pdMS_TO_TICKS(timeout.count())); } -void DLC_channel::cmd_post() +void DLCChannel::cmdPost() {} -std::vector DLC_channel::SendCommandPrompt(const char *cmd, - size_t rxCount, - std::chrono::milliseconds timeout) +std::vector DLCChannel::sendCommandPrompt(const char *cmd, + size_t rxCount, + std::chrono::milliseconds timeout) { std::vector tokens; - LOG_DEBUG("SendCommandPrompt start"); - awaitingResponseFlag.set(); at::Result result; - cmd_init(); + cmdInit(); std::string cmdFixed = formatCommand(cmd); - cmd_send(cmdFixed); + cmdSend(cmdFixed); auto startTime = std::chrono::steady_clock::now(); auto endTime = startTime + timeout; - LOG_DEBUG("SendCommandPrompt cmd sent"); // Wait for response: while (true) { if (std::chrono::steady_clock::now() > endTime) { result.code = at::Result::Code::TIMEOUT; - LOG_DEBUG("SendCommandPrompt cmd timeout"); break; } - if (size_t bytesRead = cmd_receive(receiveBuffer.get(), std::chrono::milliseconds{0}); bytesRead > 0) { + if (size_t bytesRead = cmdReceive(receiveBuffer.get(), std::chrono::milliseconds{0}); bytesRead > 0) { auto cellularResult = bsp::cellular::CellularResult{receiveBuffer.get(), bytesRead}; auto str = cellularResult.getDataAsString(); - LOG_DEBUG("SendCommandPrompt got response"); auto cellResult = checkResult(cellularResult.getResultCode()); if (cellResult.code != at::Result::Code::OK) { @@ -158,16 +146,15 @@ std::vector DLC_channel::SendCommandPrompt(const char *cmd, } } - LOG_DEBUG("SendCommandPrompt end"); cmdLog(cmdFixed, result, timeout); - cmd_post(); + cmdPost(); awaitingResponseFlag.clear(); return tokens; } -at::Result DLC_channel::ParseInputData(bsp::cellular::CellularResult *cellularResult) +at::Result DLCChannel::parseInputData(bsp::cellular::CellularResult *cellularResult) { at::Result result; @@ -180,9 +167,9 @@ at::Result DLC_channel::ParseInputData(bsp::cellular::CellularResult *cellularRe result.code = at::Result::Code::FULL_MSG_BUFFER; } } - else if (pv_callback != nullptr) { + else if (pvCallback != nullptr) { std::string receivedData = cellularResult->getDataAsString(); - pv_callback(receivedData); + pvCallback(receivedData); } else { result.code = at::Result::Code::DATA_NOT_USED; @@ -191,9 +178,9 @@ at::Result DLC_channel::ParseInputData(bsp::cellular::CellularResult *cellularRe return result; } -bool DLC_channel::evaluateEstablishResponse(bsp::cellular::CellularResult &response) const +bool DLCChannel::evaluateEstablishResponse(bsp::cellular::CellularResult &response) const { - auto frame = TS0710_Frame{response.getData()}; - return (frame.getFrameDLCI() == pv_DLCI && + auto frame = CellularMuxFrame{response.getData()}; + return (frame.getFrameDLCI() == DLCI && (frame.getFrame().Control == (static_cast(TypeOfFrame_e::UA) & ~(1 << 4)))); } diff --git a/module-cellular/modem/mux/DLCChannel.h b/module-cellular/modem/mux/DLCChannel.h new file mode 100644 index 0000000000000000000000000000000000000000..6865468083fa4cc22585b9a29e7de7385ab9b39d --- /dev/null +++ b/module-cellular/modem/mux/DLCChannel.h @@ -0,0 +1,77 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "modem/ATCommon.hpp" +#include "CellularMuxTypes.h" + +class DLCChannel : public at::Channel +{ + public: + using Callback_t = std::function; + + private: + std::string name; + DLCI_t DLCI = -1; + bool active = false; + DLC_ESTABL_SystemParameters_t chanParams{}; + Callback_t pvCallback; + bsp::Cellular *pvCellular = nullptr; + + public: + DLCChannel(DLCI_t DLCI, const std::string &name, bsp::Cellular *cellular, const Callback_t &callback = nullptr); + DLCChannel() : Channel{nullptr}, name{"none"}, DLCI{-1} {}; + virtual ~DLCChannel() = default; + + bool init(); + bool establish(); + void sendData(std::vector &data); + + virtual void cmdInit() override final; + virtual void cmdSend(std::string cmd) override final; + virtual size_t cmdReceive(std::uint8_t *result, std::chrono::milliseconds timeout) override final; + virtual void cmdPost() override final; + + std::vector sendCommandPrompt(const char *cmd, + size_t rxCount, + std::chrono::milliseconds timeout = std::chrono::milliseconds{300}); + + at::Result parseInputData(bsp::cellular::CellularResult *cellularResult); + + bool evaluateEstablishResponse(bsp::cellular::CellularResult &response) const; + + void callback(std::string &data) + { + pvCallback(data); + } + + DLCI_t getDLCI() const noexcept + { + return DLCI; + } + std::string getName() const + { + return name; + } + bool getActive() const noexcept + { + return active; + } + + void setCallback(Callback_t callback) + { + LOG_DEBUG("[%s] Setting up callback for channel", name.c_str()); + pvCallback = std::move(callback); + } +}; diff --git a/module-cellular/modem/mux/MuxParameters.hpp b/module-cellular/modem/mux/MuxParameters.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2568bd405dc19e58b00365b15384a15c3f460234 --- /dev/null +++ b/module-cellular/modem/mux/MuxParameters.hpp @@ -0,0 +1,16 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +struct MuxParameters +{ + PortSpeed_e PortSpeed{}; //!< Port speed + int MaxFrameSize{}; //!< Maximum Frame Size [ 1-128 in Basic mode, 1-512 in HDLC modes, default: 31 for basic + //!< option & 64 for advanced ] + int AckTimer{}; //!< Acknowledgement Timer [0,01s-2,55s, default: 0,1s] + int MaxNumOfRetransmissions{}; //!< Maximum number of retransmissions [0-100, default: 3] + int MaxCtrlRespTime{}; //!< Response timer for the multiplexer control channel [0,01s-2,55s, default: 0,3s] + int WakeUpRespTime{}; //!< Wake up response timer [1s-255s, default: 10s] + int ErrRecovWindowSize{}; //!< Window size for error recovery mode [1-7, default: 2] +}; diff --git a/module-cellular/Modem/TS0710/tests/test-DLC_channel.cpp b/module-cellular/modem/mux/tests/test-DLCChannel.cpp similarity index 95% rename from module-cellular/Modem/TS0710/tests/test-DLC_channel.cpp rename to module-cellular/modem/mux/tests/test-DLCChannel.cpp index a10004aafb041db9e34c91b7ec5c2fcc66933540..5102bbe49759523f5e5aabacc5f086ad98bf1230 100644 --- a/module-cellular/Modem/TS0710/tests/test-DLC_channel.cpp +++ b/module-cellular/modem/mux/tests/test-DLCChannel.cpp @@ -7,11 +7,11 @@ TEST_CASE("test-DLC_channel") { - DLC_channel *_class = new DLC_channel(); + DLCChannel *_class = new DLC_channel(); REQUIRE(_class->getName() == "none"); delete _class; - _class = new DLC_channel(2, "Test2"); + _class = new DLCChannel(2, "Test2"); REQUIRE(_class->getName() == "Test2"); REQUIRE(_class->getDLCI() == 2); std::vector v; diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710.cpp b/module-cellular/modem/mux/tests/test-TS0710.cpp similarity index 100% rename from module-cellular/Modem/TS0710/tests/test-TS0710.cpp rename to module-cellular/modem/mux/tests/test-TS0710.cpp diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_DATA.cpp b/module-cellular/modem/mux/tests/test-TS0710_DATA.cpp similarity index 100% rename from module-cellular/Modem/TS0710/tests/test-TS0710_DATA.cpp rename to module-cellular/modem/mux/tests/test-TS0710_DATA.cpp diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_DLC_ESTABL.cpp b/module-cellular/modem/mux/tests/test-TS0710_DLC_ESTABL.cpp similarity index 100% rename from module-cellular/Modem/TS0710/tests/test-TS0710_DLC_ESTABL.cpp rename to module-cellular/modem/mux/tests/test-TS0710_DLC_ESTABL.cpp diff --git a/module-cellular/Modem/TS0710/tests/test-TS0710_START.cpp b/module-cellular/modem/mux/tests/test-TS0710_START.cpp similarity index 100% rename from module-cellular/Modem/TS0710/tests/test-TS0710_START.cpp rename to module-cellular/modem/mux/tests/test-TS0710_START.cpp diff --git a/module-cellular/test/mock/AtCommon_channel.hpp b/module-cellular/test/mock/AtCommon_channel.hpp index 3773426ac7f0940fc86de8c9ab1a498949ff029c..b209190451a8b5e76b01e3028f73f1a7073fc343 100644 --- a/module-cellular/test/mock/AtCommon_channel.hpp +++ b/module-cellular/test/mock/AtCommon_channel.hpp @@ -3,8 +3,8 @@ #pragma once -#include "Modem/ATCommon.hpp" -#include "Modem/BaseChannel.hpp" +#include "modem/ATCommon.hpp" +#include "modem/BaseChannel.hpp" namespace at { @@ -32,16 +32,16 @@ namespace at return ResultMock(); } - void cmd_init() override + void cmdInit() override {} - void cmd_send(std::string cmd) override + void cmdSend(std::string cmd) override {} - void cmd_post() override + void cmdPost() override {} - size_t cmd_receive(std::uint8_t *buffer, std::chrono::milliseconds timeoutMs) override + size_t cmdReceive(std::uint8_t *buffer, std::chrono::milliseconds timeoutMs) override { return {}; } diff --git a/module-cellular/test/unittest_ATStream.cpp b/module-cellular/test/unittest_ATStream.cpp index c2ca5f0a3ea6b3e490202df2828ac2101efcf23f..fa86372c925fc0f368940357be78e6477a76c702 100644 --- a/module-cellular/test/unittest_ATStream.cpp +++ b/module-cellular/test/unittest_ATStream.cpp @@ -5,7 +5,7 @@ #define CATCH_CONFIG_MAIN #include -#include "Modem/ATStream.hpp" +#include "modem/ATStream.hpp" #include "Result.hpp" TEST_CASE("Channel Test- AT return parser") diff --git a/module-cellular/test/unittest_ATURCStream.cpp b/module-cellular/test/unittest_ATURCStream.cpp index 5a98c86c262328c418665de6edd68cdc79b360d2..04713b3aac81fbd971af5c09c7339f33fc85e0fd 100644 --- a/module-cellular/test/unittest_ATURCStream.cpp +++ b/module-cellular/test/unittest_ATURCStream.cpp @@ -5,7 +5,7 @@ #define CATCH_CONFIG_MAIN #include -#include "Modem/ATURCStream.hpp" +#include "modem/ATURCStream.hpp" TEST_CASE("URC AT Stream Parser") { diff --git a/module-cellular/test/unittest_CellularResult.cpp b/module-cellular/test/unittest_CellularResult.cpp index d6bd75641736e2873e7c0b82ce82083ac066ec2f..92f37b9a28c29a271ad5e1a1d1a0572919056f3e 100644 --- a/module-cellular/test/unittest_CellularResult.cpp +++ b/module-cellular/test/unittest_CellularResult.cpp @@ -4,7 +4,7 @@ #define CATCH_CONFIG_MAIN #include -#include +#include TEST_CASE("CellularResult") { diff --git a/module-cellular/test/unittest_URC.cpp b/module-cellular/test/unittest_URC.cpp index f10f594d88b72f1255751a42a373633b834f99dd..f950cc248b2c4d1e950475c4d20f2759a4465f2e 100644 --- a/module-cellular/test/unittest_URC.cpp +++ b/module-cellular/test/unittest_URC.cpp @@ -8,7 +8,7 @@ #define CATCH_CONFIG_MAIN #include -#include +#include