forked from blynkkk/blynk-library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BlynkSimpleUserDefined.h
79 lines (61 loc) · 1.5 KB
/
BlynkSimpleUserDefined.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* @file BlynkSimpleUserManaged.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jun 2015
* @brief
*
*/
#ifndef BlynkSimpleUserManaged_h
#define BlynkSimpleUserManaged_h
#ifndef BLYNK_INFO_CONNECTION
#define BLYNK_INFO_CONNECTION "custom"
#endif
#include <BlynkApiArduino.h>
#include <Blynk/BlynkProtocol.h>
extern size_t BlynkStreamRead(void* buf, size_t len);
extern size_t BlynkStreamWrite(const void* buf, size_t len);
class BlynkTransportUserDefined
{
public:
BlynkTransportUserDefined()
: mConn (false)
{}
bool connect() {
return mConn = true;
}
void disconnect() { mConn = false; }
bool connected() {
return mConn;
}
size_t read(void* buf, size_t len) {
return BlynkStreamRead(buf, len);
}
size_t write(const void* buf, size_t len) {
return BlynkStreamWrite(buf, len);
}
size_t available() {
return 0;
}
private:
bool mConn;
};
class BlynkUserDefined
: public BlynkProtocol<BlynkTransportUserDefined>
{
typedef BlynkProtocol<BlynkTransportUserDefined> Base;
public:
BlynkUserDefined(BlynkTransportUserDefined& transp)
: Base(transp)
{}
void begin(const char* auth)
{
Base::begin(auth);
}
private:
};
static BlynkTransportUserDefined _blynkTransport;
BlynkUserDefined Blynk(_blynkTransport);
#include <BlynkWidgets.h>
#endif