blinker-library
repository·master·Indexed 26 days ago
https://github.com/blinker-iot/blinker-libraryA cross-platform IoT solution for embedded hardware including Arduino, ESP8266, and ESP32. It provides an ecosystem of APP, device, and server support via cloud services for smart home automation and data monitoring. The library includes specialized classes for device interaction such as BlinkerWidgets, BlinkerBridge_key for communication, and data management tools like BlinkerTimeSlotData, BlinkerData, and BlinkerRTData.
What's inside blinker-library
- blinker-library is a cross-hardware and cross-platform IoT solution designed for embedded hardware. It provides support for APP, device, and server components, utilizing public cloud services for data transmission and storage. It is suitable for applications such as smart home automation and data monitoring, aiming to simplify the process of building IoT projects.
Encode and decode binary data using Base64
masterThebase64module provides utility methods to encode binary data into Base64 strings and decode Base64 strings back into binary data.Supported Hardware for blinker-library
masterThe blinker library is compatible with the following embedded hardware platforms:
- Arduino
- ESP8266
- ESP32
Access Blinker API Reference
masterFor detailed technical documentation and API references, use the following links:
- English Reference: Blinker Arduino library reference
- Chinese Reference: Blinker Arduino 使用手册
- Official Website (Chinese): diandeng.tech/doc
Manage time-slotted data with BlinkerTimeSlotData
masterBlinkerTimeSlotDatais used to store and format multiple data points (up to 6) associated with timestamps in a JSON-like format.Supported data types via
saveData():int32_t(maps toBLINKER_INT_DATA)uint32_t(maps toBLINKER_UINT_DATA)float(maps toBLINKER_FLOAT_DATA)
Methods:
saveData(char key[], T data, time_t now_time): Saves a new data point. If the key already exists, it is not overwritten (it checks for availability viacheckNum).getData(): Returns aStringcontaining the formatted JSON data including the timestamp and keys.flush(): Resets thekey_countandtime_data.
Use Blinker Widgets for device interaction
masterBlinker provides several widget classes to represent different types of data or controls in the Blinker ecosystem. Each widget is identified by a unique name and can optionally trigger a callback function when interacted with.
Available widget types:
BlinkerWidgets_num: A numeric/boolean control. SupportssetState(bool state)to enable/disable auto-updates.BlinkerWidgets_string: Handles string data. Requires ablinker_callback_with_string_arg_tcallback.BlinkerWidgets_int32: Handles 32-bit integer data. Requires ablinker_callback_with_int32_arg_tcallback.BlinkerWidgets_rgb: Handles RGB color data. Requires ablinker_callback_with_rgb_arg_tcallback.BlinkerWidgets_joy: Handles joystick/analog data. Requires ablinker_callback_with_joy_arg_tcallback.BlinkerWidgets_table: A complex widget supporting two callbacks:blinker_callback_with_table_arg_tandblinker_callback_t.
Use BlinkerRTData for real-time data availability
masterBlinkerRTDatais designed for real-time data updates. It uses a freshness mechanism to signal when new data is available for consumption.Methods:
name(const char* _name): Sets the data name.state(bool fresh_state): Sets the freshness status. Use this to signal that new data has been received.available(): Returnstrueif the data is marked as fresh (is_fresh).checkName(const char* name): Checks if the provided name matches the registered name (usingstrncmp).
Store historical data with BlinkerData
masterBlinkerDatamanages a collection of historical data points (up toBLINKER_MAX_DATA_COUNT). It stores data as a sequence of[timestamp, value]pairs.Methods:
name(const String & name): Sets the identifier for this data series.saveData(const String & _data, time_t now_time, uint32_t _limit): Saves a data string. The_limitparameter acts as a throttle; if the time elapsed sincelatest_timeis less than_limit, the data is not saved.getData(): Returns aStringformatted as a JSON array of arrays:[[timestamp, value], [timestamp, value], ...].flush(): Clears all stored data points.
Use BlinkerBridge_key for bridge communication
masterWhen using MQTT or specific gateway modes,
BlinkerBridge_keyallows you to define a key-value pair for communication. You can assign a name to the bridge key using thename(const String & name)method.Methods:
getKey(): Returns the bridge key string.getName(): Returns the registered name or "false" if not registered.setFunc(blinker_callback_with_string_arg_t _func): Sets the callback for the bridge key.checkName(char * _key): Validates if the provided key matches.