Search
 
SCRIPT & CODE EXAMPLE
 

C

rainmaker simple project

    /* Initialize Wi-Fi. Note that, this should be called before esp_rmaker_init()
     */
    app_wifi_init();

    /* Initialize the ESP RainMaker Agent.
     * Note that this should be called after app_wifi_init() but before app_wifi_start()
     * */
    esp_rmaker_config_t rainmaker_cfg = {
        .enable_time_sync = false,
    };
    esp_rmaker_node_t *node = esp_rmaker_node_init(&rainmaker_cfg, "ESP RainMaker Device", "Switch");
    if (!node) {
        ESP_LOGE(TAG, "Could not initialise node. Aborting!!!");
        vTaskDelay(5000/portTICK_PERIOD_MS);
        abort();
    }

    /* Create a Switch device.
     * You can optionally use the helper API esp_rmaker_switch_device_create() to
     * avoid writing code for adding the name and power parameters.
     */
    switch_device = esp_rmaker_device_create("Switch", ESP_RMAKER_DEVICE_SWITCH, NULL);

    /* Add the write callback for the device. We aren't registering any read callback yet as
     * it is for future use.
     */
    esp_rmaker_device_add_cb(switch_device, write_cb, NULL);

    /* Add the standard name parameter (type: esp.param.name), which allows setting a persistent,
     * user friendly custom name from the phone apps. All devices are recommended to have this
     * parameter.
     */
    esp_rmaker_device_add_param(switch_device, esp_rmaker_name_param_create("name", "Switch"));

    /* Add the standard power parameter (type: esp.param.power), which adds a boolean param
     * with a toggle switch ui-type.
     */
    esp_rmaker_param_t *power_param = esp_rmaker_power_param_create("power", DEFAULT_POWER);
    esp_rmaker_device_add_param(switch_device, power_param);

    /* Assign the power parameter as the primary, so that it can be controlled from the
     * home screen of the phone apps.
     */
    esp_rmaker_device_assign_primary_param(switch_device, power_param);

    /* Add this switch device to the node */
    esp_rmaker_node_add_device(node, switch_device);

    /* Start the ESP RainMaker Agent */
    esp_rmaker_start();

    /* Start the Wi-Fi.
     * If the node is provisioned, it will start connection attempts,
     * else, it will start Wi-Fi provisioning. The function will return
     * after a connection has been successfully established
     */
    app_wifi_start(POP_TYPE_RANDOM);
Comment

PREVIOUS NEXT
Code Example
C :: How to get the number of characters in a string without using strlen function 
C :: FivemStore 
C :: user define 
C :: np mean 2nd dimension 
C :: C static libraries (creating archive from object files) 
C :: gotoxy not working in dev c++ 
C :: passing an array of unspecified number of variables to a function 
C :: not repeated serial number in c 
C :: c %s 
C :: nosql injection 
C :: function for 2d dynamic array 
C :: i2c scanner 
C :: C Variable Byte Sizes 
C :: install zoom on ubuntu 
Dart :: TextStyle underline flutter 
Dart :: flutter sharedpreferences clear 
Dart :: flutter datetime to string 
Dart :: change padding in text field flutter 
Dart :: type check of variable dart 
Dart :: flutter TextButton.icon 
Dart :: date now dart 
Dart :: dart loop through array 
Dart :: flutter espacio entre widgets 
Dart :: text in column flutter overflow ellipsis not working 
Dart :: DartPad localStorage 
Dart :: flutter listtile disable 
Dart :: dart typeof 
Dart :: flutter flat button size 
Dart :: dart uri 
Dart :: dart modulo 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =