Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc. http://www.blynk.cc/

Dependents:   Blynk_RBL_BLE_Nano Blynk_MicroBit Blynk_Serial Blynk_RBL_BLE_Nano

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BlynkProtocolDefs.h Source File

BlynkProtocolDefs.h

Go to the documentation of this file.
00001 /**
00002  * @file       BlynkProtocolDefs.h
00003  * @author     Volodymyr Shymanskyy
00004  * @license    This project is released under the MIT License (MIT)
00005  * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
00006  * @date       Jan 2015
00007  * @brief      Blynk protocol definitions
00008  *
00009  */
00010 
00011 #ifndef BlynkProtocolDefs_h
00012 #define BlynkProtocolDefs_h
00013 
00014 enum BlynkCmd
00015 {
00016     BLYNK_CMD_RESPONSE       = 0,
00017     BLYNK_CMD_REGISTER       = 1,
00018     BLYNK_CMD_LOGIN          = 2,
00019     BLYNK_CMD_SAVE_PROF      = 3,
00020     BLYNK_CMD_LOAD_PROF      = 4,
00021     BLYNK_CMD_GET_TOKEN      = 5,
00022     BLYNK_CMD_PING           = 6,
00023     BLYNK_CMD_ACTIVATE       = 7,
00024     BLYNK_CMD_DEACTIVATE     = 8,
00025     BLYNK_CMD_REFRESH        = 9,
00026     BLYNK_CMD_GET_GRAPH_DATA = 10,
00027     BLYNK_CMD_GET_GRAPH_DATA_RESPONSE = 11,
00028 
00029     BLYNK_CMD_TWEET          = 12,
00030     BLYNK_CMD_EMAIL          = 13,
00031     BLYNK_CMD_NOTIFY         = 14,
00032     BLYNK_CMD_BRIDGE         = 15,
00033     BLYNK_CMD_HARDWARE_SYNC  = 16,
00034     BLYNK_CMD_INTERNAL       = 17,
00035     BLYNK_CMD_SMS            = 18,
00036     BLYNK_CMD_PROPERTY       = 19,
00037     BLYNK_CMD_HARDWARE       = 20,
00038 
00039     BLYNK_CMD_CREATE_DASH    = 21,
00040     BLYNK_CMD_SAVE_DASH      = 22,
00041     BLYNK_CMD_DELETE_DASH    = 23,
00042     BLYNK_CMD_LOAD_PROF_GZ   = 24,
00043     BLYNK_CMD_SYNC           = 25,
00044     BLYNK_CMD_SHARING        = 26,
00045     BLYNK_CMD_ADD_PUSH_TOKEN = 27,
00046 
00047     //sharing commands
00048     BLYNK_CMD_GET_SHARED_DASH = 29,
00049     BLYNK_CMD_GET_SHARE_TOKEN = 30,
00050     BLYNK_CMD_REFRESH_SHARE_TOKEN = 31,
00051     BLYNK_CMD_SHARE_LOGIN     = 32,
00052 
00053     BLYNK_CMD_REDIRECT        = 41,
00054 
00055     BLYNK_CMD_DEBUG_PRINT     = 55,
00056 
00057     BLYNK_CMD_EVENT_LOG       = 64
00058 };
00059 
00060 enum BlynkStatus
00061 {
00062     BLYNK_SUCCESS                = 200,
00063     BLYNK_QUOTA_LIMIT_EXCEPTION  = 1,
00064     BLYNK_ILLEGAL_COMMAND        = 2,
00065     BLYNK_NOT_REGISTERED         = 3,
00066     BLYNK_ALREADY_REGISTERED     = 4,
00067     BLYNK_NOT_AUTHENTICATED      = 5,
00068     BLYNK_NOT_ALLOWED            = 6,
00069     BLYNK_DEVICE_NOT_IN_NETWORK  = 7,
00070     BLYNK_NO_ACTIVE_DASHBOARD    = 8,
00071     BLYNK_INVALID_TOKEN          = 9,
00072     BLYNK_ILLEGAL_COMMAND_BODY   = 11,
00073     BLYNK_GET_GRAPH_DATA_EXCEPTION = 12,
00074     BLYNK_NO_DATA_EXCEPTION      = 17,
00075     BLYNK_DEVICE_WENT_OFFLINE    = 18,
00076     BLYNK_SERVER_EXCEPTION       = 19,
00077 
00078     BLYNK_NTF_INVALID_BODY       = 13,
00079     BLYNK_NTF_NOT_AUTHORIZED     = 14,
00080     BLYNK_NTF_ECXEPTION          = 15,
00081 
00082     BLYNK_TIMEOUT                = 16,
00083 
00084     BLYNK_NOT_SUPPORTED_VERSION  = 20,
00085     BLYNK_ENERGY_LIMIT           = 21
00086 };
00087 
00088 struct BlynkHeader
00089 {
00090     uint8_t  type;
00091     uint16_t msg_id;
00092     uint16_t length;
00093 }
00094 BLYNK_ATTR_PACKED;
00095 
00096 #if !defined(htons) && (defined(ARDUINO) || defined(ESP8266) || defined(PARTICLE) || defined(__MBED__))
00097     #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
00098         #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) )
00099         #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
00100                            ((x)<< 8 & 0x00FF0000UL) | \
00101                            ((x)>> 8 & 0x0000FF00UL) | \
00102                            ((x)>>24 & 0x000000FFUL) )
00103         #define ntohs(x) htons(x)
00104         #define ntohl(x) htonl(x)
00105     #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
00106         #define htons(x) (x)
00107         #define htonl(x) (x)
00108         #define ntohs(x) (x)
00109         #define ntohl(x) (x)
00110     #else
00111         #error byte order problem
00112     #endif
00113 #endif
00114 
00115 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
00116     #define BLYNK_STR_16(a,b)     ((uint16_t(a) << 0) | (uint16_t(b) << 8))
00117     #define BLYNK_STR_32(a,b,c,d) ((uint32_t(a) << 0) | (uint32_t(b) << 8) | (uint32_t(c) << 16) | (uint32_t(d) << 24))
00118 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
00119     #define BLYNK_STR_16(a,b)     ((uint16_t(b) << 0) | (uint16_t(a) << 8))
00120     #define BLYNK_STR_32(a,b,c,d) ((uint32_t(d) << 0) | (uint32_t(c) << 8) | (uint32_t(b) << 16) | (uint32_t(a) << 24))
00121 #else
00122     #error byte order problem
00123 #endif
00124 
00125 #define BLYNK_HW_PM BLYNK_STR_16('p','m')
00126 #define BLYNK_HW_DW BLYNK_STR_16('d','w')
00127 #define BLYNK_HW_DR BLYNK_STR_16('d','r')
00128 #define BLYNK_HW_AW BLYNK_STR_16('a','w')
00129 #define BLYNK_HW_AR BLYNK_STR_16('a','r')
00130 #define BLYNK_HW_VW BLYNK_STR_16('v','w')
00131 #define BLYNK_HW_VR BLYNK_STR_16('v','r')
00132 
00133 #define BLYNK_INT_RTC  BLYNK_STR_32('r','t','c',0)
00134 #define BLYNK_INT_OTA  BLYNK_STR_32('o','t','a',0)
00135 #define BLYNK_INT_ACON BLYNK_STR_32('a','c','o','n')
00136 #define BLYNK_INT_ADIS BLYNK_STR_32('a','d','i','s')
00137 
00138 #endif