Initial client application skeleton
This commit is contained in:
parent
8cddb07ee4
commit
e86a5a1cbe
@ -50,6 +50,7 @@ add_executable(skl_tunnel
|
||||
radio/src/radio_hw_instance.cpp
|
||||
|
||||
app/src/app_logging.cpp
|
||||
app/src/app_transparent_client.cpp
|
||||
main.cpp
|
||||
syscalls.c
|
||||
)
|
||||
|
||||
25
app/include/app_settings.hpp
Normal file
25
app/include/app_settings.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by erki on 14.07.22.
|
||||
//
|
||||
|
||||
#ifndef SKL_TUNNEL_APP_SETTINGS_HPP
|
||||
#define SKL_TUNNEL_APP_SETTINGS_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace App
|
||||
{
|
||||
|
||||
struct RadioSettings
|
||||
{
|
||||
std::uint16_t short_address = 0x0230;
|
||||
std::uint64_t long_address = 0x1222334455667788;
|
||||
std::uint8_t channel = 11;
|
||||
std::uint16_t pan_id = 0x0023;
|
||||
std::int16_t tx_power_dbm = 0;
|
||||
std::uint8_t retries = 3;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SKL_TUNNEL_APP_SETTINGS_HPP
|
||||
35
app/include/app_transparent_client.hpp
Normal file
35
app/include/app_transparent_client.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// Created by erki on 13.07.22.
|
||||
//
|
||||
|
||||
#ifndef SKL_TUNNEL_APP_TRANSPARENT_CLIENT_HPP
|
||||
#define SKL_TUNNEL_APP_TRANSPARENT_CLIENT_HPP
|
||||
|
||||
#include "app_settings.hpp"
|
||||
|
||||
namespace radio
|
||||
{
|
||||
class HwInstance;
|
||||
}
|
||||
|
||||
namespace App
|
||||
{
|
||||
|
||||
class TransparentClient
|
||||
{
|
||||
public:
|
||||
TransparentClient(const RadioSettings& initial_settings);
|
||||
|
||||
void apply_settings(const RadioSettings& settings);
|
||||
|
||||
TransparentClient(const TransparentClient&) = delete;
|
||||
TransparentClient(TransparentClient&&) = delete;
|
||||
TransparentClient& operator=(const TransparentClient&) = delete;
|
||||
TransparentClient& operator=(TransparentClient&&) = delete;
|
||||
private:
|
||||
radio::HwInstance* m_radio;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SKL_TUNNEL_APP_TRANSPARENT_CLIENT_HPP
|
||||
28
app/src/app_transparent_client.cpp
Normal file
28
app/src/app_transparent_client.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by erki on 14.07.22.
|
||||
//
|
||||
|
||||
#include "radio_hw_instance.hpp"
|
||||
|
||||
#include "app_transparent_client.hpp"
|
||||
|
||||
namespace App
|
||||
{
|
||||
|
||||
TransparentClient::TransparentClient(const RadioSettings& initial_settings)
|
||||
: m_radio(radio::HwInstance::instance())
|
||||
{
|
||||
apply_settings(initial_settings);
|
||||
}
|
||||
|
||||
void TransparentClient::apply_settings(const RadioSettings& settings)
|
||||
{
|
||||
m_radio->set_address_short(settings.short_address);
|
||||
m_radio->set_address_long(settings.long_address);
|
||||
m_radio->set_channel(settings.channel);
|
||||
m_radio->set_pan_id(settings.pan_id);
|
||||
m_radio->set_tx_power(settings.tx_power_dbm);
|
||||
m_radio->set_max_retries(settings.retries);
|
||||
}
|
||||
|
||||
}
|
||||
10
main.cpp
10
main.cpp
@ -2,16 +2,20 @@
|
||||
|
||||
#include <utility_logging.hpp>
|
||||
#include <utility_assert.hpp>
|
||||
#include <utility_staticpointer.hpp>
|
||||
|
||||
#include "radio_hw_instance.hpp"
|
||||
#include "app_logging.hpp"
|
||||
#include "skullc_samd21_hal.hpp"
|
||||
#include "app_transparent_client.hpp"
|
||||
|
||||
namespace Hal = Peripherals::Hal::Samd;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
Utility::StaticPointer<App::TransparentClient> m_app;
|
||||
|
||||
[[noreturn]] void m_faultHandler(const char* expression, const char* file, const int line)
|
||||
{
|
||||
SKULLC_LOG_FATAL("Expression failed: (%s), source: %s:%d", expression, file, line);
|
||||
@ -34,9 +38,13 @@ int main()
|
||||
|
||||
App::Logging::setup();
|
||||
|
||||
radio::HwInstance* radio_hw = radio::HwInstance::instance();
|
||||
SKULLC_LOG_DEBUG("Begin.");
|
||||
|
||||
const App::RadioSettings settings;
|
||||
|
||||
m_app.setup(settings);
|
||||
radio::HwInstance* radio_hw = radio::HwInstance::instance();
|
||||
|
||||
/* Replace with your application code */
|
||||
while (true)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user