blinker-library

repository·master·Indexed 26 days ago

https://github.com/blinker-iot/blinker-library

A 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.

Tokens
1.1K
Snippets
0
Records
9
Agent score
40%

What's inside blinker-library

  1. Overview of blinker-library

    master
    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.
  2. Manage time-slotted data with BlinkerTimeSlotData

    master

    BlinkerTimeSlotData is 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 to BLINKER_INT_DATA)
    • uint32_t (maps to BLINKER_UINT_DATA)
    • float (maps to BLINKER_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 via checkNum).
    • getData(): Returns a String containing the formatted JSON data including the timestamp and keys.
    • flush(): Resets the key_count and time_data.
  3. Use Blinker Widgets for device interaction

    master

    Blinker 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. Supports setState(bool state) to enable/disable auto-updates.
    • BlinkerWidgets_string: Handles string data. Requires a blinker_callback_with_string_arg_t callback.
    • BlinkerWidgets_int32: Handles 32-bit integer data. Requires a blinker_callback_with_int32_arg_t callback.
    • BlinkerWidgets_rgb: Handles RGB color data. Requires a blinker_callback_with_rgb_arg_t callback.
    • BlinkerWidgets_joy: Handles joystick/analog data. Requires a blinker_callback_with_joy_arg_t callback.
    • BlinkerWidgets_table: A complex widget supporting two callbacks: blinker_callback_with_table_arg_t and blinker_callback_t.
  4. Use BlinkerRTData for real-time data availability

    master

    BlinkerRTData is 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(): Returns true if the data is marked as fresh (is_fresh).
    • checkName(const char* name): Checks if the provided name matches the registered name (using strncmp).
  5. Store historical data with BlinkerData

    master

    BlinkerData manages a collection of historical data points (up to BLINKER_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 _limit parameter acts as a throttle; if the time elapsed since latest_time is less than _limit, the data is not saved.
    • getData(): Returns a String formatted as a JSON array of arrays: [[timestamp, value], [timestamp, value], ...].
    • flush(): Clears all stored data points.
  6. Use BlinkerBridge_key for bridge communication

    master

    When using MQTT or specific gateway modes, BlinkerBridge_key allows you to define a key-value pair for communication. You can assign a name to the bridge key using the name(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.