OpenCPN Partial API docs
Loading...
Searching...
No Matches
wificlient.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: wifi Client Data Object
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2010 by David S. Register *
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 __WIFICLIENT_H__
27#define __WIFICLIENT_H__
28
29// Include wxWindows' headers
30
31#include "wx/wxprec.h"
32
33#ifndef WX_PRECOMP
34#include "wx/wx.h"
35#endif // precompiled header
36
37#include "dychart.h"
38
39#include "wx/socket.h"
40
41#ifdef __WXMSW__
42#include <wx/datetime.h>
43#endif
44
45//----------------------------------------------------------------------------
46// constants
47//----------------------------------------------------------------------------
48#define WIFI_TRANSMIT_DATA 0x42 // This is the request code
49#define WIFI_TRANSMIT_DATA_EXT 'D' // Extended request code
50
51#define NLOCALSTORE 4
52#define N_AGEDEATH 5
53// Class declarations
54
55// The MY_FILETIME structure is a 64-bit value
56// representing the number of 100-nanosecond
57// intervals since January 1, 1601 (UTC).
58// This is the format used in the NMEA server data packet
59// sigh....
60
61typedef struct {
62 unsigned int low;
63 unsigned int high;
65
66class MyFrame;
67
68// A local structure for managing station scanning
69typedef struct {
70 char ESSID[64];
71 int sig_quality;
72 int secure;
73 bool bisvalid;
74 int age;
75
77
78//----------------------------------------------------------------------------
79// WIFIWindow
80//----------------------------------------------------------------------------
81
82class WIFIWindow : public wxWindow {
83public:
84 WIFIWindow(wxFrame *frame, const wxString &WiFiServerName);
86
87 void GetSource(wxString &source);
88
89 // Stop/Start the Socket Client
90 // Used to prevent async interrupts at critical times
91 void Pause(void);
92 void UnPause(void);
93
94private:
95 void OnPaint(wxPaintEvent &event);
96 void OnActivate(wxActivateEvent &event);
97 void OnSocketEvent(wxSocketEvent &event);
98 void OnTimer1(wxTimerEvent &event);
99 void OnCloseWindow(wxCloseEvent &event);
100 void wxDTToMyFileTime(wxDateTime *SDT, WiFiMyFileTime *pFileTime);
101 void MyFileTimeTowxDT(WiFiMyFileTime *pFileTime, wxDateTime *SDT);
102
103 wxIPV4address addr;
104 wxSocketClient *m_sock;
105 bool m_busy;
106 wxTimer Timer1;
107 MyFrame *parent_frame;
108 bool m_bRX;
109 wxString *m_pdata_server_string;
110 int m_watchtick;
111 int m_scan_interval_msec;
112 bool m_timer_active;
113
114 wifi_local_scan_data station_data[NLOCALSTORE];
115
116 DECLARE_EVENT_TABLE()
117};
118
119typedef struct _WIFI_DATA_MSG1 {
120 int msg;
121 long time; // UNIX 64 bit time
122 long time1;
124
125//-------------------------------------------------------------------------------------------------------------
126//
127// WiFi Server Data Definitions
128//
129//-------------------------------------------------------------------------------------------------------------
130
131// WiFi server produces messages composed of wifi_scan_data structures
132// in a byte buffer, on 256 byte boundaries.
133// This allows extension of the data structures without radical changes to
134// server protocol
135
136typedef struct {
137 char ESSID[64];
138 int sig_quality;
139 int secure;
140 int channel;
141 sockaddr ap_addr;
142 int key_flags;
143 unsigned char mode;
145
146#define SERVER_PORT 3000 // the wifid tcp/ip socket server port
147
148#define WIFI_DOG_TIMEOUT 5
149
150//-------------------------------------------------------------------------------------------------------------
151//
152// A simple thread to test host name resolution without blocking the main
153// thread
154//
155//-------------------------------------------------------------------------------------------------------------
156class WIFIDNSTestThread : public wxThread {
157public:
158 WIFIDNSTestThread(const wxString &name_or_ip);
160 void *Entry();
161
162private:
163 wxString *m_pip;
164};
165
166#endif