-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlynkDetectDevice.h
executable file
·411 lines (358 loc) · 14 KB
/
BlynkDetectDevice.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
/**
* @file BlynkDetectDevice.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2016 Volodymyr Shymanskyy
* @date May 2016
* @brief
*
*/
#ifndef BlynkDetectDevice_h
#define BlynkDetectDevice_h
// General defines
#define BLYNK_STRINGIFY(x) #x
#define BLYNK_TOSTRING(x) BLYNK_STRINGIFY(x)
#define BLYNK_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#define BLYNK_ATTR_PACKED __attribute__ ((__packed__))
#define BLYNK_NORETURN __attribute__ ((noreturn))
#define BLYNK_UNUSED __attribute__((__unused__))
#define BLYNK_DEPRECATED __attribute__ ((deprecated))
// Causes problems on some platforms
#define BLYNK_FORCE_INLINE inline //__attribute__((always_inline))
#ifndef BLYNK_INFO_CPU
/******************************************
* ATmega
*/
#if defined(__AVR_ATmega168__)
#define BLYNK_INFO_CPU "ATmega168"
#elif defined(__AVR_ATmega328P__)
#define BLYNK_INFO_CPU "ATmega328P"
#elif defined(__AVR_ATmega1280__)
#define BLYNK_INFO_CPU "ATmega1280"
#elif defined(__AVR_ATmega1284__)
#define BLYNK_INFO_CPU "ATmega1284"
#elif defined(__AVR_ATmega2560__)
#define BLYNK_INFO_CPU "ATmega2560"
#elif defined(__AVR_ATmega32U4__)
#define BLYNK_INFO_CPU "ATmega32U4"
#elif defined(__SAM3X8E__)
#define BLYNK_INFO_CPU "AT91SAM3X8E"
/******************************************
* ATtiny
*/
#elif defined(__AVR_ATtiny25__)
#define BLYNK_INFO_CPU "ATtiny25"
#elif defined(__AVR_ATtiny45__)
#define BLYNK_INFO_CPU "ATtiny45"
#elif defined(__AVR_ATtiny85__)
#define BLYNK_INFO_CPU "ATtiny85"
#elif defined(__AVR_ATtiny24__)
#define BLYNK_INFO_CPU "ATtiny24"
#elif defined(__AVR_ATtiny44__)
#define BLYNK_INFO_CPU "ATtiny44"
#elif defined(__AVR_ATtiny84__)
#define BLYNK_INFO_CPU "ATtiny84"
#elif defined(__AVR_ATtiny2313__)
#define BLYNK_INFO_CPU "ATtiny2313"
#elif defined(__AVR_ATtiny4313__)
#define BLYNK_INFO_CPU "ATtiny4313"
#endif
#endif
#ifndef BLYNK_INFO_DEVICE
#if defined(ENERGIA)
#define BLYNK_NO_YIELD
#define BLYNK_USE_128_VPINS
#if defined(ENERGIA_ARCH_MSP430)
#define BLYNK_INFO_DEVICE "LaunchPad MSP430"
#define BLYNK_INFO_CPU "MSP430"
#define BLYNK_NO_FLOAT
#elif defined(ENERGIA_ARCH_MSP432)
#define BLYNK_INFO_DEVICE "LaunchPad MSP432"
#define BLYNK_INFO_CPU "MSP432"
#elif defined(ENERGIA_ARCH_TIVAC)
#define BLYNK_INFO_DEVICE "LaunchPad"
#elif defined(ENERGIA_ARCH_CC3200)
#define BLYNK_INFO_CONNECTION "CC3200"
#define BLYNK_SEND_CHUNK 64
#define BLYNK_BUFFERS_SIZE 1024
#if defined(ENERGIA_CC3200_LAUNCHXL) //TODO: This is a bug in Energia IDE
#define BLYNK_INFO_DEVICE "CC32000 LaunchXL"
#elif defined(ENERGIA_RedBearLab_CC3200)
#define BLYNK_INFO_DEVICE "RBL CC3200"
#elif defined(ENERGIA_RedBearLab_WiFiMini)
#define BLYNK_INFO_DEVICE "RBL WiFi Mini"
#elif defined(ENERGIA_RedBearLab_WiFiMicro)
#define BLYNK_INFO_DEVICE "RBL WiFi Micro"
#endif
#endif
#if !defined(BLYNK_INFO_DEVICE)
#define BLYNK_INFO_DEVICE "Energia"
#endif
#elif defined(LINUX)
#define BLYNK_INFO_DEVICE "Linux"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 4096
#elif defined(SPARK) || defined(PARTICLE)
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#if PLATFORM_ID==0
#define BLYNK_INFO_DEVICE "Particle Core"
#undef BLYNK_BUFFERS_SIZE // Use default on Core
#elif PLATFORM_ID==6
#define BLYNK_INFO_DEVICE "Particle Photon"
#elif PLATFORM_ID==8
#define BLYNK_INFO_DEVICE "Particle P1"
#elif PLATFORM_ID==9
#define BLYNK_INFO_DEVICE "Particle Ethernet"
#elif PLATFORM_ID==10
#define BLYNK_INFO_DEVICE "Particle Electron"
#elif PLATFORM_ID==82
#define BLYNK_INFO_DEVICE "Digistump Oak"
#elif PLATFORM_ID==88
#define BLYNK_INFO_DEVICE "RedBear Duo"
#elif PLATFORM_ID==103
#define BLYNK_INFO_DEVICE "Bluz"
#else
#if defined(BLYNK_DEBUG_ALL)
#warning "Cannot detect board type"
#endif
#define BLYNK_INFO_DEVICE "Particle"
#endif
#elif defined(MBED_LIBRARY_VERSION)
#define BLYNK_INFO_DEVICE "MBED"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 512
#elif defined(ARDUINO) && defined(MPIDE)
#define BLYNK_NO_YIELD
#if defined(_BOARD_UNO_)
#define BLYNK_INFO_DEVICE "chipKIT Uno32"
#else
#define BLYNK_INFO_DEVICE "chipKIT"
#endif
#elif defined(ARDUINO) && defined(TEENSYDUINO)
#if defined(__MK66FX1M0__)
#define BLYNK_INFO_DEVICE "Teensy 3.6"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MK64FX512__)
#define BLYNK_INFO_DEVICE "Teensy 3.5"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MK20DX256__)
#define BLYNK_INFO_DEVICE "Teensy 3.2/3.1"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MK20DX128__)
#define BLYNK_INFO_DEVICE "Teensy 3.0"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MKL26Z64__)
#define BLYNK_INFO_DEVICE "Teensy LC"
#define BLYNK_BUFFERS_SIZE 512
#elif defined(ARDUINO_ARCH_AVR)
#define BLYNK_INFO_DEVICE "Teensy 2.0"
#else
#define BLYNK_INFO_DEVICE "Teensy"
#endif
#elif defined(ARDUINO)
#if defined(ESP8266) || defined(ESP32)
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#endif
/* Arduino AVR */
#if defined(ARDUINO_AVR_NANO)
#define BLYNK_INFO_DEVICE "Arduino Nano"
#elif defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_DUEMILANOVE)
#define BLYNK_INFO_DEVICE "Arduino Uno"
#elif defined(ARDUINO_AVR_YUN)
#define BLYNK_INFO_DEVICE "Arduino Yun"
#elif defined(ARDUINO_AVR_MINI)
#define BLYNK_INFO_DEVICE "Arduino Mini"
#elif defined(ARDUINO_AVR_ETHERNET)
#define BLYNK_INFO_DEVICE "Arduino Ethernet"
#elif defined(ARDUINO_AVR_FIO)
#define BLYNK_INFO_DEVICE "Arduino Fio"
#elif defined(ARDUINO_AVR_BT)
#define BLYNK_INFO_DEVICE "Arduino BT"
#elif defined(ARDUINO_AVR_PRO)
#define BLYNK_INFO_DEVICE "Arduino Pro"
#elif defined(ARDUINO_AVR_NG)
#define BLYNK_INFO_DEVICE "Arduino NG"
#elif defined(ARDUINO_AVR_GEMMA)
#define BLYNK_INFO_DEVICE "Arduino Gemma"
#elif defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560)
#define BLYNK_INFO_DEVICE "Arduino Mega"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(ARDUINO_AVR_ADK)
#define BLYNK_INFO_DEVICE "Arduino Mega ADK"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(ARDUINO_AVR_LEONARDO)
#define BLYNK_INFO_DEVICE "Arduino Leonardo"
#elif defined(ARDUINO_AVR_MICRO)
#define BLYNK_INFO_DEVICE "Arduino Micro"
#elif defined(ARDUINO_AVR_ESPLORA)
#define BLYNK_INFO_DEVICE "Arduino Esplora"
#elif defined(ARDUINO_AVR_LILYPAD)
#define BLYNK_INFO_DEVICE "Lilypad"
#elif defined(ARDUINO_AVR_LILYPAD_USB)
#define BLYNK_INFO_DEVICE "Lilypad USB"
#elif defined(ARDUINO_AVR_ROBOT_MOTOR)
#define BLYNK_INFO_DEVICE "Robot Motor"
#elif defined(ARDUINO_AVR_ROBOT_CONTROL)
#define BLYNK_INFO_DEVICE "Robot Control"
/* Arduino SAM/SAMD */
#elif defined(ARDUINO_SAM_DUE)
#define BLYNK_INFO_DEVICE "Arduino Due"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(ARDUINO_SAMD_ZERO)
#define BLYNK_INFO_DEVICE "Arduino Zero"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(ARDUINO_SAMD_MKR1000)
#define BLYNK_INFO_DEVICE "Arduino MKR1000"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
/* Intel */
#elif defined(ARDUINO_GALILEO)
#define BLYNK_INFO_DEVICE "Galileo"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 4096
#elif defined(ARDUINO_GALILEOGEN2)
#define BLYNK_INFO_DEVICE "Galileo Gen2"
#define BLYNK_BUFFERS_SIZE 4096
#define BLYNK_USE_128_VPINS
#elif defined(ARDUINO_EDISON)
#define BLYNK_INFO_DEVICE "Edison"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 4096
#elif defined(ARDUINO_ARCH_ARC32)
#define BLYNK_INFO_DEVICE "Arduino 101"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
/* Konekt */
#elif defined(ARDUINO_DASH)
#define BLYNK_INFO_DEVICE "Dash"
#elif defined(ARDUINO_DASHPRO)
#define BLYNK_INFO_DEVICE "Dash Pro"
/* Red Bear Lab */
#elif defined(ARDUINO_RedBear_Duo)
#define BLYNK_INFO_DEVICE "RedBear Duo"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(ARDUINO_BLEND)
#define BLYNK_INFO_DEVICE "Blend"
#elif defined(ARDUINO_BLEND_MICRO_8MHZ) || defined(ARDUINO_BLEND_MICRO_16MHZ)
#define BLYNK_INFO_DEVICE "Blend Micro"
#elif defined(ARDUINO_RBL_nRF51822)
#define BLYNK_INFO_DEVICE "BLE Nano"
/* ESP8266 */
#elif defined(ARDUINO_ESP8266_ESP01)
#define BLYNK_INFO_DEVICE "ESP8266"
#elif defined(ARDUINO_ESP8266_ESP12)
#define BLYNK_INFO_DEVICE "ESP-12"
#elif defined(ARDUINO_ESP8266_NODEMCU)
#define BLYNK_INFO_DEVICE "NodeMCU"
#elif defined(ARDUINO_ESP8266_THING)
#define BLYNK_INFO_DEVICE "Esp Thing"
#elif defined(ARDUINO_ESP8266_THING_DEV)
#define BLYNK_INFO_DEVICE "Esp Thing Dev"
/* ESP32 */
#elif defined(ARDUINO_ESP32_DEV)
#define BLYNK_INFO_DEVICE "ESP32"
#elif defined(ARDUINO_ESP320)
#define BLYNK_INFO_DEVICE "SweetPeas ESP320"
#elif defined(ARDUINO_NANO32)
#define BLYNK_INFO_DEVICE "ESP32 Nano32"
#elif defined(ARDUINO_LoLin32)
#define BLYNK_INFO_DEVICE "LoLin32"
#elif defined(ARDUINO_ESPea32)
#define BLYNK_INFO_DEVICE "ESPea32"
#elif defined(ARDUINO_QUANTUM)
#define BLYNK_INFO_DEVICE "Noduino Quantum"
/* STM32 */
#elif defined(ARDUINO_ARCH_STM32F1)
#define BLYNK_INFO_DEVICE "STM32F1"
#define BLYNK_NO_YIELD
#elif defined(ARDUINO_ARCH_STM32F3)
#define BLYNK_INFO_DEVICE "STM32F3"
#define BLYNK_NO_YIELD
#elif defined(ARDUINO_ARCH_STM32F4)
#define BLYNK_INFO_DEVICE "STM32F4"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#define BLYNK_NO_YIELD
/* Digistump */
#elif defined(ARDUINO_ESP8266_OAK)
#define BLYNK_INFO_DEVICE "Oak"
#define BLYNK_USE_128_VPINS
#elif defined(ARDUINO_AVR_DIGISPARK)
#define BLYNK_INFO_DEVICE "Digispark"
#define BLYNK_NO_YIELD
#elif defined(ARDUINO_AVR_DIGISPARKPRO)
#define BLYNK_INFO_DEVICE "Digispark Pro"
#define BLYNK_NO_YIELD
/* Microduino */
#elif defined(ARDUINO_AVR_USB)
#define BLYNK_INFO_DEVICE "CoreUSB"
#elif defined(ARDUINO_AVR_PLUS)
#define BLYNK_INFO_DEVICE "Core+"
#elif defined(ARDUINO_AVR_RF)
#define BLYNK_INFO_DEVICE "CoreRF"
/* Wildfire */
#elif defined(ARDUINO_WILDFIRE_V2)
#define BLYNK_INFO_DEVICE "Wildfire V2"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(ARDUINO_WILDFIRE_V3)
#define BLYNK_INFO_DEVICE "Wildfire V3"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(ARDUINO_WILDFIRE_V4)
#define BLYNK_INFO_DEVICE "Wildfire V4"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
/* Simblee */
#elif defined(__Simblee__)
#define BLYNK_INFO_DEVICE "Simblee"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 512
/* RFduino */
#elif defined(__RFduino__)
#define BLYNK_INFO_DEVICE "RFduino"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 512
/* Nordic NRF5x */
#elif defined(ARDUINO_ARCH_NRF5)
#define BLYNK_INFO_DEVICE "nRF5"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 512
#else
#if defined(BLYNK_DEBUG_ALL)
#warning "Cannot detect board type"
#endif
#define BLYNK_INFO_DEVICE "Arduino"
#endif
#endif
#if !defined(BLYNK_MAX_READBYTES) && defined(BLYNK_BUFFERS_SIZE)
#define BLYNK_MAX_READBYTES BLYNK_BUFFERS_SIZE
#endif
#if !defined(BLYNK_MAX_SENDBYTES) && defined(BLYNK_BUFFERS_SIZE)
#define BLYNK_MAX_SENDBYTES BLYNK_BUFFERS_SIZE
#endif
// Print diagnostics
#if defined(BLYNK_DEBUG_ALL)
#if defined(BLYNK_INFO_DEVICE)
#pragma message ("BLYNK_INFO_DEVICE=" BLYNK_TOSTRING(BLYNK_INFO_DEVICE))
#endif
#if defined(BLYNK_INFO_CPU)
#pragma message ("BLYNK_INFO_CPU=" BLYNK_TOSTRING(BLYNK_INFO_CPU))
#endif
#if defined(BLYNK_BUFFERS_SIZE)
#pragma message ("BLYNK_BUFFERS_SIZE=" BLYNK_TOSTRING(BLYNK_BUFFERS_SIZE))
#endif
#endif
#endif
#endif