OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_drv_signalk_net.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2022 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24// Originally by balp on 2018-07-28.
25
26#ifndef SigNaLK_nEt_h_
27#define SigNaLK_nEt_h_
28
29#include <memory>
30#include <string>
31#include <thread>
32
33#include <wx/wxprec.h>
34
35#ifndef WX_PRECOMP
36#include <wx/wx.h>
37#endif
38
39#include <wx/event.h>
40#include <wx/string.h>
41#include <wx/timer.h>
42
43#include "model/conn_params.h"
45#include "comm_drv_stats.h"
46
47constexpr int kDogTimeoutSeconds = 5;
48
50 public wxEvtHandler,
51 public DriverStatsProvider {
52public:
54 ~CommDriverSignalKNet() override;
55
57 class InputEvt;
58
59 DriverStats GetDriverStats() const override;
60
62 static void initIXNetSystem();
63
65 static void uninitIXNetSystem();
66
76 static bool DiscoverSkServer(const std::string& service_ident, wxString& ip,
77 int& port, int tSec);
78
79private:
80 class IoThread;
81
82 ConnectionParams m_params;
83 DriverListener& m_listener;
84 int m_dog_value;
85 wxTimer m_socketread_watchdog_timer;
86 std::thread m_std_thread;
87 std::unique_ptr<IoThread> m_io_thread;
88 StatsTimer m_stats_timer;
89 DriverStats m_driver_stats;
90 std::string m_context;
91 std::string m_self;
92
93 void Open();
94 void Close();
95 void OpenWebSocket();
96 void CloseWebSocket();
97
98 void HandleSkSentence(const InputEvt& event);
99
100 void ResetWatchdog() { m_dog_value = kDogTimeoutSeconds; }
101 void SetWatchdog(int n) { m_dog_value = n; }
102};
103
104#endif // SigNaLK_nEt_h_
static void uninitIXNetSystem()
ix::uninitIXNetSystem wrapper
DriverStats GetDriverStats() const override
Get the Driver Statistics.
static void initIXNetSystem()
ix::initIXNetSystem wrapper
static bool DiscoverSkServer(const std::string &service_ident, wxString &ip, int &port, int tSec)
Scan for a SignalK server on local network using mDNS.
Interface for handling incoming messages.
Definition comm_driver.h:50
Driver interface providing driver statistics.
Continuously report driver stats to CommDrvRegistry.evt_driver_stats.
SignalK driver.
Communication statistics infrastructure.
Connection parameters.
Driver statistics report.