Browse Source

Initial commit, ESP8266 code with RFID card reader and SSL

master
Alexandre Poincet 8 months ago
parent
commit
11fd010e98
5 changed files with 967 additions and 0 deletions
  1. 274
    0
      include/certs.h
  2. 41
    0
      lib/readme.txt
  3. 15
    0
      platformio.ini
  4. 276
    0
      src/certs.h
  5. 361
    0
      src/main.cpp

+ 274
- 0
include/certs.h View File

@@ -0,0 +1,274 @@
1
+#ifndef CERTS_H
2
+#define CERTS_H
3
+
4
+unsigned char certs_client_bin_crt[] = {
5
+  0x30, 0x82, 0x03, 0xb9, 0x30, 0x82, 0x02, 0xa1, 0xa0, 0x03, 0x02, 0x01,
6
+  0x02, 0x02, 0x01, 0x04, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
7
+  0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x63, 0x31, 0x0b, 0x30,
8
+  0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31, 0x0d,
9
+  0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68, 0x65,
10
+  0x72, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07,
11
+  0x42, 0x6f, 0x75, 0x72, 0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f, 0x06,
12
+  0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d, 0x43,
13
+  0x56, 0x4c, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c,
14
+  0x03, 0x32, 0x53, 0x55, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04,
15
+  0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
16
+  0x30, 0x1e, 0x17, 0x0d, 0x31, 0x38, 0x31, 0x32, 0x30, 0x36, 0x31, 0x38,
17
+  0x30, 0x36, 0x32, 0x30, 0x5a, 0x17, 0x0d, 0x31, 0x39, 0x31, 0x32, 0x30,
18
+  0x36, 0x31, 0x38, 0x30, 0x36, 0x32, 0x30, 0x5a, 0x30, 0x60, 0x31, 0x0b,
19
+  0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31,
20
+  0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68,
21
+  0x65, 0x72, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c,
22
+  0x07, 0x42, 0x6f, 0x75, 0x72, 0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f,
23
+  0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d,
24
+  0x43, 0x56, 0x4c, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b,
25
+  0x0c, 0x03, 0x32, 0x53, 0x55, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55,
26
+  0x04, 0x03, 0x0c, 0x06, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x30, 0x82,
27
+  0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
28
+  0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82,
29
+  0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xe8, 0x23, 0xba, 0x25, 0x34,
30
+  0x87, 0x4a, 0x3e, 0x8f, 0x9f, 0x6e, 0x03, 0xea, 0x9e, 0x9f, 0xd0, 0x40,
31
+  0x8d, 0x78, 0x2d, 0x33, 0x66, 0xa2, 0xda, 0xed, 0xfd, 0x92, 0x12, 0x2d,
32
+  0xd5, 0xa0, 0xc2, 0xb5, 0xd9, 0x7f, 0x85, 0x2e, 0xf9, 0x68, 0x73, 0x6d,
33
+  0x91, 0x8f, 0xf9, 0x5d, 0x44, 0x49, 0xa3, 0xa5, 0x5a, 0xc9, 0x55, 0x42,
34
+  0x4f, 0x77, 0x0b, 0xc3, 0x6d, 0x19, 0x5d, 0x6a, 0x22, 0xa1, 0x66, 0xd9,
35
+  0x2d, 0x5d, 0x3f, 0xda, 0xa0, 0xcd, 0xd0, 0xcf, 0xb8, 0x92, 0xb7, 0x43,
36
+  0x75, 0xda, 0x5a, 0x13, 0x59, 0x42, 0x44, 0xdc, 0xb6, 0x4e, 0xaf, 0x28,
37
+  0xeb, 0x5b, 0x05, 0xea, 0x11, 0xda, 0x7a, 0xc0, 0x48, 0x2b, 0xbd, 0x6a,
38
+  0xf0, 0x10, 0xb4, 0xf2, 0x66, 0xa8, 0xe0, 0x2b, 0x57, 0x6b, 0x25, 0x3e,
39
+  0x28, 0xd2, 0x24, 0x66, 0xdd, 0xcf, 0x72, 0xbc, 0x90, 0x4a, 0x16, 0x48,
40
+  0xbb, 0x16, 0x85, 0x4b, 0x76, 0x37, 0x64, 0x53, 0x74, 0x33, 0xea, 0xe1,
41
+  0x5b, 0xa8, 0x29, 0x19, 0x03, 0xc6, 0x62, 0xec, 0x3d, 0xe5, 0x9c, 0xc3,
42
+  0x62, 0x4b, 0xca, 0x5b, 0xdf, 0x34, 0x51, 0xa6, 0xd6, 0x88, 0x51, 0x69,
43
+  0x6c, 0xf8, 0x38, 0xe7, 0xd3, 0x94, 0x6b, 0xf3, 0x92, 0xe7, 0xcf, 0xea,
44
+  0x9d, 0x60, 0x7d, 0x14, 0x58, 0x3f, 0x0d, 0xe9, 0x69, 0xd2, 0x31, 0x66,
45
+  0xec, 0xec, 0xa4, 0x9c, 0x48, 0xc1, 0x07, 0x62, 0x2c, 0xba, 0x7e, 0xea,
46
+  0xb9, 0x09, 0x81, 0x1f, 0xe5, 0x5d, 0xfa, 0xa8, 0x49, 0x29, 0x43, 0xbe,
47
+  0xab, 0xbe, 0xe3, 0x24, 0xe8, 0x13, 0x0d, 0x13, 0x84, 0x06, 0xaf, 0x08,
48
+  0x5a, 0x92, 0x71, 0xe4, 0xca, 0x5b, 0x3f, 0x79, 0x6c, 0x87, 0x4c, 0x2b,
49
+  0xe4, 0x43, 0xb8, 0x2c, 0x3f, 0xb9, 0x39, 0x64, 0x6f, 0xa6, 0x64, 0x41,
50
+  0x06, 0x92, 0x8e, 0x4b, 0xc4, 0xfb, 0xc7, 0x2b, 0x0f, 0xcc, 0xd1, 0x02,
51
+  0x03, 0x01, 0x00, 0x01, 0xa3, 0x7b, 0x30, 0x79, 0x30, 0x09, 0x06, 0x03,
52
+  0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x2c, 0x06, 0x09, 0x60,
53
+  0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, 0x16, 0x1d,
54
+  0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, 0x47, 0x65, 0x6e, 0x65,
55
+  0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66,
56
+  0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e,
57
+  0x04, 0x16, 0x04, 0x14, 0x54, 0x51, 0x24, 0xc1, 0x50, 0x47, 0x40, 0xa3,
58
+  0xc4, 0xe0, 0x56, 0x64, 0xb9, 0xa5, 0xe1, 0xb0, 0xfe, 0xa4, 0x73, 0xba,
59
+  0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80,
60
+  0x14, 0xfd, 0x47, 0x63, 0x07, 0x27, 0x21, 0x49, 0x64, 0xe9, 0x31, 0xfe,
61
+  0x34, 0x78, 0xb9, 0x7d, 0xd4, 0x60, 0xb2, 0x50, 0x2f, 0x30, 0x0d, 0x06,
62
+  0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00,
63
+  0x03, 0x82, 0x01, 0x01, 0x00, 0x4f, 0x25, 0xdf, 0x17, 0xa3, 0xf7, 0xad,
64
+  0x90, 0xd4, 0xec, 0x35, 0x78, 0x64, 0x61, 0xb6, 0xc0, 0x0c, 0x47, 0x61,
65
+  0x6d, 0x42, 0xe0, 0x97, 0x95, 0x87, 0x87, 0xa0, 0xc9, 0x28, 0x22, 0xb6,
66
+  0xa0, 0x00, 0xc1, 0x42, 0xa7, 0x8e, 0xb8, 0x97, 0x49, 0x5b, 0x28, 0x82,
67
+  0xd9, 0x08, 0x25, 0xe8, 0xd7, 0x69, 0x08, 0x88, 0x8d, 0x6d, 0xd6, 0xa8,
68
+  0x78, 0xd6, 0x8d, 0xc1, 0xdf, 0x77, 0xdc, 0x56, 0x8b, 0x4d, 0xe7, 0xc6,
69
+  0x65, 0xa3, 0x86, 0x03, 0x6c, 0xaa, 0x36, 0x86, 0x9d, 0x2f, 0x00, 0x99,
70
+  0x13, 0xc5, 0x15, 0xe1, 0xfb, 0x67, 0xf5, 0xb5, 0x9d, 0xd2, 0x43, 0x88,
71
+  0x63, 0xca, 0x69, 0xc0, 0x98, 0x5b, 0xb9, 0x7e, 0x32, 0x88, 0x03, 0xa5,
72
+  0x29, 0xec, 0x0f, 0x0b, 0x2c, 0x12, 0x45, 0x6c, 0xa3, 0x2e, 0xff, 0xc7,
73
+  0x7d, 0x11, 0x23, 0x99, 0x6f, 0x0d, 0x03, 0xc1, 0x2e, 0x80, 0xac, 0x69,
74
+  0x06, 0x7a, 0xa9, 0xc9, 0xd6, 0xb3, 0xb7, 0x29, 0xe4, 0xbe, 0x33, 0xaf,
75
+  0x1f, 0x5a, 0x03, 0xb1, 0xf2, 0x8d, 0xc8, 0xec, 0xf4, 0xb8, 0x94, 0xc1,
76
+  0x61, 0x3f, 0xb8, 0xaf, 0x8c, 0x00, 0x38, 0xd3, 0x01, 0x2d, 0xfb, 0x8b,
77
+  0xbf, 0xdb, 0x97, 0xff, 0x15, 0xc1, 0xc7, 0x0e, 0x96, 0x7d, 0x5b, 0xbf,
78
+  0x74, 0x60, 0x5e, 0xe5, 0x7f, 0xb1, 0x26, 0x29, 0xd8, 0x4f, 0x5b, 0xfb,
79
+  0x35, 0x96, 0x21, 0x86, 0x1c, 0xe8, 0x15, 0x67, 0x07, 0xd3, 0x1e, 0x29,
80
+  0xca, 0x6c, 0xf8, 0x50, 0x22, 0xe6, 0x3b, 0xa5, 0xd1, 0xb1, 0x55, 0xd3,
81
+  0x03, 0x9c, 0x3f, 0x4d, 0x6b, 0x54, 0x1e, 0x9a, 0x32, 0x25, 0x26, 0x72,
82
+  0x18, 0xb0, 0xb2, 0xff, 0xce, 0xf3, 0xa0, 0x42, 0x8b, 0xf2, 0xb0, 0xbd,
83
+  0xc9, 0x35, 0xde, 0xdc, 0xa4, 0xa4, 0xbf, 0xee, 0xc5, 0x07, 0x4a, 0x3c,
84
+  0xa8, 0x85, 0x9b, 0x65, 0xcb, 0xa5, 0x11, 0xb0, 0x60
85
+};
86
+unsigned int certs_client_bin_crt_len = 957;
87
+
88
+//CA CERT
89
+const unsigned char caCert[] PROGMEM = {
90
+  0x30, 0x82, 0x03, 0x9c, 0x30, 0x82, 0x02, 0x84, 0xa0, 0x03, 0x02, 0x01,
91
+  0x02, 0x02, 0x09, 0x00, 0xad, 0xed, 0x82, 0x10, 0xcc, 0x63, 0x41, 0x82,
92
+  0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
93
+  0x0b, 0x05, 0x00, 0x30, 0x63, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
94
+  0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03,
95
+  0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68, 0x65, 0x72, 0x31, 0x10, 0x30,
96
+  0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x42, 0x6f, 0x75, 0x72,
97
+  0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a,
98
+  0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d, 0x43, 0x56, 0x4c, 0x31, 0x0c,
99
+  0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x32, 0x53, 0x55,
100
+  0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c,
101
+  0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x1e, 0x17, 0x0d,
102
+  0x31, 0x38, 0x31, 0x32, 0x30, 0x36, 0x31, 0x36, 0x34, 0x38, 0x30, 0x30,
103
+  0x5a, 0x17, 0x0d, 0x32, 0x33, 0x31, 0x32, 0x30, 0x35, 0x31, 0x36, 0x34,
104
+  0x38, 0x30, 0x30, 0x5a, 0x30, 0x63, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
105
+  0x55, 0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31, 0x0d, 0x30, 0x0b, 0x06,
106
+  0x03, 0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68, 0x65, 0x72, 0x31, 0x10,
107
+  0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x42, 0x6f, 0x75,
108
+  0x72, 0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04,
109
+  0x0a, 0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d, 0x43, 0x56, 0x4c, 0x31,
110
+  0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x32, 0x53,
111
+  0x55, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09,
112
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x82, 0x01,
113
+  0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
114
+  0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01,
115
+  0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb7, 0xd4, 0x52, 0xd5, 0x58, 0xac,
116
+  0x0a, 0x1d, 0x71, 0x8f, 0x1a, 0x68, 0xff, 0x0f, 0xfa, 0x2f, 0xa3, 0x0c,
117
+  0x09, 0xca, 0xfb, 0xd5, 0x7e, 0x4c, 0xc0, 0x6a, 0xc6, 0xa0, 0xc0, 0x49,
118
+  0x7d, 0x17, 0xae, 0xba, 0x9e, 0x51, 0x6f, 0x6d, 0xe2, 0x62, 0x03, 0x07,
119
+  0x70, 0xbe, 0x56, 0x53, 0xb9, 0xad, 0xe5, 0x69, 0xa4, 0xd5, 0x91, 0x43,
120
+  0x5e, 0x67, 0x4d, 0x77, 0x26, 0x29, 0x25, 0xbd, 0xaa, 0xbb, 0x31, 0x34,
121
+  0xf3, 0x0f, 0x0a, 0xa6, 0xbf, 0x8e, 0xdb, 0x7e, 0x4e, 0xd5, 0x8d, 0x8c,
122
+  0x60, 0x5d, 0x89, 0xc5, 0x8e, 0x6a, 0xc2, 0xa1, 0xf2, 0x34, 0xb4, 0x83,
123
+  0xae, 0xa1, 0x74, 0x53, 0xe8, 0x34, 0x2d, 0x8e, 0x0e, 0xb8, 0x2d, 0x14,
124
+  0xcb, 0xe9, 0x85, 0xb7, 0x3d, 0xc9, 0x8e, 0xfd, 0x77, 0x27, 0x3a, 0x5a,
125
+  0xa9, 0x5c, 0xd9, 0xbf, 0x93, 0x00, 0x9a, 0x53, 0xd7, 0xff, 0xca, 0x77,
126
+  0x0b, 0x3f, 0xf0, 0x62, 0xd5, 0xa2, 0xe0, 0x3a, 0xfe, 0xb9, 0x8a, 0xb6,
127
+  0x1d, 0x2d, 0x49, 0xcc, 0x3d, 0x2a, 0xad, 0x5c, 0x7b, 0x8d, 0x42, 0xbd,
128
+  0x2c, 0x95, 0x6b, 0x59, 0x58, 0x19, 0xcf, 0x22, 0xb0, 0x9c, 0xca, 0xd4,
129
+  0x54, 0x5b, 0x2d, 0xf1, 0xcf, 0x40, 0x74, 0x3e, 0x0a, 0x08, 0xad, 0x47,
130
+  0xd0, 0x72, 0x5d, 0x4e, 0x57, 0xe9, 0x3b, 0x25, 0x96, 0x43, 0x35, 0xb0,
131
+  0x32, 0x17, 0xc0, 0xf3, 0xbb, 0x5c, 0x15, 0x47, 0xeb, 0xf0, 0xb5, 0x14,
132
+  0x8e, 0x27, 0x0f, 0x00, 0x1a, 0x64, 0x89, 0xed, 0x3e, 0xcf, 0x8b, 0xb3,
133
+  0x80, 0x86, 0xb8, 0x6a, 0x30, 0x23, 0xf8, 0xad, 0x72, 0xfa, 0xde, 0x48,
134
+  0x42, 0xff, 0xb7, 0x54, 0xc5, 0x7a, 0x06, 0x42, 0x38, 0x35, 0x69, 0x3e,
135
+  0xba, 0x0e, 0xdb, 0x5e, 0x0e, 0xa1, 0xbd, 0x11, 0xf9, 0x65, 0x8d, 0x32,
136
+  0xce, 0xb7, 0xb0, 0xe8, 0x5c, 0x4c, 0x9e, 0xff, 0x13, 0x47, 0x02, 0x03,
137
+  0x01, 0x00, 0x01, 0xa3, 0x53, 0x30, 0x51, 0x30, 0x1d, 0x06, 0x03, 0x55,
138
+  0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xfd, 0x47, 0x63, 0x07, 0x27, 0x21,
139
+  0x49, 0x64, 0xe9, 0x31, 0xfe, 0x34, 0x78, 0xb9, 0x7d, 0xd4, 0x60, 0xb2,
140
+  0x50, 0x2f, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
141
+  0x16, 0x80, 0x14, 0xfd, 0x47, 0x63, 0x07, 0x27, 0x21, 0x49, 0x64, 0xe9,
142
+  0x31, 0xfe, 0x34, 0x78, 0xb9, 0x7d, 0xd4, 0x60, 0xb2, 0x50, 0x2f, 0x30,
143
+  0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30,
144
+  0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
145
+  0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00,
146
+  0x6f, 0xdd, 0x8c, 0xd1, 0xfd, 0xef, 0x84, 0x26, 0x40, 0x4b, 0x19, 0xd1,
147
+  0x0e, 0x32, 0xe8, 0x8a, 0x1b, 0xb4, 0xdd, 0x3e, 0x0d, 0x31, 0xf3, 0xec,
148
+  0x20, 0xc8, 0x6c, 0xe7, 0x0f, 0x05, 0x59, 0x0d, 0x03, 0xe3, 0x47, 0xe4,
149
+  0x22, 0x34, 0xb1, 0x95, 0xbc, 0xe1, 0x1f, 0x29, 0x04, 0x02, 0x5b, 0x99,
150
+  0x2c, 0x43, 0xf5, 0x5e, 0xdf, 0x76, 0xc9, 0x13, 0x6e, 0xb2, 0x15, 0xb2,
151
+  0x9f, 0xda, 0x39, 0x3a, 0xbd, 0x8f, 0x8b, 0x7e, 0x21, 0x89, 0x77, 0x15,
152
+  0x1a, 0x31, 0xe5, 0x0a, 0xe4, 0xe2, 0x83, 0xee, 0xf7, 0xc2, 0xbf, 0x0e,
153
+  0x91, 0xad, 0x93, 0x8b, 0xea, 0xb9, 0xdc, 0x04, 0xd6, 0xd8, 0xe6, 0x31,
154
+  0x97, 0x79, 0x26, 0xbf, 0x8f, 0xfd, 0xef, 0xfb, 0xf4, 0x23, 0x70, 0xbb,
155
+  0x47, 0x71, 0xae, 0x1f, 0x36, 0x01, 0x0a, 0xa2, 0xb0, 0xeb, 0x95, 0xf3,
156
+  0x8e, 0x22, 0x83, 0x9e, 0x36, 0xff, 0x96, 0x13, 0x2d, 0x03, 0x9b, 0x46,
157
+  0xe3, 0xc0, 0xae, 0xfc, 0x94, 0xea, 0x22, 0xa1, 0x07, 0xbe, 0xf5, 0x31,
158
+  0xc2, 0x68, 0xef, 0xfb, 0x3f, 0xf4, 0x0d, 0x9d, 0xb6, 0x7a, 0xda, 0x26,
159
+  0x65, 0xc3, 0xb6, 0x19, 0xfa, 0x75, 0x0a, 0xc2, 0xb6, 0x62, 0x4e, 0xb1,
160
+  0x7c, 0x31, 0x6e, 0x09, 0x0f, 0x2c, 0x06, 0x2e, 0xd8, 0x19, 0x21, 0xe3,
161
+  0x00, 0x6a, 0x07, 0x24, 0xc8, 0x55, 0xa8, 0x07, 0xa0, 0xec, 0xf5, 0x28,
162
+  0xcc, 0x8c, 0x0d, 0x96, 0x35, 0xbf, 0x9d, 0x11, 0xd8, 0x92, 0x99, 0xf7,
163
+  0xf2, 0xe6, 0xb0, 0x84, 0x30, 0xa3, 0x1b, 0x63, 0x02, 0xde, 0x71, 0x3b,
164
+  0x6c, 0x21, 0x43, 0x1b, 0x2c, 0xa0, 0xc7, 0x67, 0xe1, 0x7c, 0x0b, 0x0a,
165
+  0x4d, 0x05, 0x08, 0xba, 0xdf, 0x16, 0xaf, 0x7d, 0xd1, 0x0f, 0xf8, 0x33,
166
+  0x0a, 0x93, 0xbf, 0x12, 0xdb, 0x78, 0x0b, 0x00, 0x02, 0x60, 0xd7, 0x5b,
167
+  0xa1, 0xa1, 0x64, 0x63
168
+};
169
+
170
+unsigned char private_client_bin_key[] = {
171
+  0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00,
172
+  0xe8, 0x23, 0xba, 0x25, 0x34, 0x87, 0x4a, 0x3e, 0x8f, 0x9f, 0x6e, 0x03,
173
+  0xea, 0x9e, 0x9f, 0xd0, 0x40, 0x8d, 0x78, 0x2d, 0x33, 0x66, 0xa2, 0xda,
174
+  0xed, 0xfd, 0x92, 0x12, 0x2d, 0xd5, 0xa0, 0xc2, 0xb5, 0xd9, 0x7f, 0x85,
175
+  0x2e, 0xf9, 0x68, 0x73, 0x6d, 0x91, 0x8f, 0xf9, 0x5d, 0x44, 0x49, 0xa3,
176
+  0xa5, 0x5a, 0xc9, 0x55, 0x42, 0x4f, 0x77, 0x0b, 0xc3, 0x6d, 0x19, 0x5d,
177
+  0x6a, 0x22, 0xa1, 0x66, 0xd9, 0x2d, 0x5d, 0x3f, 0xda, 0xa0, 0xcd, 0xd0,
178
+  0xcf, 0xb8, 0x92, 0xb7, 0x43, 0x75, 0xda, 0x5a, 0x13, 0x59, 0x42, 0x44,
179
+  0xdc, 0xb6, 0x4e, 0xaf, 0x28, 0xeb, 0x5b, 0x05, 0xea, 0x11, 0xda, 0x7a,
180
+  0xc0, 0x48, 0x2b, 0xbd, 0x6a, 0xf0, 0x10, 0xb4, 0xf2, 0x66, 0xa8, 0xe0,
181
+  0x2b, 0x57, 0x6b, 0x25, 0x3e, 0x28, 0xd2, 0x24, 0x66, 0xdd, 0xcf, 0x72,
182
+  0xbc, 0x90, 0x4a, 0x16, 0x48, 0xbb, 0x16, 0x85, 0x4b, 0x76, 0x37, 0x64,
183
+  0x53, 0x74, 0x33, 0xea, 0xe1, 0x5b, 0xa8, 0x29, 0x19, 0x03, 0xc6, 0x62,
184
+  0xec, 0x3d, 0xe5, 0x9c, 0xc3, 0x62, 0x4b, 0xca, 0x5b, 0xdf, 0x34, 0x51,
185
+  0xa6, 0xd6, 0x88, 0x51, 0x69, 0x6c, 0xf8, 0x38, 0xe7, 0xd3, 0x94, 0x6b,
186
+  0xf3, 0x92, 0xe7, 0xcf, 0xea, 0x9d, 0x60, 0x7d, 0x14, 0x58, 0x3f, 0x0d,
187
+  0xe9, 0x69, 0xd2, 0x31, 0x66, 0xec, 0xec, 0xa4, 0x9c, 0x48, 0xc1, 0x07,
188
+  0x62, 0x2c, 0xba, 0x7e, 0xea, 0xb9, 0x09, 0x81, 0x1f, 0xe5, 0x5d, 0xfa,
189
+  0xa8, 0x49, 0x29, 0x43, 0xbe, 0xab, 0xbe, 0xe3, 0x24, 0xe8, 0x13, 0x0d,
190
+  0x13, 0x84, 0x06, 0xaf, 0x08, 0x5a, 0x92, 0x71, 0xe4, 0xca, 0x5b, 0x3f,
191
+  0x79, 0x6c, 0x87, 0x4c, 0x2b, 0xe4, 0x43, 0xb8, 0x2c, 0x3f, 0xb9, 0x39,
192
+  0x64, 0x6f, 0xa6, 0x64, 0x41, 0x06, 0x92, 0x8e, 0x4b, 0xc4, 0xfb, 0xc7,
193
+  0x2b, 0x0f, 0xcc, 0xd1, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01,
194
+  0x01, 0x00, 0xdd, 0xf9, 0x43, 0xc6, 0xcd, 0xca, 0xcc, 0x40, 0xb4, 0x3f,
195
+  0x24, 0x08, 0xd4, 0xb1, 0x67, 0x69, 0xd0, 0x40, 0x36, 0x79, 0x2a, 0x5c,
196
+  0x6b, 0x3f, 0x63, 0x31, 0x04, 0x1b, 0x23, 0xfe, 0xd1, 0xa1, 0x3e, 0x18,
197
+  0x42, 0xea, 0xcc, 0x77, 0x2a, 0xdc, 0xad, 0x19, 0xf2, 0x8c, 0xe5, 0x15,
198
+  0x26, 0x41, 0x38, 0x1d, 0x6e, 0xc5, 0x7b, 0x09, 0xd7, 0x70, 0xc5, 0x27,
199
+  0x2e, 0x88, 0xf7, 0xb3, 0x33, 0x98, 0xcf, 0xf4, 0xa3, 0xe5, 0x2a, 0x1e,
200
+  0x77, 0x8f, 0xc3, 0x00, 0xe0, 0x32, 0x23, 0x6c, 0xaf, 0x25, 0x50, 0xb9,
201
+  0x1a, 0x38, 0x14, 0xc0, 0xb2, 0xce, 0xa5, 0x17, 0x20, 0x4b, 0xb0, 0x7d,
202
+  0xef, 0xe7, 0x4e, 0xb3, 0xf4, 0x37, 0x44, 0xe9, 0x57, 0x60, 0x5f, 0x25,
203
+  0xb1, 0x37, 0xe1, 0xd9, 0xce, 0x97, 0xa7, 0x2f, 0x8b, 0x79, 0xc9, 0x6f,
204
+  0x32, 0x2d, 0xa9, 0x87, 0x63, 0x80, 0x99, 0x7d, 0x64, 0x52, 0xb1, 0x16,
205
+  0x5a, 0x00, 0x1c, 0x4f, 0x8c, 0xf0, 0x54, 0x46, 0x84, 0x7d, 0x46, 0xa5,
206
+  0x48, 0xc3, 0xeb, 0x99, 0x2d, 0x7b, 0x5f, 0xcc, 0x00, 0x43, 0x06, 0x97,
207
+  0x68, 0x14, 0xdf, 0xaa, 0x9a, 0xc2, 0xb1, 0xfb, 0x32, 0xc1, 0x1a, 0x20,
208
+  0x27, 0xa7, 0xe1, 0x36, 0xfd, 0xd8, 0x2c, 0xf1, 0xe2, 0xf8, 0x30, 0x8d,
209
+  0x7f, 0x16, 0xb5, 0x10, 0xc5, 0x60, 0x8b, 0xae, 0x94, 0x6f, 0x9e, 0xbe,
210
+  0x09, 0x54, 0x99, 0x16, 0xa2, 0x38, 0x3d, 0xef, 0xab, 0x32, 0x19, 0xa1,
211
+  0x96, 0xda, 0xcb, 0x2c, 0xc4, 0x20, 0x0f, 0xff, 0xc6, 0xfa, 0x4d, 0xfd,
212
+  0x91, 0x4e, 0x1f, 0xd1, 0x76, 0x79, 0x7a, 0x3e, 0x2e, 0x0e, 0x8d, 0x2e,
213
+  0xce, 0xe1, 0x47, 0x7b, 0x41, 0xba, 0x0f, 0x91, 0x09, 0x67, 0x0d, 0xb2,
214
+  0x87, 0xbc, 0xd9, 0x44, 0xa2, 0xa5, 0x83, 0xb6, 0x50, 0x45, 0x85, 0x8d,
215
+  0x01, 0xc0, 0xfc, 0x74, 0x48, 0x3d, 0x02, 0x81, 0x81, 0x00, 0xf4, 0x32,
216
+  0x6b, 0xd6, 0x5d, 0x17, 0xe2, 0x96, 0x1d, 0x04, 0xfe, 0x39, 0xc4, 0xee,
217
+  0x49, 0xbf, 0x01, 0xc2, 0x01, 0x80, 0x92, 0x84, 0x7e, 0x3a, 0x56, 0xa0,
218
+  0xfc, 0xf4, 0xa7, 0x4d, 0xbd, 0x42, 0x35, 0x06, 0xa2, 0x7b, 0xfc, 0x29,
219
+  0x4c, 0xf2, 0xe6, 0x24, 0x34, 0xd0, 0x7f, 0x1d, 0xad, 0x0a, 0x45, 0xc2,
220
+  0x1d, 0x33, 0x53, 0xee, 0x2f, 0x4e, 0x24, 0xaa, 0x1a, 0xe0, 0x7b, 0xbb,
221
+  0x53, 0x7e, 0x1f, 0xbd, 0xf0, 0xfc, 0xb0, 0x76, 0x95, 0x83, 0x03, 0x94,
222
+  0x44, 0xc0, 0x76, 0x96, 0x85, 0xa1, 0xc5, 0x40, 0xbe, 0x23, 0xf4, 0x3c,
223
+  0xac, 0xe0, 0xb6, 0x95, 0x3e, 0x56, 0xe4, 0x5c, 0x92, 0x09, 0xda, 0xd4,
224
+  0x1d, 0x7c, 0x25, 0x42, 0xa4, 0xfa, 0xff, 0x95, 0x3f, 0x63, 0x18, 0x3b,
225
+  0xab, 0x5c, 0x01, 0xdd, 0x27, 0x1b, 0xc5, 0x5a, 0x8e, 0x0e, 0xbb, 0x1a,
226
+  0x4e, 0x87, 0x7b, 0xc6, 0x15, 0x43, 0x02, 0x81, 0x81, 0x00, 0xf3, 0x5c,
227
+  0x1d, 0x00, 0x46, 0x24, 0xc9, 0xc2, 0x89, 0x50, 0x53, 0x20, 0xaf, 0x13,
228
+  0xb0, 0x11, 0x0c, 0x29, 0x36, 0x73, 0x6f, 0x55, 0x80, 0xfe, 0xe8, 0x18,
229
+  0x1c, 0xa7, 0x62, 0x6f, 0xb6, 0x8f, 0x28, 0xa4, 0xaf, 0xc7, 0xb9, 0xe2,
230
+  0x1d, 0x72, 0x03, 0xaf, 0x99, 0x44, 0xe9, 0x82, 0xdc, 0xf9, 0x19, 0x11,
231
+  0x26, 0xe5, 0xe9, 0x46, 0x35, 0xb1, 0x2f, 0x01, 0xeb, 0x4f, 0x30, 0xdd,
232
+  0x97, 0xe1, 0x2b, 0x37, 0x5e, 0x1c, 0xc1, 0xec, 0xf4, 0xb0, 0xa8, 0x7a,
233
+  0x31, 0x48, 0x66, 0xe5, 0x44, 0xbc, 0xa5, 0x32, 0x4a, 0x2f, 0x1f, 0x1e,
234
+  0xda, 0xca, 0x9d, 0x57, 0x02, 0x1c, 0x9a, 0x05, 0x15, 0x7a, 0x76, 0x2f,
235
+  0xc2, 0x4d, 0x9f, 0xad, 0xa4, 0xbd, 0xc6, 0x1b, 0x8c, 0x8f, 0xb6, 0x04,
236
+  0x01, 0xe7, 0xfc, 0x5e, 0xa0, 0x09, 0x67, 0x61, 0xcc, 0xc1, 0x00, 0x2e,
237
+  0xea, 0xf9, 0x73, 0xfd, 0xea, 0x5b, 0x02, 0x81, 0x80, 0x05, 0x8d, 0x47,
238
+  0xea, 0x5d, 0xbf, 0x77, 0x45, 0x56, 0x6f, 0x90, 0xa0, 0x1b, 0x9c, 0x17,
239
+  0x4d, 0x22, 0x6b, 0x18, 0xc1, 0xa5, 0x93, 0x21, 0x93, 0x8d, 0xf8, 0xa7,
240
+  0x07, 0xa0, 0xee, 0x21, 0x89, 0x69, 0xcf, 0x36, 0xce, 0x7e, 0xd3, 0x29,
241
+  0x8e, 0xb4, 0x30, 0xca, 0x8a, 0x9a, 0xf9, 0x3f, 0xbf, 0xe6, 0x0a, 0x1d,
242
+  0xc3, 0xd6, 0xfa, 0xa9, 0x54, 0xab, 0x7c, 0xba, 0x93, 0xb3, 0xfc, 0x74,
243
+  0x4f, 0x7f, 0xc5, 0x3f, 0xbf, 0x5e, 0xfb, 0xb3, 0x36, 0x81, 0x54, 0x53,
244
+  0xa3, 0xd4, 0x8e, 0x63, 0x87, 0x64, 0x06, 0xae, 0xcb, 0xfe, 0x77, 0x8a,
245
+  0xae, 0xa9, 0x38, 0x07, 0x6c, 0xce, 0x50, 0x54, 0x79, 0xa8, 0xe1, 0xfd,
246
+  0xb1, 0x9e, 0xdf, 0x3f, 0x04, 0xfd, 0xde, 0x94, 0xcc, 0x59, 0xf6, 0xb1,
247
+  0x54, 0xac, 0x2e, 0x2c, 0xff, 0x72, 0xa3, 0x36, 0x6b, 0x9b, 0x51, 0x63,
248
+  0xcb, 0xac, 0xc2, 0xba, 0x25, 0x02, 0x81, 0x80, 0x09, 0xce, 0x8f, 0x78,
249
+  0xa0, 0x5b, 0x01, 0x2a, 0x6e, 0xc0, 0x26, 0xe9, 0x6d, 0x44, 0xbc, 0xd6,
250
+  0xa3, 0x07, 0xd2, 0x22, 0xea, 0xbc, 0xa6, 0x5b, 0x1f, 0x5d, 0x41, 0x62,
251
+  0x59, 0x6c, 0x29, 0x0e, 0x31, 0xd4, 0x19, 0x25, 0x52, 0x4f, 0x53, 0x62,
252
+  0x71, 0xd5, 0x94, 0xb6, 0x9b, 0x36, 0x63, 0xd3, 0x41, 0xf8, 0x57, 0xf9,
253
+  0xf1, 0xe1, 0x9b, 0x6e, 0x4d, 0x77, 0xa5, 0x54, 0xe6, 0xa2, 0x37, 0x69,
254
+  0xa2, 0x85, 0x33, 0xac, 0xb2, 0xff, 0xea, 0x88, 0x67, 0xf1, 0xac, 0xa4,
255
+  0xbf, 0x48, 0xc3, 0xf1, 0x5a, 0x32, 0xe1, 0x9c, 0x6e, 0x83, 0x9e, 0xcb,
256
+  0x85, 0x75, 0xa9, 0x27, 0x1f, 0xe9, 0xce, 0x88, 0xc5, 0xd4, 0x7c, 0xdf,
257
+  0x05, 0xed, 0x48, 0x73, 0x41, 0x55, 0x80, 0xdf, 0x95, 0xb5, 0x29, 0xa2,
258
+  0x80, 0xa0, 0x0b, 0x90, 0xf5, 0x72, 0x92, 0x7e, 0xc0, 0x94, 0x23, 0x71,
259
+  0xf4, 0x03, 0xaa, 0x7b, 0x02, 0x81, 0x81, 0x00, 0xd9, 0x31, 0xb1, 0xbd,
260
+  0x33, 0x0c, 0x83, 0x16, 0x2a, 0x2d, 0xbe, 0xde, 0x26, 0x15, 0x94, 0xe0,
261
+  0x5d, 0x1e, 0x3d, 0x3b, 0xb7, 0x6f, 0x1b, 0x89, 0x14, 0x3d, 0x75, 0x19,
262
+  0x25, 0x08, 0xd4, 0xfa, 0x6b, 0x12, 0x37, 0x49, 0xca, 0x4a, 0x21, 0xd8,
263
+  0x83, 0x86, 0xf6, 0x29, 0x64, 0x48, 0xd5, 0xce, 0x5e, 0x5f, 0xf4, 0x2f,
264
+  0x07, 0x5a, 0x26, 0xc7, 0x8c, 0x1a, 0x8c, 0x6e, 0xcd, 0x30, 0x4a, 0x9a,
265
+  0xd5, 0xb6, 0x4d, 0x06, 0x1d, 0xc1, 0xbe, 0xb4, 0x63, 0xf8, 0x95, 0xbf,
266
+  0xb9, 0xc4, 0xd2, 0x69, 0xc1, 0x80, 0x48, 0xb8, 0x26, 0xa5, 0x1f, 0x5d,
267
+  0x3b, 0x85, 0xd5, 0xda, 0xd3, 0x01, 0x80, 0xbb, 0xa3, 0xce, 0xa4, 0x20,
268
+  0xaf, 0x41, 0x04, 0xf2, 0x6c, 0xfc, 0x8a, 0xc2, 0x02, 0x3e, 0x9a, 0xc3,
269
+  0xdd, 0xf6, 0x86, 0x95, 0xbf, 0xa5, 0xdf, 0x2e, 0xc1, 0xe8, 0xec, 0x2f,
270
+  0xd3, 0xef, 0x70, 0x7b
271
+};
272
+unsigned int private_client_bin_key_len = 1192;
273
+
274
+#endif

