OpenCPN Partial API docs
comm_drv_n0183_android_bt.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose:
5  * Author: David Register, Alec Leamas
6  *
7  ***************************************************************************
8  * Copyright (C) 2023 by David Register, Alec Leamas *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  **************************************************************************/
25 
26 #ifndef _COMMDRIVERN0183ANDROIDBT_H
27 #define _COMMDRIVERN0183ANDROIDBT_H
28 
29 #include <atomic>
30 #include <string>
31 
32 #include <wx/event.h>
33 
34 #include "model/comm_drv_n0183.h"
35 #include "model/conn_params.h"
36 
37 class CommDriverN0183AndroidBTEvent : public wxEvent {
38 public:
39  CommDriverN0183AndroidBTEvent( wxEventType commandType, int id);
41 
42  // accessors
43  void SetPayload(std::shared_ptr<std::vector<unsigned char>> data);
44  std::shared_ptr<std::vector<unsigned char>> GetPayload();
45 
46  // required for sending with wxPostEvent()
47  wxEvent* Clone() const;
48 private:
49  std::shared_ptr<std::vector<unsigned char>> m_payload;
50 };
51 
52 wxDECLARE_EVENT(wxEVT_COMMDRIVER_N0183_ANDROID_BT, CommDriverN0183AndroidBTEvent);
53 
54 
55 class CommDriverN0183AndroidBT : public CommDriverN0183, public wxEvtHandler {
56 public:
58 
59  virtual ~CommDriverN0183AndroidBT();
60 
62  void Activate() override;
63 
64  bool Open();
65  void Close();
66 
67  ConnectionParams GetParams() const { return m_params; }
68 
69  bool SendMessage(std::shared_ptr<const NavMsg> msg,
70  std::shared_ptr<const NavAddr> addr) override;
71 
72 private:
73  bool m_bok;
74  std::string m_portstring;
75  std::string m_BaudRate;
76  int m_handshake;
77 
78 
79  ConnectionParams m_params;
80  DriverListener& m_listener;
81  void handle_N0183_MSG(CommDriverN0183AndroidBTEvent& event);
82 };
83 
84 #endif // guard
void Activate() override
Register driver and possibly do other post-ctor steps.
Interface implemented by transport layer and possible other parties like test code which should handl...
Definition: comm_driver.h:47