blynk & neopixelring & w7500

Fork of WIZwiki-7500_Blynk by IOP

Committer:
jcm931213
Date:
Mon Nov 27 11:49:08 2017 +0000
Revision:
18:bc3d69c01bf2
Parent:
14:76d8fd871a4d
NeoPixel Ring Blynk Example final!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vshymanskyy 0:58b20b438383 1 /**
vshymanskyy 0:58b20b438383 2 * @file BlynkProtocolDefs.h
vshymanskyy 0:58b20b438383 3 * @author Volodymyr Shymanskyy
vshymanskyy 0:58b20b438383 4 * @license This project is released under the MIT License (MIT)
vshymanskyy 0:58b20b438383 5 * @copyright Copyright (c) 2015 Volodymyr Shymanskyy
vshymanskyy 0:58b20b438383 6 * @date Jan 2015
vshymanskyy 0:58b20b438383 7 * @brief Blynk protocol definitions
vshymanskyy 0:58b20b438383 8 *
vshymanskyy 0:58b20b438383 9 */
vshymanskyy 0:58b20b438383 10
vshymanskyy 0:58b20b438383 11 #ifndef BlynkProtocolDefs_h
vshymanskyy 0:58b20b438383 12 #define BlynkProtocolDefs_h
vshymanskyy 0:58b20b438383 13
vshymanskyy 0:58b20b438383 14 enum BlynkCmd
vshymanskyy 0:58b20b438383 15 {
vshymanskyy 0:58b20b438383 16 BLYNK_CMD_RESPONSE = 0,
vshymanskyy 0:58b20b438383 17 BLYNK_CMD_REGISTER = 1,
vshymanskyy 0:58b20b438383 18 BLYNK_CMD_LOGIN = 2,
vshymanskyy 0:58b20b438383 19 BLYNK_CMD_SAVE_PROF = 3,
vshymanskyy 0:58b20b438383 20 BLYNK_CMD_LOAD_PROF = 4,
vshymanskyy 0:58b20b438383 21 BLYNK_CMD_GET_TOKEN = 5,
vshymanskyy 0:58b20b438383 22 BLYNK_CMD_PING = 6,
vshymanskyy 0:58b20b438383 23 BLYNK_CMD_ACTIVATE = 7,
vshymanskyy 0:58b20b438383 24 BLYNK_CMD_DEACTIVATE = 8,
vshymanskyy 0:58b20b438383 25 BLYNK_CMD_REFRESH = 9,
vshymanskyy 0:58b20b438383 26 BLYNK_CMD_GET_GRAPH_DATA = 10,
vshymanskyy 0:58b20b438383 27 BLYNK_CMD_GET_GRAPH_DATA_RESPONSE = 11,
vshymanskyy 0:58b20b438383 28
vshymanskyy 0:58b20b438383 29 BLYNK_CMD_TWEET = 12,
vshymanskyy 0:58b20b438383 30 BLYNK_CMD_EMAIL = 13,
vshymanskyy 0:58b20b438383 31 BLYNK_CMD_NOTIFY = 14,
vshymanskyy 0:58b20b438383 32 BLYNK_CMD_BRIDGE = 15,
vshymanskyy 0:58b20b438383 33 BLYNK_CMD_HARDWARE_SYNC = 16,
Volodymyr Shymanskyy 10:c241e4227173 34 BLYNK_CMD_INTERNAL = 17,
Volodymyr Shymanskyy 9:7369ec77a3ea 35 BLYNK_CMD_SMS = 18,
Volodymyr Shymanskyy 9:7369ec77a3ea 36 BLYNK_CMD_PROPERTY = 19,
vshymanskyy 0:58b20b438383 37 BLYNK_CMD_HARDWARE = 20,
vshymanskyy 0:58b20b438383 38
vshymanskyy 0:58b20b438383 39 BLYNK_CMD_CREATE_DASH = 21,
vshymanskyy 0:58b20b438383 40 BLYNK_CMD_SAVE_DASH = 22,
vshymanskyy 0:58b20b438383 41 BLYNK_CMD_DELETE_DASH = 23,
vshymanskyy 0:58b20b438383 42 BLYNK_CMD_LOAD_PROF_GZ = 24,
vshymanskyy 0:58b20b438383 43 BLYNK_CMD_SYNC = 25,
vshymanskyy 0:58b20b438383 44 BLYNK_CMD_SHARING = 26,
vshymanskyy 0:58b20b438383 45 BLYNK_CMD_ADD_PUSH_TOKEN = 27,
vshymanskyy 0:58b20b438383 46
vshymanskyy 0:58b20b438383 47 //sharing commands
vshymanskyy 0:58b20b438383 48 BLYNK_CMD_GET_SHARED_DASH = 29,
vshymanskyy 0:58b20b438383 49 BLYNK_CMD_GET_SHARE_TOKEN = 30,
vshymanskyy 0:58b20b438383 50 BLYNK_CMD_REFRESH_SHARE_TOKEN = 31,
Volodymyr Shymanskyy 9:7369ec77a3ea 51 BLYNK_CMD_SHARE_LOGIN = 32,
Volodymyr Shymanskyy 9:7369ec77a3ea 52
Volodymyr Shymanskyy 9:7369ec77a3ea 53 BLYNK_CMD_REDIRECT = 41,
Volodymyr Shymanskyy 9:7369ec77a3ea 54
Volodymyr Shymanskyy 14:76d8fd871a4d 55 BLYNK_CMD_DEBUG_PRINT = 55,
Volodymyr Shymanskyy 14:76d8fd871a4d 56
Volodymyr Shymanskyy 14:76d8fd871a4d 57 BLYNK_CMD_EVENT_LOG = 60
vshymanskyy 0:58b20b438383 58 };
vshymanskyy 0:58b20b438383 59
vshymanskyy 0:58b20b438383 60 enum BlynkStatus
vshymanskyy 0:58b20b438383 61 {
vshymanskyy 0:58b20b438383 62 BLYNK_SUCCESS = 200,
vshymanskyy 0:58b20b438383 63 BLYNK_QUOTA_LIMIT_EXCEPTION = 1,
vshymanskyy 0:58b20b438383 64 BLYNK_ILLEGAL_COMMAND = 2,
vshymanskyy 0:58b20b438383 65 BLYNK_NOT_REGISTERED = 3,
vshymanskyy 0:58b20b438383 66 BLYNK_ALREADY_REGISTERED = 4,
vshymanskyy 0:58b20b438383 67 BLYNK_NOT_AUTHENTICATED = 5,
vshymanskyy 0:58b20b438383 68 BLYNK_NOT_ALLOWED = 6,
Volodymyr Shymanskyy 9:7369ec77a3ea 69 BLYNK_DEVICE_NOT_IN_NETWORK = 7,
vshymanskyy 0:58b20b438383 70 BLYNK_NO_ACTIVE_DASHBOARD = 8,
vshymanskyy 0:58b20b438383 71 BLYNK_INVALID_TOKEN = 9,
Volodymyr Shymanskyy 9:7369ec77a3ea 72 BLYNK_ILLEGAL_COMMAND_BODY = 11,
vshymanskyy 0:58b20b438383 73 BLYNK_GET_GRAPH_DATA_EXCEPTION = 12,
vshymanskyy 0:58b20b438383 74 BLYNK_NO_DATA_EXCEPTION = 17,
Volodymyr Shymanskyy 9:7369ec77a3ea 75 BLYNK_DEVICE_WENT_OFFLINE = 18,
vshymanskyy 0:58b20b438383 76 BLYNK_SERVER_EXCEPTION = 19,
vshymanskyy 0:58b20b438383 77
vshymanskyy 0:58b20b438383 78 BLYNK_NTF_INVALID_BODY = 13,
vshymanskyy 0:58b20b438383 79 BLYNK_NTF_NOT_AUTHORIZED = 14,
vshymanskyy 0:58b20b438383 80 BLYNK_NTF_ECXEPTION = 15,
vshymanskyy 0:58b20b438383 81
Volodymyr Shymanskyy 9:7369ec77a3ea 82 BLYNK_TIMEOUT = 16,
Volodymyr Shymanskyy 9:7369ec77a3ea 83
Volodymyr Shymanskyy 9:7369ec77a3ea 84 BLYNK_NOT_SUPPORTED_VERSION = 20,
Volodymyr Shymanskyy 9:7369ec77a3ea 85 BLYNK_ENERGY_LIMIT = 21
vshymanskyy 0:58b20b438383 86 };
vshymanskyy 0:58b20b438383 87
vshymanskyy 0:58b20b438383 88 struct BlynkHeader
vshymanskyy 0:58b20b438383 89 {
vshymanskyy 0:58b20b438383 90 uint8_t type;
vshymanskyy 0:58b20b438383 91 uint16_t msg_id;
vshymanskyy 0:58b20b438383 92 uint16_t length;
vshymanskyy 0:58b20b438383 93 }
vshymanskyy 0:58b20b438383 94 BLYNK_ATTR_PACKED;
vshymanskyy 0:58b20b438383 95
Volodymyr Shymanskyy 7:8879692d4e6c 96 #if !defined(ESP32) && (defined(ARDUINO) || defined(ESP8266) || defined(PARTICLE) || defined(MBED_LIBRARY_VERSION))
vshymanskyy 0:58b20b438383 97 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
vshymanskyy 0:58b20b438383 98 #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) )
vshymanskyy 0:58b20b438383 99 #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
vshymanskyy 0:58b20b438383 100 ((x)<< 8 & 0x00FF0000UL) | \
vshymanskyy 0:58b20b438383 101 ((x)>> 8 & 0x0000FF00UL) | \
vshymanskyy 0:58b20b438383 102 ((x)>>24 & 0x000000FFUL) )
vshymanskyy 0:58b20b438383 103 #define ntohs(x) htons(x)
vshymanskyy 0:58b20b438383 104 #define ntohl(x) htonl(x)
vshymanskyy 0:58b20b438383 105 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
vshymanskyy 0:58b20b438383 106 #define htons(x) (x)
vshymanskyy 0:58b20b438383 107 #define htonl(x) (x)
vshymanskyy 0:58b20b438383 108 #define ntohs(x) (x)
vshymanskyy 0:58b20b438383 109 #define ntohl(x) (x)
vshymanskyy 0:58b20b438383 110 #else
vshymanskyy 0:58b20b438383 111 #error byte order problem
vshymanskyy 0:58b20b438383 112 #endif
vshymanskyy 0:58b20b438383 113 #endif
vshymanskyy 0:58b20b438383 114
vshymanskyy 0:58b20b438383 115 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
Volodymyr Shymanskyy 10:c241e4227173 116 #define BLYNK_STR_16(a,b) ((uint16_t(a) << 0) | (uint16_t(b) << 8))
Volodymyr Shymanskyy 10:c241e4227173 117 #define BLYNK_STR_32(a,b,c,d) ((uint32_t(a) << 0) | (uint32_t(b) << 8) | (uint32_t(c) << 16) | (uint32_t(d) << 24))
vshymanskyy 0:58b20b438383 118 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
Volodymyr Shymanskyy 10:c241e4227173 119 #define BLYNK_STR_16(a,b) ((uint16_t(b) << 0) | (uint16_t(a) << 8))
Volodymyr Shymanskyy 10:c241e4227173 120 #define BLYNK_STR_32(a,b,c,d) ((uint32_t(d) << 0) | (uint32_t(c) << 8) | (uint32_t(b) << 16) | (uint32_t(a) << 24))
vshymanskyy 0:58b20b438383 121 #else
vshymanskyy 0:58b20b438383 122 #error byte order problem
vshymanskyy 0:58b20b438383 123 #endif
vshymanskyy 0:58b20b438383 124
Volodymyr Shymanskyy 10:c241e4227173 125 #define BLYNK_HW_PM BLYNK_STR_16('p','m')
Volodymyr Shymanskyy 10:c241e4227173 126 #define BLYNK_HW_DW BLYNK_STR_16('d','w')
Volodymyr Shymanskyy 10:c241e4227173 127 #define BLYNK_HW_DR BLYNK_STR_16('d','r')
Volodymyr Shymanskyy 10:c241e4227173 128 #define BLYNK_HW_AW BLYNK_STR_16('a','w')
Volodymyr Shymanskyy 10:c241e4227173 129 #define BLYNK_HW_AR BLYNK_STR_16('a','r')
Volodymyr Shymanskyy 10:c241e4227173 130 #define BLYNK_HW_VW BLYNK_STR_16('v','w')
Volodymyr Shymanskyy 10:c241e4227173 131 #define BLYNK_HW_VR BLYNK_STR_16('v','r')
Volodymyr Shymanskyy 10:c241e4227173 132
Volodymyr Shymanskyy 10:c241e4227173 133 #define BLYNK_INT_RTC BLYNK_STR_32('r','t','c',0)
Volodymyr Shymanskyy 10:c241e4227173 134 #define BLYNK_INT_OTA BLYNK_STR_32('o','t','a',0)
Volodymyr Shymanskyy 10:c241e4227173 135 #define BLYNK_INT_ACON BLYNK_STR_32('a','c','o','n')
Volodymyr Shymanskyy 10:c241e4227173 136 #define BLYNK_INT_ADIS BLYNK_STR_32('a','d','i','s')
Volodymyr Shymanskyy 10:c241e4227173 137
vshymanskyy 0:58b20b438383 138 #endif