+ 41
- 0
lib/readme.txt View File

@@ -0,0 +1,41 @@
1
+
2
+This directory is intended for the project specific (private) libraries.
3
+PlatformIO will compile them to static libraries and link to executable file.
4
+
5
+The source code of each library should be placed in separate directory, like
6
+"lib/private_lib/[here are source files]".
7
+
8
+For example, see how can be organized `Foo` and `Bar` libraries:
9
+
10
+|--lib
11
+|  |
12
+|  |--Bar
13
+|  |  |--docs
14
+|  |  |--examples
15
+|  |  |--src
16
+|  |     |- Bar.c
17
+|  |     |- Bar.h
18
+|  |  |- library.json (optional, custom build options, etc) http://docs.platformio.org/page/librarymanager/config.html
19
+|  |
20
+|  |--Foo
21
+|  |  |- Foo.c
22
+|  |  |- Foo.h
23
+|  |
24
+|  |- readme.txt --> THIS FILE
25
+|
26
+|- platformio.ini
27
+|--src
28
+   |- main.c
29
+
30
+Then in `src/main.c` you should use:
31
+
32
+#include <Foo.h>
33
+#include <Bar.h>
34
+
35
+// rest H/C/CPP code
36
+
37
+PlatformIO will find your libraries automatically, configure preprocessor's
38
+include paths and build them.
39
+
40
+More information about PlatformIO Library Dependency Finder
41
+- http://docs.platformio.org/page/librarymanager/ldf.html

