- Add full message catalogs and content for French (fr) and German (de) - Implement ASCII canonical slugs for French and German routes - Add language-specific search endpoints (/api/busca/fr, /api/busca/de) - Configure strict 404 responses for /fr/livro and /de/livro - Localize SEO, OpenGraph (fr_FR, de_DE), Twitter and JSON-LD schemas - Add localized code example comments across 14 examples for fr and de - Enable 'fr' and 'de' in ENABLED_LOCALES with root negotiation and redirect - Extend test suite in check-i18n, smoke-imagem and verifica-vazamentos Co-Authored-By: Antigravity <noreply@google.com>
77 lines
2.3 KiB
C
77 lines
2.3 KiB
C
/*
|
|
* Exemplo ESP-RainMaker para ESP32
|
|
* Dispositivo: Interruptor Inteligente com controle via App e Nuvem
|
|
*
|
|
* Dependência (idf_component.yml):
|
|
* espressif/esp_rainmaker: "^1.4.0"
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_log.h"
|
|
#include "nvs_flash.h"
|
|
|
|
#include <esp_rmaker_core.h>
|
|
#include <esp_rmaker_standard_params.h>
|
|
#include <esp_rmaker_standard_devices.h>
|
|
#include <app_wifi.h>
|
|
|
|
static const char *TAG = "app_rainmaker";
|
|
static esp_rmaker_device_t *switch_device;
|
|
|
|
/* Callback acionado quando o usuário altera o estado no App móvel */
|
|
static esp_err_t write_cb(const esp_rmaker_device_t *dev, const esp_rmaker_param_val_t val, void *priv_data, esp_rmaker_write_ctx_t *ctx)
|
|
{
|
|
if (ctx) {
|
|
ESP_LOGI(TAG, "Comando recebido via %s", esp_rmaker_device_cb_src_to_str(ctx->src));
|
|
}
|
|
|
|
bool state = val.val.b;
|
|
ESP_LOGI(TAG, "Schalterzustand geändert auf: %s", state ? "EIN" : "AUS");
|
|
|
|
// Aktualisiert den Parameter in Cloud und App
|
|
esp_rmaker_param_update_and_report(priv_data, val);
|
|
return ESP_OK;
|
|
}
|
|
|
|
void app_main(void)
|
|
{
|
|
// Inicialização da memória não-volátil (NVS)
|
|
esp_err_t err = nvs_flash_init();
|
|
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
|
err = nvs_flash_init();
|
|
}
|
|
ESP_ERROR_CHECK(err);
|
|
|
|
// Inicializa o provisionamento Wi-Fi
|
|
app_wifi_init();
|
|
|
|
// Configura o nó RainMaker
|
|
esp_rmaker_config_t rainmaker_cfg = {
|
|
.enable_time_sync = true,
|
|
};
|
|
esp_rmaker_node_t *node = esp_rmaker_node_init(&rainmaker_cfg, "ESP32_SmartSwitch", "Switch");
|
|
|
|
// Cria o dispositivo padrão 'Switch'
|
|
switch_device = esp_rmaker_switch_device_create("Luz Sala", NULL, true);
|
|
|
|
// Registra callback de escrita
|
|
esp_rmaker_device_add_cb(switch_device, write_cb, NULL);
|
|
esp_rmaker_node_add_device(node, switch_device);
|
|
|
|
// Habilita serviços adicionais (OTA e Timezone)
|
|
esp_rmaker_ota_enable_default();
|
|
esp_rmaker_timezone_service_enable();
|
|
|
|
// Inicia o agente RainMaker
|
|
esp_rmaker_start();
|
|
|
|
// Inicia o provisionamento Wi-Fi via BLE (abre no app oficial RainMaker)
|
|
app_wifi_start(POP_TYPE_RANDOM);
|
|
|
|
ESP_LOGI(TAG, "Nó RainMaker pronto! Escaneie o QR Code no app ESP RainMaker.");
|
|
}
|