This repository has been archived by the owner on Mar 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
SFE_CC3000_Client.h
60 lines (49 loc) · 1.55 KB
/
SFE_CC3000_Client.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
/**
* @file SFE_CC3000_Client.h
* @brief Library for the SparkFun CC3000 shield and breakout boards
* @author Shawn Hymel (SparkFun Electronics)
* @author Revisions by Jacob Rosenthal (https://github.com/jacobrosenthal)
*
* @copyright This code is public domain but you buy me a beer if you use
* this and we meet someday (Beerware license).
*
* The client library provides functions to connect to servers using sockets.
*/
#ifndef SFE_CC3000_CLIENT_H
#define SFE_CC3000_CLIENT_H
#include <Arduino.h>
#include "SFE_CC3000.h"
#include "utility/socket.h" // Needed for socket communications
#include "Client.h"
/* Constants for IP protocol types */
#define TCP IPPROTO_TCP
#define UDP IPPROTO_UDP
/* CC3000 Client class */
class SFE_CC3000_Client : public Client {
public:
SFE_CC3000_Client(SFE_CC3000 &cc3000);
~SFE_CC3000_Client();
int connect( const char *hostname,
uint16_t port = 80);
int connect( IPAddress ip_address,
uint16_t port = 80);
int connectUDP( const char *hostname,
uint16_t port = 80);
int connectUDP( IPAddress ip_address,
uint16_t port = 80);
virtual size_t write(uint8_t c);
virtual size_t write(const uint8_t *buf, size_t size);
int available();
int read();
int read(uint8_t *buf, size_t size);
bool close();
uint8_t connected();
int peek();
void flush();
void stop();
operator bool();
private:
SFE_CC3000 *cc3000_;
int32_t socket_;
};
#endif