+ 15
- 0
platformio.ini View File

@@ -0,0 +1,15 @@
1
+; PlatformIO Project Configuration File
2
+;
3
+;   Build options: build flags, source filter
4
+;   Upload options: custom upload port, speed and extra flags
5
+;   Library options: dependencies, extra library storages
6
+;   Advanced options: extra scripting
7
+;
8
+; Please visit documentation for the other options and examples
9
+; http://docs.platformio.org/page/projectconf.html
10
+
11
+[env:nodemcuv2]
12
+platform = espressif8266
13
+board = nodemcuv2
14
+framework = arduino
15
+board_build.f_cpu = 160000000L

+ 276
- 0
src/certs.h View File

@@ -0,0 +1,276 @@
1
+#ifndef CERTS_H
2
+#define CERTS_H
3
+
4
+unsigned char certs_client_bin_crt[] = {
5
+  0x30, 0x82, 0x03, 0xb9, 0x30, 0x82, 0x02, 0xa1, 0xa0, 0x03, 0x02, 0x01,
6
+  0x02, 0x02, 0x01, 0x04, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
7
+  0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x63, 0x31, 0x0b, 0x30,
8
+  0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31, 0x0d,
9
+  0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68, 0x65,
10
+  0x72, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07,
11
+  0x42, 0x6f, 0x75, 0x72, 0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f, 0x06,
12
+  0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d, 0x43,
13
+  0x56, 0x4c, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c,
14
+  0x03, 0x32, 0x53, 0x55, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04,
15
+  0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
16
+  0x30, 0x1e, 0x17, 0x0d, 0x31, 0x38, 0x31, 0x32, 0x30, 0x36, 0x31, 0x38,
17
+  0x30, 0x36, 0x32, 0x30, 0x5a, 0x17, 0x0d, 0x31, 0x39, 0x31, 0x32, 0x30,
18
+  0x36, 0x31, 0x38, 0x30, 0x36, 0x32, 0x30, 0x5a, 0x30, 0x60, 0x31, 0x0b,
19
+  0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31,
20
+  0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68,
21
+  0x65, 0x72, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c,
22
+  0x07, 0x42, 0x6f, 0x75, 0x72, 0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f,
23
+  0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d,
24
+  0x43, 0x56, 0x4c, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b,
25
+  0x0c, 0x03, 0x32, 0x53, 0x55, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55,
26
+  0x04, 0x03, 0x0c, 0x06, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x30, 0x82,
27
+  0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
28
+  0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82,
29
+  0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xe8, 0x23, 0xba, 0x25, 0x34,
30
+  0x87, 0x4a, 0x3e, 0x8f, 0x9f, 0x6e, 0x03, 0xea, 0x9e, 0x9f, 0xd0, 0x40,
31
+  0x8d, 0x78, 0x2d, 0x33, 0x66, 0xa2, 0xda, 0xed, 0xfd, 0x92, 0x12, 0x2d,
32
+  0xd5, 0xa0, 0xc2, 0xb5, 0xd9, 0x7f, 0x85, 0x2e, 0xf9, 0x68, 0x73, 0x6d,
33
+  0x91, 0x8f, 0xf9, 0x5d, 0x44, 0x49, 0xa3, 0xa5, 0x5a, 0xc9, 0x55, 0x42,
34
+  0x4f, 0x77, 0x0b, 0xc3, 0x6d, 0x19, 0x5d, 0x6a, 0x22, 0xa1, 0x66, 0xd9,
35
+  0x2d, 0x5d, 0x3f, 0xda, 0xa0, 0xcd, 0xd0, 0xcf, 0xb8, 0x92, 0xb7, 0x43,
36
+  0x75, 0xda, 0x5a, 0x13, 0x59, 0x42, 0x44, 0xdc, 0xb6, 0x4e, 0xaf, 0x28,
37
+  0xeb, 0x5b, 0x05, 0xea, 0x11, 0xda, 0x7a, 0xc0, 0x48, 0x2b, 0xbd, 0x6a,
38
+  0xf0, 0x10, 0xb4, 0xf2, 0x66, 0xa8, 0xe0, 0x2b, 0x57, 0x6b, 0x25, 0x3e,
39
+  0x28, 0xd2, 0x24, 0x66, 0xdd, 0xcf, 0x72, 0xbc, 0x90, 0x4a, 0x16, 0x48,
40
+  0xbb, 0x16, 0x85, 0x4b, 0x76, 0x37, 0x64, 0x53, 0x74, 0x33, 0xea, 0xe1,
41
+  0x5b, 0xa8, 0x29, 0x19, 0x03, 0xc6, 0x62, 0xec, 0x3d, 0xe5, 0x9c, 0xc3,
42
+  0x62, 0x4b, 0xca, 0x5b, 0xdf, 0x34, 0x51, 0xa6, 0xd6, 0x88, 0x51, 0x69,
43
+  0x6c, 0xf8, 0x38, 0xe7, 0xd3, 0x94, 0x6b, 0xf3, 0x92, 0xe7, 0xcf, 0xea,
44
+  0x9d, 0x60, 0x7d, 0x14, 0x58, 0x3f, 0x0d, 0xe9, 0x69, 0xd2, 0x31, 0x66,
45
+  0xec, 0xec, 0xa4, 0x9c, 0x48, 0xc1, 0x07, 0x62, 0x2c, 0xba, 0x7e, 0xea,
46
+  0xb9, 0x09, 0x81, 0x1f, 0xe5, 0x5d, 0xfa, 0xa8, 0x49, 0x29, 0x43, 0xbe,
47
+  0xab, 0xbe, 0xe3, 0x24, 0xe8, 0x13, 0x0d, 0x13, 0x84, 0x06, 0xaf, 0x08,
48
+  0x5a, 0x92, 0x71, 0xe4, 0xca, 0x5b, 0x3f, 0x79, 0x6c, 0x87, 0x4c, 0x2b,
49
+  0xe4, 0x43, 0xb8, 0x2c, 0x3f, 0xb9, 0x39, 0x64, 0x6f, 0xa6, 0x64, 0x41,
50
+  0x06, 0x92, 0x8e, 0x4b, 0xc4, 0xfb, 0xc7, 0x2b, 0x0f, 0xcc, 0xd1, 0x02,
51
+  0x03, 0x01, 0x00, 0x01, 0xa3, 0x7b, 0x30, 0x79, 0x30, 0x09, 0x06, 0x03,
52
+  0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x2c, 0x06, 0x09, 0x60,
53
+  0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, 0x16, 0x1d,
54
+  0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, 0x47, 0x65, 0x6e, 0x65,
55
+  0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66,
56
+  0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e,
57
+  0x04, 0x16, 0x04, 0x14, 0x54, 0x51, 0x24, 0xc1, 0x50, 0x47, 0x40, 0xa3,
58
+  0xc4, 0xe0, 0x56, 0x64, 0xb9, 0xa5, 0xe1, 0xb0, 0xfe, 0xa4, 0x73, 0xba,
59
+  0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80,
60
+  0x14, 0xfd, 0x47, 0x63, 0x07, 0x27, 0x21, 0x49, 0x64, 0xe9, 0x31, 0xfe,
61
+  0x34, 0x78, 0xb9, 0x7d, 0xd4, 0x60, 0xb2, 0x50, 0x2f, 0x30, 0x0d, 0x06,
62
+  0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00,
63
+  0x03, 0x82, 0x01, 0x01, 0x00, 0x4f, 0x25, 0xdf, 0x17, 0xa3, 0xf7, 0xad,
64
+  0x90, 0xd4, 0xec, 0x35, 0x78, 0x64, 0x61, 0xb6, 0xc0, 0x0c, 0x47, 0x61,
65
+  0x6d, 0x42, 0xe0, 0x97, 0x95, 0x87, 0x87, 0xa0, 0xc9, 0x28, 0x22, 0xb6,
66
+  0xa0, 0x00, 0xc1, 0x42, 0xa7, 0x8e, 0xb8, 0x97, 0x49, 0x5b, 0x28, 0x82,
67
+  0xd9, 0x08, 0x25, 0xe8, 0xd7, 0x69, 0x08, 0x88, 0x8d, 0x6d, 0xd6, 0xa8,
68
+  0x78, 0xd6, 0x8d, 0xc1, 0xdf, 0x77, 0xdc, 0x56, 0x8b, 0x4d, 0xe7, 0xc6,
69
+  0x65, 0xa3, 0x86, 0x03, 0x6c, 0xaa, 0x36, 0x86, 0x9d, 0x2f, 0x00, 0x99,
70
+  0x13, 0xc5, 0x15, 0xe1, 0xfb, 0x67, 0xf5, 0xb5, 0x9d, 0xd2, 0x43, 0x88,
71
+  0x63, 0xca, 0x69, 0xc0, 0x98, 0x5b, 0xb9, 0x7e, 0x32, 0x88, 0x03, 0xa5,
72
+  0x29, 0xec, 0x0f, 0x0b, 0x2c, 0x12, 0x45, 0x6c, 0xa3, 0x2e, 0xff, 0xc7,
73
+  0x7d, 0x11, 0x23, 0x99, 0x6f, 0x0d, 0x03, 0xc1, 0x2e, 0x80, 0xac, 0x69,
74
+  0x06, 0x7a, 0xa9, 0xc9, 0xd6, 0xb3, 0xb7, 0x29, 0xe4, 0xbe, 0x33, 0xaf,
75
+  0x1f, 0x5a, 0x03, 0xb1, 0xf2, 0x8d, 0xc8, 0xec, 0xf4, 0xb8, 0x94, 0xc1,
76
+  0x61, 0x3f, 0xb8, 0xaf, 0x8c, 0x00, 0x38, 0xd3, 0x01, 0x2d, 0xfb, 0x8b,
77
+  0xbf, 0xdb, 0x97, 0xff, 0x15, 0xc1, 0xc7, 0x0e, 0x96, 0x7d, 0x5b, 0xbf,
78
+  0x74, 0x60, 0x5e, 0xe5, 0x7f, 0xb1, 0x26, 0x29, 0xd8, 0x4f, 0x5b, 0xfb,
79
+  0x35, 0x96, 0x21, 0x86, 0x1c, 0xe8, 0x15, 0x67, 0x07, 0xd3, 0x1e, 0x29,
80
+  0xca, 0x6c, 0xf8, 0x50, 0x22, 0xe6, 0x3b, 0xa5, 0xd1, 0xb1, 0x55, 0xd3,
81
+  0x03, 0x9c, 0x3f, 0x4d, 0x6b, 0x54, 0x1e, 0x9a, 0x32, 0x25, 0x26, 0x72,
82
+  0x18, 0xb0, 0xb2, 0xff, 0xce, 0xf3, 0xa0, 0x42, 0x8b, 0xf2, 0xb0, 0xbd,
83
+  0xc9, 0x35, 0xde, 0xdc, 0xa4, 0xa4, 0xbf, 0xee, 0xc5, 0x07, 0x4a, 0x3c,
84
+  0xa8, 0x85, 0x9b, 0x65, 0xcb, 0xa5, 0x11, 0xb0, 0x60
85
+};
86
+unsigned int certs_client_bin_crt_len = 957;
87
+
88
+//CA CERT
89
+const unsigned char caCert[] PROGMEM = {
90
+  0x30, 0x82, 0x03, 0x9c, 0x30, 0x82, 0x02, 0x84, 0xa0, 0x03, 0x02, 0x01,
91
+  0x02, 0x02, 0x09, 0x00, 0xad, 0xed, 0x82, 0x10, 0xcc, 0x63, 0x41, 0x82,
92
+  0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
93
+  0x0b, 0x05, 0x00, 0x30, 0x63, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
94
+  0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03,
95
+  0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68, 0x65, 0x72, 0x31, 0x10, 0x30,
96
+  0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x42, 0x6f, 0x75, 0x72,
97
+  0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a,
98
+  0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d, 0x43, 0x56, 0x4c, 0x31, 0x0c,
99
+  0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x32, 0x53, 0x55,
100
+  0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c,
101
+  0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x1e, 0x17, 0x0d,
102
+  0x31, 0x38, 0x31, 0x32, 0x30, 0x36, 0x31, 0x36, 0x34, 0x38, 0x30, 0x30,
103
+  0x5a, 0x17, 0x0d, 0x32, 0x33, 0x31, 0x32, 0x30, 0x35, 0x31, 0x36, 0x34,
104
+  0x38, 0x30, 0x30, 0x5a, 0x30, 0x63, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
105
+  0x55, 0x04, 0x06, 0x13, 0x02, 0x46, 0x52, 0x31, 0x0d, 0x30, 0x0b, 0x06,
106
+  0x03, 0x55, 0x04, 0x08, 0x0c, 0x04, 0x43, 0x68, 0x65, 0x72, 0x31, 0x10,
107
+  0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x42, 0x6f, 0x75,
108
+  0x72, 0x67, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04,
109
+  0x0a, 0x0c, 0x08, 0x49, 0x4e, 0x53, 0x41, 0x2d, 0x43, 0x56, 0x4c, 0x31,
110
+  0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x32, 0x53,
111
+  0x55, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09,
112
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x82, 0x01,
113
+  0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
114
+  0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01,
115
+  0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb7, 0xd4, 0x52, 0xd5, 0x58, 0xac,
116
+  0x0a, 0x1d, 0x71, 0x8f, 0x1a, 0x68, 0xff, 0x0f, 0xfa, 0x2f, 0xa3, 0x0c,
117
+  0x09, 0xca, 0xfb, 0xd5, 0x7e, 0x4c, 0xc0, 0x6a, 0xc6, 0xa0, 0xc0, 0x49,
118
+  0x7d, 0x17, 0xae, 0xba, 0x9e, 0x51, 0x6f, 0x6d, 0xe2, 0x62, 0x03, 0x07,
119
+  0x70, 0xbe, 0x56, 0x53, 0xb9, 0xad, 0xe5, 0x69, 0xa4, 0xd5, 0x91, 0x43,
120
+  0x5e, 0x67, 0x4d, 0x77, 0x26, 0x29, 0x25, 0xbd, 0xaa, 0xbb, 0x31, 0x34,
121
+  0xf3, 0x0f, 0x0a, 0xa6, 0xbf, 0x8e, 0xdb, 0x7e, 0x4e, 0xd5, 0x8d, 0x8c,
122
+  0x60, 0x5d, 0x89, 0xc5, 0x8e, 0x6a, 0xc2, 0xa1, 0xf2, 0x34, 0xb4, 0x83,
123
+  0xae, 0xa1, 0x74, 0x53, 0xe8, 0x34, 0x2d, 0x8e, 0x0e, 0xb8, 0x2d, 0x14,
124
+  0xcb, 0xe9, 0x85, 0xb7, 0x3d, 0xc9, 0x8e, 0xfd, 0x77, 0x27, 0x3a, 0x5a,
125
+  0xa9, 0x5c, 0xd9, 0xbf, 0x93, 0x00, 0x9a, 0x53, 0xd7, 0xff, 0xca, 0x77,
126
+  0x0b, 0x3f, 0xf0, 0x62, 0xd5, 0xa2, 0xe0, 0x3a, 0xfe, 0xb9, 0x8a, 0xb6,
127
+  0x1d, 0x2d, 0x49, 0xcc, 0x3d, 0x2a, 0xad, 0x5c, 0x7b, 0x8d, 0x42, 0xbd,
128
+  0x2c, 0x95, 0x6b, 0x59, 0x58, 0x19, 0xcf, 0x22, 0xb0, 0x9c, 0xca, 0xd4,
129
+  0x54, 0x5b, 0x2d, 0xf1, 0xcf, 0x40, 0x74, 0x3e, 0x0a, 0x08, 0xad, 0x47,
130
+  0xd0, 0x72, 0x5d, 0x4e, 0x57, 0xe9, 0x3b, 0x25, 0x96, 0x43, 0x35, 0xb0,
131
+  0x32, 0x17, 0xc0, 0xf3, 0xbb, 0x5c, 0x15, 0x47, 0xeb, 0xf0, 0xb5, 0x14,
132
+  0x8e, 0x27, 0x0f, 0x00, 0x1a, 0x64, 0x89, 0xed, 0x3e, 0xcf, 0x8b, 0xb3,
133
+  0x80, 0x86, 0xb8, 0x6a, 0x30, 0x23, 0xf8, 0xad, 0x72, 0xfa, 0xde, 0x48,
134
+  0x42, 0xff, 0xb7, 0x54, 0xc5, 0x7a, 0x06, 0x42, 0x38, 0x35, 0x69, 0x3e,
135
+  0xba, 0x0e, 0xdb, 0x5e, 0x0e, 0xa1, 0xbd, 0x11, 0xf9, 0x65, 0x8d, 0x32,
136
+  0xce, 0xb7, 0xb0, 0xe8, 0x5c, 0x4c, 0x9e, 0xff, 0x13, 0x47, 0x02, 0x03,
137
+  0x01, 0x00, 0x01, 0xa3, 0x53, 0x30, 0x51, 0x30, 0x1d, 0x06, 0x03, 0x55,
138
+  0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xfd, 0x47, 0x63, 0x07, 0x27, 0x21,
139
+  0x49, 0x64, 0xe9, 0x31, 0xfe, 0x34, 0x78, 0xb9, 0x7d, 0xd4, 0x60, 0xb2,
140
+  0x50, 0x2f, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
141
+  0x16, 0x80, 0x14, 0xfd, 0x47, 0x63, 0x07, 0x27, 0x21, 0x49, 0x64, 0xe9,
142
+  0x31, 0xfe, 0x34, 0x78, 0xb9, 0x7d, 0xd4, 0x60, 0xb2, 0x50, 0x2f, 0x30,
143
+  0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30,
144
+  0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
145
+  0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00,
146
+  0x6f, 0xdd, 0x8c, 0xd1, 0xfd, 0xef, 0x84, 0x26, 0x40, 0x4b, 0x19, 0xd1,
147
+  0x0e, 0x32, 0xe8, 0x8a, 0x1b, 0xb4, 0xdd, 0x3e, 0x0d, 0x31, 0xf3, 0xec,
148
+  0x20, 0xc8, 0x6c, 0xe7, 0x0f, 0x05, 0x59, 0x0d, 0x03, 0xe3, 0x47, 0xe4,
149
+  0x22, 0x34, 0xb1, 0x95, 0xbc, 0xe1, 0x1f, 0x29, 0x04, 0x02, 0x5b, 0x99,
150
+  0x2c, 0x43, 0xf5, 0x5e, 0xdf, 0x76, 0xc9, 0x13, 0x6e, 0xb2, 0x15, 0xb2,
151
+  0x9f, 0xda, 0x39, 0x3a, 0xbd, 0x8f, 0x8b, 0x7e, 0x21, 0x89, 0x77, 0x15,
152
+  0x1a, 0x31, 0xe5, 0x0a, 0xe4, 0xe2, 0x83, 0xee, 0xf7, 0xc2, 0xbf, 0x0e,
153
+  0x91, 0xad, 0x93, 0x8b, 0xea, 0xb9, 0xdc, 0x04, 0xd6, 0xd8, 0xe6, 0x31,
154
+  0x97, 0x79, 0x26, 0xbf, 0x8f, 0xfd, 0xef, 0xfb, 0xf4, 0x23, 0x70, 0xbb,
155
+  0x47, 0x71, 0xae, 0x1f, 0x36, 0x01, 0x0a, 0xa2, 0xb0, 0xeb, 0x95, 0xf3,
156
+  0x8e, 0x22, 0x83, 0x9e, 0x36, 0xff, 0x96, 0x13, 0x2d, 0x03, 0x9b, 0x46,
157
+  0xe3, 0xc0, 0xae, 0xfc, 0x94, 0xea, 0x22, 0xa1, 0x07, 0xbe, 0xf5, 0x31,
158
+  0xc2, 0x68, 0xef, 0xfb, 0x3f, 0xf4, 0x0d, 0x9d, 0xb6, 0x7a, 0xda, 0x26,
159
+  0x65, 0xc3, 0xb6, 0x19, 0xfa, 0x75, 0x0a, 0xc2, 0xb6, 0x62, 0x4e, 0xb1,
160
+  0x7c, 0x31, 0x6e, 0x09, 0x0f, 0x2c, 0x06, 0x2e, 0xd8, 0x19, 0x21, 0xe3,
161
+  0x00, 0x6a, 0x07, 0x24, 0xc8, 0x55, 0xa8, 0x07, 0xa0, 0xec, 0xf5, 0x28,
162
+  0xcc, 0x8c, 0x0d, 0x96, 0x35, 0xbf, 0x9d, 0x11, 0xd8, 0x92, 0x99, 0xf7,
163
+  0xf2, 0xe6, 0xb0, 0x84, 0x30, 0xa3, 0x1b, 0x63, 0x02, 0xde, 0x71, 0x3b,
164
+  0x6c, 0x21, 0x43, 0x1b, 0x2c, 0xa0, 0xc7, 0x67, 0xe1, 0x7c, 0x0b, 0x0a,
165
+  0x4d, 0x05, 0x08, 0xba, 0xdf, 0x16, 0xaf, 0x7d, 0xd1, 0x0f, 0xf8, 0x33,
166
+  0x0a, 0x93, 0xbf, 0x12, 0xdb, 0x78, 0x0b, 0x00, 0x02, 0x60, 0xd7, 0x5b,
167
+  0xa1, 0xa1, 0x64, 0x63
168
+};
169
+
170
+const unsigned int caCertLen = 928;
171
+
172
+unsigned char private_client_bin_key[] = {
173
+  0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00,
174
+  0xe8, 0x23, 0xba, 0x25, 0x34, 0x87, 0x4a, 0x3e, 0x8f, 0x9f, 0x6e, 0x03,
175
+  0xea, 0x9e, 0x9f, 0xd0, 0x40, 0x8d, 0x78, 0x2d, 0x33, 0x66, 0xa2, 0xda,
176
+  0xed, 0xfd, 0x92, 0x12, 0x2d, 0xd5, 0xa0, 0xc2, 0xb5, 0xd9, 0x7f, 0x85,
177
+  0x2e, 0xf9, 0x68, 0x73, 0x6d, 0x91, 0x8f, 0xf9, 0x5d, 0x44, 0x49, 0xa3,
178
+  0xa5, 0x5a, 0xc9, 0x55, 0x42, 0x4f, 0x77, 0x0b, 0xc3, 0x6d, 0x19, 0x5d,
179
+  0x6a, 0x22, 0xa1, 0x66, 0xd9, 0x2d, 0x5d, 0x3f, 0xda, 0xa0, 0xcd, 0xd0,
180
+  0xcf, 0xb8, 0x92, 0xb7, 0x43, 0x75, 0xda, 0x5a, 0x13, 0x59, 0x42, 0x44,
181
+  0xdc, 0xb6, 0x4e, 0xaf, 0x28, 0xeb, 0x5b, 0x05, 0xea, 0x11, 0xda, 0x7a,
182
+  0xc0, 0x48, 0x2b, 0xbd, 0x6a, 0xf0, 0x10, 0xb4, 0xf2, 0x66, 0xa8, 0xe0,
183
+  0x2b, 0x57, 0x6b, 0x25, 0x3e, 0x28, 0xd2, 0x24, 0x66, 0xdd, 0xcf, 0x72,
184
+  0xbc, 0x90, 0x4a, 0x16, 0x48, 0xbb, 0x16, 0x85, 0x4b, 0x76, 0x37, 0x64,
185
+  0x53, 0x74, 0x33, 0xea, 0xe1, 0x5b, 0xa8, 0x29, 0x19, 0x03, 0xc6, 0x62,
186
+  0xec, 0x3d, 0xe5, 0x9c, 0xc3, 0x62, 0x4b, 0xca, 0x5b, 0xdf, 0x34, 0x51,
187
+  0xa6, 0xd6, 0x88, 0x51, 0x69, 0x6c, 0xf8, 0x38, 0xe7, 0xd3, 0x94, 0x6b,
188
+  0xf3, 0x92, 0xe7, 0xcf, 0xea, 0x9d, 0x60, 0x7d, 0x14, 0x58, 0x3f, 0x0d,
189
+  0xe9, 0x69, 0xd2, 0x31, 0x66, 0xec, 0xec, 0xa4, 0x9c, 0x48, 0xc1, 0x07,
190
+  0x62, 0x2c, 0xba, 0x7e, 0xea, 0xb9, 0x09, 0x81, 0x1f, 0xe5, 0x5d, 0xfa,
191
+  0xa8, 0x49, 0x29, 0x43, 0xbe, 0xab, 0xbe, 0xe3, 0x24, 0xe8, 0x13, 0x0d,
192
+  0x13, 0x84, 0x06, 0xaf, 0x08, 0x5a, 0x92, 0x71, 0xe4, 0xca, 0x5b, 0x3f,
193
+  0x79, 0x6c, 0x87, 0x4c, 0x2b, 0xe4, 0x43, 0xb8, 0x2c, 0x3f, 0xb9, 0x39,
194
+  0x64, 0x6f, 0xa6, 0x64, 0x41, 0x06, 0x92, 0x8e, 0x4b, 0xc4, 0xfb, 0xc7,
195
+  0x2b, 0x0f, 0xcc, 0xd1, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01,
196
+  0x01, 0x00, 0xdd, 0xf9, 0x43, 0xc6, 0xcd, 0xca, 0xcc, 0x40, 0xb4, 0x3f,
197
+  0x24, 0x08, 0xd4, 0xb1, 0x67, 0x69, 0xd0, 0x40, 0x36, 0x79, 0x2a, 0x5c,
198
+  0x6b, 0x3f, 0x63, 0x31, 0x04, 0x1b, 0x23, 0xfe, 0xd1, 0xa1, 0x3e, 0x18,
199
+  0x42, 0xea, 0xcc, 0x77, 0x2a, 0xdc, 0xad, 0x19, 0xf2, 0x8c, 0xe5, 0x15,
200
+  0x26, 0x41, 0x38, 0x1d, 0x6e, 0xc5, 0x7b, 0x09, 0xd7, 0x70, 0xc5, 0x27,
201
+  0x2e, 0x88, 0xf7, 0xb3, 0x33, 0x98, 0xcf, 0xf4, 0xa3, 0xe5, 0x2a, 0x1e,
202
+  0x77, 0x8f, 0xc3, 0x00, 0xe0, 0x32, 0x23, 0x6c, 0xaf, 0x25, 0x50, 0xb9,
203
+  0x1a, 0x38, 0x14, 0xc0, 0xb2, 0xce, 0xa5, 0x17, 0x20, 0x4b, 0xb0, 0x7d,
204
+  0xef, 0xe7, 0x4e, 0xb3, 0xf4, 0x37, 0x44, 0xe9, 0x57, 0x60, 0x5f, 0x25,
205
+  0xb1, 0x37, 0xe1, 0xd9, 0xce, 0x97, 0xa7, 0x2f, 0x8b, 0x79, 0xc9, 0x6f,
206
+  0x32, 0x2d, 0xa9, 0x87, 0x63, 0x80, 0x99, 0x7d, 0x64, 0x52, 0xb1, 0x16,
207
+  0x5a, 0x00, 0x1c, 0x4f, 0x8c, 0xf0, 0x54, 0x46, 0x84, 0x7d, 0x46, 0xa5,
208
+  0x48, 0xc3, 0xeb, 0x99, 0x2d, 0x7b, 0x5f, 0xcc, 0x00, 0x43, 0x06, 0x97,
209
+  0x68, 0x14, 0xdf, 0xaa, 0x9a, 0xc2, 0xb1, 0xfb, 0x32, 0xc1, 0x1a, 0x20,
210
+  0x27, 0xa7, 0xe1, 0x36, 0xfd, 0xd8, 0x2c, 0xf1, 0xe2, 0xf8, 0x30, 0x8d,
211
+  0x7f, 0x16, 0xb5, 0x10, 0xc5, 0x60, 0x8b, 0xae, 0x94, 0x6f, 0x9e, 0xbe,
212
+  0x09, 0x54, 0x99, 0x16, 0xa2, 0x38, 0x3d, 0xef, 0xab, 0x32, 0x19, 0xa1,
213
+  0x96, 0xda, 0xcb, 0x2c, 0xc4, 0x20, 0x0f, 0xff, 0xc6, 0xfa, 0x4d, 0xfd,
214
+  0x91, 0x4e, 0x1f, 0xd1, 0x76, 0x79, 0x7a, 0x3e, 0x2e, 0x0e, 0x8d, 0x2e,
215
+  0xce, 0xe1, 0x47, 0x7b, 0x41, 0xba, 0x0f, 0x91, 0x09, 0x67, 0x0d, 0xb2,
216
+  0x87, 0xbc, 0xd9, 0x44, 0xa2, 0xa5, 0x83, 0xb6, 0x50, 0x45, 0x85, 0x8d,
217
+  0x01, 0xc0, 0xfc, 0x74, 0x48, 0x3d, 0x02, 0x81, 0x81, 0x00, 0xf4, 0x32,
218
+  0x6b, 0xd6, 0x5d, 0x17, 0xe2, 0x96, 0x1d, 0x04, 0xfe, 0x39, 0xc4, 0xee,
219
+  0x49, 0xbf, 0x01, 0xc2, 0x01, 0x80, 0x92, 0x84, 0x7e, 0x3a, 0x56, 0xa0,
220
+  0xfc, 0xf4, 0xa7, 0x4d, 0xbd, 0x42, 0x35, 0x06, 0xa2, 0x7b, 0xfc, 0x29,
221
+  0x4c, 0xf2, 0xe6, 0x24, 0x34, 0xd0, 0x7f, 0x1d, 0xad, 0x0a, 0x45, 0xc2,
222
+  0x1d, 0x33, 0x53, 0xee, 0x2f, 0x4e, 0x24, 0xaa, 0x1a, 0xe0, 0x7b, 0xbb,
223
+  0x53, 0x7e, 0x1f, 0xbd, 0xf0, 0xfc, 0xb0, 0x76, 0x95, 0x83, 0x03, 0x94,
224
+  0x44, 0xc0, 0x76, 0x96, 0x85, 0xa1, 0xc5, 0x40, 0xbe, 0x23, 0xf4, 0x3c,
225
+  0xac, 0xe0, 0xb6, 0x95, 0x3e, 0x56, 0xe4, 0x5c, 0x92, 0x09, 0xda, 0xd4,
226
+  0x1d, 0x7c, 0x25, 0x42, 0xa4, 0xfa, 0xff, 0x95, 0x3f, 0x63, 0x18, 0x3b,
227
+  0xab, 0x5c, 0x01, 0xdd, 0x27, 0x1b, 0xc5, 0x5a, 0x8e, 0x0e, 0xbb, 0x1a,
228
+  0x4e, 0x87, 0x7b, 0xc6, 0x15, 0x43, 0x02, 0x81, 0x81, 0x00, 0xf3, 0x5c,
229
+  0x1d, 0x00, 0x46, 0x24, 0xc9, 0xc2, 0x89, 0x50, 0x53, 0x20, 0xaf, 0x13,
230
+  0xb0, 0x11, 0x0c, 0x29, 0x36, 0x73, 0x6f, 0x55, 0x80, 0xfe, 0xe8, 0x18,
231
+  0x1c, 0xa7, 0x62, 0x6f, 0xb6, 0x8f, 0x28, 0xa4, 0xaf, 0xc7, 0xb9, 0xe2,
232
+  0x1d, 0x72, 0x03, 0xaf, 0x99, 0x44, 0xe9, 0x82, 0xdc, 0xf9, 0x19, 0x11,
233
+  0x26, 0xe5, 0xe9, 0x46, 0x35, 0xb1, 0x2f, 0x01, 0xeb, 0x4f, 0x30, 0xdd,
234
+  0x97, 0xe1, 0x2b, 0x37, 0x5e, 0x1c, 0xc1, 0xec, 0xf4, 0xb0, 0xa8, 0x7a,
235
+  0x31, 0x48, 0x66, 0xe5, 0x44, 0xbc, 0xa5, 0x32, 0x4a, 0x2f, 0x1f, 0x1e,
236
+  0xda, 0xca, 0x9d, 0x57, 0x02, 0x1c, 0x9a, 0x05, 0x15, 0x7a, 0x76, 0x2f,
237
+  0xc2, 0x4d, 0x9f, 0xad, 0xa4, 0xbd, 0xc6, 0x1b, 0x8c, 0x8f, 0xb6, 0x04,
238
+  0x01, 0xe7, 0xfc, 0x5e, 0xa0, 0x09, 0x67, 0x61, 0xcc, 0xc1, 0x00, 0x2e,
239
+  0xea, 0xf9, 0x73, 0xfd, 0xea, 0x5b, 0x02, 0x81, 0x80, 0x05, 0x8d, 0x47,
240
+  0xea, 0x5d, 0xbf, 0x77, 0x45, 0x56, 0x6f, 0x90, 0xa0, 0x1b, 0x9c, 0x17,
241
+  0x4d, 0x22, 0x6b, 0x18, 0xc1, 0xa5, 0x93, 0x21, 0x93, 0x8d, 0xf8, 0xa7,
242
+  0x07, 0xa0, 0xee, 0x21, 0x89, 0x69, 0xcf, 0x36, 0xce, 0x7e, 0xd3, 0x29,
243
+  0x8e, 0xb4, 0x30, 0xca, 0x8a, 0x9a, 0xf9, 0x3f, 0xbf, 0xe6, 0x0a, 0x1d,
244
+  0xc3, 0xd6, 0xfa, 0xa9, 0x54, 0xab, 0x7c, 0xba, 0x93, 0xb3, 0xfc, 0x74,
245
+  0x4f, 0x7f, 0xc5, 0x3f, 0xbf, 0x5e, 0xfb, 0xb3, 0x36, 0x81, 0x54, 0x53,
246
+  0xa3, 0xd4, 0x8e, 0x63, 0x87, 0x64, 0x06, 0xae, 0xcb, 0xfe, 0x77, 0x8a,
247
+  0xae, 0xa9, 0x38, 0x07, 0x6c, 0xce, 0x50, 0x54, 0x79, 0xa8, 0xe1, 0xfd,
248
+  0xb1, 0x9e, 0xdf, 0x3f, 0x04, 0xfd, 0xde, 0x94, 0xcc, 0x59, 0xf6, 0xb1,
249
+  0x54, 0xac, 0x2e, 0x2c, 0xff, 0x72, 0xa3, 0x36, 0x6b, 0x9b, 0x51, 0x63,
250
+  0xcb, 0xac, 0xc2, 0xba, 0x25, 0x02, 0x81, 0x80, 0x09, 0xce, 0x8f, 0x78,
251
+  0xa0, 0x5b, 0x01, 0x2a, 0x6e, 0xc0, 0x26, 0xe9, 0x6d, 0x44, 0xbc, 0xd6,
252
+  0xa3, 0x07, 0xd2, 0x22, 0xea, 0xbc, 0xa6, 0x5b, 0x1f, 0x5d, 0x41, 0x62,
253
+  0x59, 0x6c, 0x29, 0x0e, 0x31, 0xd4, 0x19, 0x25, 0x52, 0x4f, 0x53, 0x62,
254
+  0x71, 0xd5, 0x94, 0xb6, 0x9b, 0x36, 0x63, 0xd3, 0x41, 0xf8, 0x57, 0xf9,
255
+  0xf1, 0xe1, 0x9b, 0x6e, 0x4d, 0x77, 0xa5, 0x54, 0xe6, 0xa2, 0x37, 0x69,
256
+  0xa2, 0x85, 0x33, 0xac, 0xb2, 0xff, 0xea, 0x88, 0x67, 0xf1, 0xac, 0xa4,
257
+  0xbf, 0x48, 0xc3, 0xf1, 0x5a, 0x32, 0xe1, 0x9c, 0x6e, 0x83, 0x9e, 0xcb,
258
+  0x85, 0x75, 0xa9, 0x27, 0x1f, 0xe9, 0xce, 0x88, 0xc5, 0xd4, 0x7c, 0xdf,
259
+  0x05, 0xed, 0x48, 0x73, 0x41, 0x55, 0x80, 0xdf, 0x95, 0xb5, 0x29, 0xa2,
260
+  0x80, 0xa0, 0x0b, 0x90, 0xf5, 0x72, 0x92, 0x7e, 0xc0, 0x94, 0x23, 0x71,
261
+  0xf4, 0x03, 0xaa, 0x7b, 0x02, 0x81, 0x81, 0x00, 0xd9, 0x31, 0xb1, 0xbd,
262
+  0x33, 0x0c, 0x83, 0x16, 0x2a, 0x2d, 0xbe, 0xde, 0x26, 0x15, 0x94, 0xe0,
263
+  0x5d, 0x1e, 0x3d, 0x3b, 0xb7, 0x6f, 0x1b, 0x89, 0x14, 0x3d, 0x75, 0x19,
264
+  0x25, 0x08, 0xd4, 0xfa, 0x6b, 0x12, 0x37, 0x49, 0xca, 0x4a, 0x21, 0xd8,
265
+  0x83, 0x86, 0xf6, 0x29, 0x64, 0x48, 0xd5, 0xce, 0x5e, 0x5f, 0xf4, 0x2f,
266
+  0x07, 0x5a, 0x26, 0xc7, 0x8c, 0x1a, 0x8c, 0x6e, 0xcd, 0x30, 0x4a, 0x9a,
267
+  0xd5, 0xb6, 0x4d, 0x06, 0x1d, 0xc1, 0xbe, 0xb4, 0x63, 0xf8, 0x95, 0xbf,
268
+  0xb9, 0xc4, 0xd2, 0x69, 0xc1, 0x80, 0x48, 0xb8, 0x26, 0xa5, 0x1f, 0x5d,
269
+  0x3b, 0x85, 0xd5, 0xda, 0xd3, 0x01, 0x80, 0xbb, 0xa3, 0xce, 0xa4, 0x20,
270
+  0xaf, 0x41, 0x04, 0xf2, 0x6c, 0xfc, 0x8a, 0xc2, 0x02, 0x3e, 0x9a, 0xc3,
271
+  0xdd, 0xf6, 0x86, 0x95, 0xbf, 0xa5, 0xdf, 0x2e, 0xc1, 0xe8, 0xec, 0x2f,
272
+  0xd3, 0xef, 0x70, 0x7b
273
+};
274
+unsigned int private_client_bin_key_len = 1192;
275
+
276
+#endif

