完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
esp32-c3 mqtt遗嘱实验没成功,问题请教! 问题描述: 目的:为了实现esp32-c3断开mqtt网后(不能发送mqtt public主题)。服务器能发送提示消息给订阅者,告知订阅者esp32-c3断网。 使用的芯片为esp32-c3内置4m的乐鑫芯片模块。esp32-c3-mimi-1 使用的sdk为esp-idf 4.4 修改内容: static void mqtt_app_start(void) { esp_mqtt_client_config_t mqtt_cfg = { .uri = CONFIG_BROKER_URL, }; mqtt_cfg.uri="mqtt://xxx.xxx.xxx.xxx"; mqtt_cfg.port = 1883; mqtt_cfg.username ="myuser1"; mqtt_cfg.password ="123456"; mqtt_cfg.client_id ="abcdef123456789"; mqtt_cfg.lwt_topic ="/test"; static int i=0; mqtt_cfg.lwt_msg ="noconnectnd!!!%s",i++; mqtt_cfg.lwt_msg_len =sizeof(mqtt_cfg.lwt_msg); mqtt_cfg.lwt_qos =0; mqtt_cfg.lwt_retain =1; //#if CONFIG_BROKER_URL_FROM_STDIN // char line[128]; // // if (strcmp(mqtt_cfg.uri, "FROM_STDIN") == 0) { // int count = 0; // printf("Please enter url of mqtt brokern"); // while (count < 128) { // int c = fgetc(stdin); // if (c == 'n') { // line[count] = ' |