* AM2321的取温度间隔得大于2s,否则,i2c会不工作了 * SimpleTimer有个bug,会导致两次快速的读温度,现在读温度函数里加了保护 * Blynk有个bug,会导致无法把数据传到服务器 * 现在可以正常工作了
Blynk_v0_3_7/Blynk/BlynkSimpleUserDefined.h@1:e34100dd6532, 2016-06-24 (annotated)
- Committer:
- lixianyu
- Date:
- Fri Jun 24 02:06:43 2016 +0000
- Revision:
- 1:e34100dd6532
- Parent:
- 0:740c1eb2df13
?Arduino??????????0~255??????LPC824????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lixianyu | 0:740c1eb2df13 | 1 | /** |
lixianyu | 0:740c1eb2df13 | 2 | * @file BlynkSimpleUserManaged.h |
lixianyu | 0:740c1eb2df13 | 3 | * @author Volodymyr Shymanskyy |
lixianyu | 0:740c1eb2df13 | 4 | * @license This project is released under the MIT License (MIT) |
lixianyu | 0:740c1eb2df13 | 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy |
lixianyu | 0:740c1eb2df13 | 6 | * @date Jun 2015 |
lixianyu | 0:740c1eb2df13 | 7 | * @brief |
lixianyu | 0:740c1eb2df13 | 8 | * |
lixianyu | 0:740c1eb2df13 | 9 | */ |
lixianyu | 0:740c1eb2df13 | 10 | |
lixianyu | 0:740c1eb2df13 | 11 | #ifndef BlynkSimpleUserManaged_h |
lixianyu | 0:740c1eb2df13 | 12 | #define BlynkSimpleUserManaged_h |
lixianyu | 0:740c1eb2df13 | 13 | |
lixianyu | 0:740c1eb2df13 | 14 | #ifndef BLYNK_INFO_CONNECTION |
lixianyu | 0:740c1eb2df13 | 15 | #define BLYNK_INFO_CONNECTION "custom" |
lixianyu | 0:740c1eb2df13 | 16 | #endif |
lixianyu | 0:740c1eb2df13 | 17 | |
lixianyu | 0:740c1eb2df13 | 18 | #include <BlynkApiMbed.h> |
lixianyu | 0:740c1eb2df13 | 19 | #include <Blynk/BlynkProtocol.h> |
lixianyu | 0:740c1eb2df13 | 20 | |
lixianyu | 0:740c1eb2df13 | 21 | extern size_t BlynkStreamRead(void* buf, size_t len); |
lixianyu | 0:740c1eb2df13 | 22 | extern size_t BlynkStreamWrite(const void* buf, size_t len); |
lixianyu | 0:740c1eb2df13 | 23 | |
lixianyu | 0:740c1eb2df13 | 24 | class BlynkTransportUserDefined |
lixianyu | 0:740c1eb2df13 | 25 | { |
lixianyu | 0:740c1eb2df13 | 26 | public: |
lixianyu | 0:740c1eb2df13 | 27 | BlynkTransportUserDefined() |
lixianyu | 0:740c1eb2df13 | 28 | : mConn (false) |
lixianyu | 0:740c1eb2df13 | 29 | {} |
lixianyu | 0:740c1eb2df13 | 30 | |
lixianyu | 0:740c1eb2df13 | 31 | bool connect() { |
lixianyu | 0:740c1eb2df13 | 32 | return mConn = true; |
lixianyu | 0:740c1eb2df13 | 33 | } |
lixianyu | 0:740c1eb2df13 | 34 | |
lixianyu | 0:740c1eb2df13 | 35 | void disconnect() { mConn = false; } |
lixianyu | 0:740c1eb2df13 | 36 | |
lixianyu | 0:740c1eb2df13 | 37 | bool connected() { |
lixianyu | 0:740c1eb2df13 | 38 | return mConn; |
lixianyu | 0:740c1eb2df13 | 39 | } |
lixianyu | 0:740c1eb2df13 | 40 | |
lixianyu | 0:740c1eb2df13 | 41 | size_t read(void* buf, size_t len) { |
lixianyu | 0:740c1eb2df13 | 42 | return BlynkStreamRead(buf, len); |
lixianyu | 0:740c1eb2df13 | 43 | } |
lixianyu | 0:740c1eb2df13 | 44 | |
lixianyu | 0:740c1eb2df13 | 45 | size_t write(const void* buf, size_t len) { |
lixianyu | 0:740c1eb2df13 | 46 | return BlynkStreamWrite(buf, len); |
lixianyu | 0:740c1eb2df13 | 47 | } |
lixianyu | 0:740c1eb2df13 | 48 | |
lixianyu | 0:740c1eb2df13 | 49 | size_t available() { |
lixianyu | 0:740c1eb2df13 | 50 | return 0; |
lixianyu | 0:740c1eb2df13 | 51 | } |
lixianyu | 0:740c1eb2df13 | 52 | |
lixianyu | 0:740c1eb2df13 | 53 | private: |
lixianyu | 0:740c1eb2df13 | 54 | bool mConn; |
lixianyu | 0:740c1eb2df13 | 55 | }; |
lixianyu | 0:740c1eb2df13 | 56 | |
lixianyu | 0:740c1eb2df13 | 57 | class BlynkUserDefined |
lixianyu | 0:740c1eb2df13 | 58 | : public BlynkProtocol<BlynkTransportUserDefined> |
lixianyu | 0:740c1eb2df13 | 59 | { |
lixianyu | 0:740c1eb2df13 | 60 | typedef BlynkProtocol<BlynkTransportUserDefined> Base; |
lixianyu | 0:740c1eb2df13 | 61 | public: |
lixianyu | 0:740c1eb2df13 | 62 | BlynkUserDefined(BlynkTransportUserDefined& transp) |
lixianyu | 0:740c1eb2df13 | 63 | : Base(transp) |
lixianyu | 0:740c1eb2df13 | 64 | {} |
lixianyu | 0:740c1eb2df13 | 65 | |
lixianyu | 0:740c1eb2df13 | 66 | void begin(const char* auth) |
lixianyu | 0:740c1eb2df13 | 67 | { |
lixianyu | 0:740c1eb2df13 | 68 | Base::begin(auth); |
lixianyu | 0:740c1eb2df13 | 69 | } |
lixianyu | 0:740c1eb2df13 | 70 | |
lixianyu | 0:740c1eb2df13 | 71 | private: |
lixianyu | 0:740c1eb2df13 | 72 | }; |
lixianyu | 0:740c1eb2df13 | 73 | |
lixianyu | 0:740c1eb2df13 | 74 | static BlynkTransportUserDefined _blynkTransport; |
lixianyu | 0:740c1eb2df13 | 75 | BlynkUserDefined Blynk(_blynkTransport); |
lixianyu | 0:740c1eb2df13 | 76 | |
lixianyu | 0:740c1eb2df13 | 77 | #include <BlynkWidgets.h> |
lixianyu | 0:740c1eb2df13 | 78 | |
lixianyu | 0:740c1eb2df13 | 79 | #endif |
lixianyu | 0:740c1eb2df13 | 80 |