+ 361
- 0
src/main.cpp View File

@@ -0,0 +1,361 @@
1
+#include <Arduino.h>
2
+#include <time.h>
3
+#include <ESP8266WiFi.h>
4
+#include <WiFiClientSecure.h>
5
+#include <SPI.h>
6
+#include <MFRC522.h>
7
+#include "certs.h"
8
+
9
+#define RST_PIN         0          // Configurable, see typical pin layout above
10
+#define SS_PIN          2         // Configurable, see typical pin layout above
11
+#define IRQ_PIN			4
12
+
13
+#define DOOR_PIN		5
14
+
15
+#define MAX_TRY_REQUEST 3
16
+#define TIMEOUT_DELAY	5000
17
+#define TIMEOUT_WIFI	5000
18
+
19
+MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create mfrc522 instance
20
+MFRC522::MIFARE_Key key;
21
+
22
+unsigned long start_timer=0;
23
+
24
+enum state{WAITING_CARD, CARD_AVAILABLE, CARD_READ, REQUEST_SENT, REQUEST_TIMEOUT, REQUEST_ACCEPTED, REQUEST_REJECTED} current_state, last_state;
25
+volatile bool card_available = false;
26
+volatile bool response_available = false;
27
+
28
+const char* ssid = "Honor9";
29
+const char* password = "test123456";
30
+
31
+const char* host = "192.168.43.203";
32
+const int httpsPort = 443;
33
+
34
+WiFiClientSecure client;
35
+
36
+/*
37
+ * The function to clear the pending interrupt bits after interrupt serving routine
38
+ */
39
+void clearInt() {
40
+  mfrc522.PCD_WriteRegister(mfrc522.ComIrqReg, 0x7F);
41
+}
42
+
43
+/*
44
+ * The function sending to the MFRC522 the needed commands to activate the reception
45
+ */
46
+void activateRec() {
47
+  mfrc522.PCD_WriteRegister(mfrc522.FIFODataReg, mfrc522.PICC_CMD_REQA);
48
+  mfrc522.PCD_WriteRegister(mfrc522.CommandReg, mfrc522.PCD_Transceive);
49
+  mfrc522.PCD_WriteRegister(mfrc522.BitFramingReg, 0x87);
50
+}
51
+
52
+void resetStateMachine(){
53
+	clearInt();
54
+    mfrc522.PICC_HaltA();
55
+    card_available = false;
56
+    current_state=WAITING_CARD;
57
+    Serial.println("\n---- RESET ST_MACHINE ----");
58
+}
59
+
60
+
61
+void IRQ_cardAvailable(){
62
+	card_available=true;
63
+}
64
+
65
+void openDoor(){
66
+	// Open door for X seconds and write result blockchain
67
+	digitalWrite(DOOR_PIN, HIGH);
68
+	delay(2000);
69
+	digitalWrite(DOOR_PIN, LOW);
70
+}
71
+
72
+void printCardUID(){
73
+	Serial.print(F("	Card UID:"));
74
+	for (byte i = 0; i < mfrc522.uid.size; i++) {
75
+		Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
76
+	    Serial.print(mfrc522.uid.uidByte[i], HEX);
77
+	}
78
+	Serial.println(); 
79
+}
80
+
81
+void readCardUID(){
82
+	mfrc522.PICC_ReadCardSerial();
83
+  	if(mfrc522.uid.size > 0){
84
+  		printCardUID();
85
+  		current_state=CARD_READ;
86
+  	}
87
+  	else{
88
+  		Serial.println("	Error : cannot read card UID");
89
+  		resetStateMachine();
90
+  	}
91
+}
92
+
93
+void processResponse(){
94
+	bool request_response=false;
95
+	if(request_response){
96
+		current_state=REQUEST_ACCEPTED;
97
+	}
98
+	else{
99
+		current_state=REQUEST_REJECTED;
100
+	}
101
+}
102
+
103
+bool sendPostRequest(char *data, int data_len){
104
+	char req[1024];
105
+	String req_str;
106
+	req_str =req_str + "POST index.html"                   
107
+        +" HTTP/1.1\r\n" 
108
+        +"Host: "+host+"\r\n" 
109
+        +"Connection: close\r\n"
110
+        +"Accept: */*\r\n" 
111
+        +"User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n" 
112
+        +"Content-Type: application/json\r\n"
113
+        +"Content-Length: "+data_len+"\r\n"
114
+        +"\r\n"
115
+        +data+"\r\n";
116
+    req_str.toCharArray(req,1024);
117
+	if(client.print(req)){
118
+		Serial.println("Request : ");
119
+		Serial.println(req);
120
+	}
121
+	else{
122
+		Serial.println("		Failed to send request to server !");
123
+		return false;
124
+	}
125
+	return true;
126
+}
127
+
128
+void sendRequest(){
129
+	byte nb_try=0;
130
+	bool request_sent=false;
131
+	Serial.println("	Sending request ...");
132
+	while(nb_try < MAX_TRY_REQUEST && !request_sent){
133
+		
134
+		//request_sent=true;
135
+		// SEND request to API (connect wifi here ? , server, +.)
136
+		// if no connection to wifi or server current_state=WAITING_CARD
137
+		request_sent=sendPostRequest("{test:1}",8);
138
+
139
+		if(request_sent){
140
+			// start timer timeout
141
+			current_state=REQUEST_SENT;
142
+			start_timer=millis();
143
+			Serial.println("	Request sent !");
144
+			Serial.println("	Waiting for reponse ...");
145
+		}
146
+		nb_try++;
147
+	}
148
+	if(nb_try == MAX_TRY_REQUEST && !request_sent){
149
+		Serial.println("	Error : number of sending attempts > MAX_TRY_REQUEST");
150
+		resetStateMachine();
151
+	}
152
+
153
+}
154
+
155
+void runStateMachine(){
156
+	last_state=REQUEST_REJECTED;
157
+	Serial.println("\n*********** Start state machine ***********");
158
+	while(1){
159
+		if(last_state != current_state){
160
+			Serial.print("\nCurrent state : ");Serial.println(current_state);
161
+			last_state=current_state;
162
+		}
163
+		switch(current_state){
164
+			case WAITING_CARD:
165
+				if(card_available){
166
+					current_state=CARD_AVAILABLE;
167
+				}
168
+				else{
169
+					//delay(500);
170
+				}
171
+				break;
172
+
173
+			case CARD_AVAILABLE:
174
+				readCardUID();
175
+				break;
176
+
177
+			case CARD_READ:
178
+				//printCardUID();
179
+				sendRequest();
180
+				break;
181
+
182
+			case REQUEST_SENT:
183
+				if(millis() - start_timer > TIMEOUT_DELAY){
184
+					Serial.println("	Error : response timeout");
185
+					resetStateMachine();
186
+				}
187
+				else if(response_available){
188
+					processResponse();
189
+				}
190
+				break;
191
+
192
+			case REQUEST_REJECTED:
193
+				resetStateMachine();
194
+				break;
195
+
196
+			case REQUEST_ACCEPTED:
197
+				openDoor();
198
+				break;
199
+
200
+			default:
201
+				resetStateMachine();
202
+				break;
203
+		}
204
+		if(!card_available) activateRec();
205
+		delay(10);
206
+	}
207
+}
208
+
209
+bool connectToWIfi(){
210
+	Serial.println();
211
+  Serial.print("connecting to ");
212
+  Serial.println(ssid);
213
+  WiFi.mode(WIFI_STA);
214
+  WiFi.begin(ssid, password);
215
+  long start=millis();
216
+  while (WiFi.status() != WL_CONNECTED) {
217
+  	if(millis()-start > TIMEOUT_WIFI) return false;
218
+    delay(500);
219
+    Serial.print(".");
220
+  }
221
+  Serial.println("");
222
+  Serial.println("WiFi connected");
223
+  Serial.println("IP address: ");
224
+  Serial.println(WiFi.localIP());
225
+  return true;
226
+}
227
+
228
+bool addSSL(){
229
+  Serial.print("Setting time using SNTP");
230
+  configTime(8 * 3600, 0, "pool.ntp.org", "time.nist.gov");
231
+  time_t now = time(nullptr);
232
+  while (now < 8 * 3600 * 2) {
233
+    delay(500);
234
+    Serial.print(".");
235
+    now = time(nullptr);
236
+  }
237
+  Serial.println("");
238
+  struct tm timeinfo;
239
+  gmtime_r(&now, &timeinfo);
240
+  Serial.print("Current time: ");
241
+  Serial.print(asctime(&timeinfo));
242
+
243
+
244
+  bool res0 = client.setCertificate(certs_client_bin_crt, certs_client_bin_crt_len);
245
+  if (!res0) {
246
+    Serial.println("Failed to load client certificate!");
247
+    return false;
248
+    // while (true) {
249
+    //   yield();
250
+    // }
251
+  }
252
+  bool res1 = client.setPrivateKey(private_client_bin_key, private_client_bin_key_len);
253
+  if (!res1) {
254
+    Serial.println("Failed to load client private key!");
255
+    return false;
256
+    // while (true) {
257
+    //   yield();
258
+    // }
259
+  }
260
+  bool res = client.setCACert_P(caCert, caCertLen);
261
+  if (!res) {
262
+    Serial.println("Failed to load root CA certificate!");
263
+    return false;
264
+    // while (true) {
265
+    //   yield();
266
+    // }
267
+  }
268
+  return true;
269
+}
270
+
271
+bool connectToServer(){
272
+  // Connect to remote server
273
+  Serial.print("connecting to ");
274
+  Serial.println(host);
275
+  if (!client.connect(host, httpsPort)) {
276
+    Serial.println("connection failed");
277
+    return false;
278
+  }
279
+
280
+  // Verify validity of server's certificate
281
+
282
+  if (client.verifyCertChain(host)) {
283
+  //if (client.verify(fingerprint, host)){
284
+    Serial.println("Server certificate verified");
285
+  } else {
286
+    Serial.println("ERROR: certificate verification failed!");
287
+    return false;
288
+  }
289
+  return true;
290
+}
291
+
292
+
293
+void setup(){
294
+
295
+	Serial.begin(9600);		// Initialize serial communications with the PC
296
+	while (!Serial);		// Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
297
+
298
+	pinMode(DOOR_PIN, OUTPUT);
299
+	/* setup the IRQ pin*/
300
+	pinMode(IRQ_PIN, INPUT_PULLUP);
301
+
302
+	SPI.begin();			// Init SPI bus
303
+	mfrc522.PCD_Init();		// Init MFRC522
304
+	 /* read and printout the MFRC522 version (valid values 0x91 & 0x92)*/
305
+	Serial.print(F("Ver: 0x"));
306
+	byte readReg = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
307
+	Serial.println(readReg, HEX);
308
+	mfrc522.PCD_WriteRegister(mfrc522.ComIEnReg, 0xA0); // Enable interrupt
309
+
310
+	/*Activate the interrupt*/
311
+	attachInterrupt(digitalPinToInterrupt(IRQ_PIN), IRQ_cardAvailable, FALLING);
312
+
313
+	mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
314
+	Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks+."));
315
+
316
+// proceed with connecting of client to the host
317
+	bool wifi_connected = false;
318
+	while(!wifi_connected){
319
+		wifi_connected=connectToWIfi();
320
+		if(!wifi_connected) delay(60000);
321
+	}
322
+
323
+	// Add SSL layer
324
+	bool ssl_added=false;
325
+	while(!ssl_added){
326
+		ssl_added=addSSL();
327
+		if(!ssl_added) delay(500);
328
+	}
329
+
330
+	Serial.println("Connected to WiFi and SSL ready");
331
+
332
+	// Connect to server
333
+	bool server_connected=false;
334
+	while(!server_connected){
335
+		server_connected=connectToServer();
336
+		if(!server_connected) delay(500);
337
+	}
338
+
339
+	Serial.println("Connected to server");
340
+
341
+
342
+	resetStateMachine();
343
+	activateRec();
344
+}
345
+
346
+
347
+void loop(){
348
+	// if (card_available) { //new read interrupt
349
+	//     mfrc522.PICC_ReadCardSerial(); //read the tag data
350
+	//     // Show some details of the PICC (that is: the tag/card)
351
+	//     printCardUID();
352
+	//     resetStateMachine();
353
+	//     openDoor();
354
+ //  	}
355
+
356
+ //  // The receiving block needs regular retriggering (tell the tag it should transmit??)
357
+ //  // (mfrc522.PCD_WriteRegister(mfrc522.FIFODataReg,mfrc522.PICC_CMD_REQA);)
358
+ //  	activateRec();
359
+ //    delay(100);
360
+	runStateMachine();
361
+}

Loading…
Cancel
Save