-
-
Notifications
You must be signed in to change notification settings - Fork 7k
/
Copy pathserver_drv.h
60 lines (39 loc) · 1.91 KB
/
server_drv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
server_drv.h - Library for Arduino Wifi shield.
Copyright (c) 2011-2014 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Server_Drv_h
#define Server_Drv_h
#include <inttypes.h>
#include "utility/wifi_spi.h"
typedef enum eProtMode {TCP_MODE, UDP_MODE}tProtMode;
class ServerDrv
{
public:
// Start server TCP on port specified
static void startServer(uint16_t port, uint8_t sock, uint8_t protMode=TCP_MODE);
static void startClient(uint32_t ipAddress, uint16_t port, uint8_t sock, uint8_t protMode=TCP_MODE);
static void stopClient(uint8_t sock);
static uint8_t getServerState(uint8_t sock);
static uint8_t getClientState(uint8_t sock);
static bool getData(uint8_t sock, uint8_t *data, uint8_t peek = 0);
static bool getDataBuf(uint8_t sock, uint8_t *data, uint16_t *len);
static bool insertDataBuf(uint8_t sock, const uint8_t *_data, uint16_t _dataLen);
static bool sendData(uint8_t sock, const uint8_t *data, uint16_t len);
static bool sendUdpData(uint8_t sock);
static uint16_t availData(uint8_t sock);
static uint8_t checkDataSent(uint8_t sock);
};
extern ServerDrv serverDrv;
#endif