mirror of
https://gitee.com/beecue/fastbee.git
synced 2026-02-05 08:35:57 +08:00
添加智能灯固件代码
This commit is contained in:
38
firmware/esp-idf/wumei-smart-firmware/main/include/button.h
Normal file
38
firmware/esp-idf/wumei-smart-firmware/main/include/button.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _BUTTON_H_
|
||||
#define _BUTTON_H_
|
||||
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/timers.h"
|
||||
#include <freertos/semphr.h>
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "unity.h"
|
||||
#include "iot_button.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
bool is_open;
|
||||
|
||||
void button_start(void);
|
||||
void rf_receiver_start(void);
|
||||
void radar_start(void);
|
||||
|
||||
|
||||
#endif
|
||||
134
firmware/esp-idf/wumei-smart-firmware/main/include/common.h
Normal file
134
firmware/esp-idf/wumei-smart-firmware/main/include/common.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/timers.h"
|
||||
#include <freertos/semphr.h>
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "unity.h"
|
||||
#include "iot_button.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include <string.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "esp_spiffs.h"
|
||||
|
||||
#define IO_SENSOR_SCL 1 // IIC-SCL
|
||||
#define IO_SENSOR_SDA 2 // IIC-SDA
|
||||
#define IO_RADAR_OUT 3 // 雷达模块输入
|
||||
#define IO_RADAR_CDS 4 // 雷达模块CDS
|
||||
#define IO_RELAY 5 // 继电器
|
||||
|
||||
|
||||
// 电源灯:红色(接通电源)、 绿色(已经联网)、蓝色闪烁(智能配网,长按配网按钮2s进入)、黄色闪烁(遥控学习,长按配置按钮5s进入)
|
||||
// 接收消息和发送消息时、mqtt连接成功 蓝色灯闪烁一次
|
||||
#define IO_LED_R 11
|
||||
#define IO_LED_G 12
|
||||
#define IO_LED_B 13
|
||||
|
||||
#define IO_SWITCH_BUTTON 15 // 短按开关、连续短按断网/联网、长按3s重启
|
||||
|
||||
#define IO_RF_RECEIVER_D 19 // 433M射频遥控接收
|
||||
#define IO_RF_RECEIVER_C 20
|
||||
#define IO_RF_RECEIVER_B 21
|
||||
#define IO_RF_RECEIVER_A 26
|
||||
#define IO_RF_LEARN_KEY 33 // RF遥控学习
|
||||
|
||||
#define OTA_DIAGNOSTIC 35 // ota升级回滚确认引脚
|
||||
|
||||
// #define BROKEN_URL "mqtt://wumei.live:1883"
|
||||
#define BROKEN_URL "mqtt://wumei.live:1884"
|
||||
#define BROKEN_SSL_URL "mqtts://test.mosquitto.org:8884"
|
||||
#define BROKEN_ADMIN "admin"
|
||||
#define BROKEN_PWD "admin"
|
||||
#define VERSION "1.0"
|
||||
#define CATEGORY 1 //1-wifi通断器,2-智能灯,3-智能门锁,4-智能水阀
|
||||
|
||||
|
||||
char ssid[33]; // wifi的SSID
|
||||
char pwd[65]; // wifi的密码
|
||||
char owner_id[64]; // 用户ID
|
||||
|
||||
char open_broken_url[128]; // 二次开发mqtt服务器地址
|
||||
char open_account[64]; // 二次开发mqtt账号
|
||||
char open_pwd[64]; // 二次开发mqtt密码
|
||||
|
||||
uint8_t relay_status; // 继电器状态 0-关闭,1-打开
|
||||
uint8_t light_status; // 灯的状态 0-关闭 1-打开
|
||||
uint8_t light_mode; // 颜色模式 0-固定颜色 1-七彩渐变 2-七彩动感 3-单色渐变 4-白光 5-暖光
|
||||
|
||||
uint8_t is_radar; // 是否进入雷达感应
|
||||
uint8_t is_alarm; // 是否打开报警
|
||||
uint8_t is_wifi_offline; // 是否离线模式
|
||||
uint8_t is_open_certifi; // 二次开发是否使用证书
|
||||
uint8_t is_host; // 是否托管
|
||||
uint8_t is_rf_control; // 是否使用RF遥控
|
||||
uint8_t rf_one_func; // 第一个遥控按键功能,1-继电器通断,2-开关灯,开关雷达,4-报警开关,5-智能配网
|
||||
uint8_t rf_two_func; // 第二个遥控按键功能
|
||||
uint8_t rf_three_func; // 第三个遥控按键功能
|
||||
uint8_t rf_four_func; // 第四个遥控按键功能
|
||||
|
||||
uint32_t red; // 红色值
|
||||
uint32_t green; // 绿色值
|
||||
uint32_t blue; // 蓝色值
|
||||
uint32_t brightness; // 亮度0-100
|
||||
uint32_t light_interval; // 颜色闪烁间隔
|
||||
uint32_t radar_interval; // 雷达开灯持续时间,单位秒
|
||||
uint32_t fade_time; // 灯渐变时间
|
||||
|
||||
// 全局变量-不需要存储
|
||||
char device_num[13]; // 设备编号,mac地址
|
||||
int8_t rssi; // wifi信号强度(信号极好4格[-55—— 0],信号好3格[-70—— -55],信号一般2格[-85—— -70],信号差1格[-100—— -85])
|
||||
uint8_t wifi_status; // wifi连接状态:0-未联网,1-已联网
|
||||
uint8_t trigger_source; // 触发源:0-无、1-按键、2.手机、3-浏览器、4-射频遥控、5-雷达、6-报警、7-定时
|
||||
uint8_t is_reset; // 是否重启
|
||||
uint8_t is_ap; // 是否打开AP
|
||||
uint8_t is_rf_learn; // 遥控配对
|
||||
uint8_t is_rf_clear; // 遥控清码
|
||||
uint8_t is_smart_config; // 智能配网
|
||||
float device_temp; // 设备温度
|
||||
float air_temperature; // 空气温度
|
||||
float air_humidity; // 空气湿度
|
||||
|
||||
// 设备重启
|
||||
void device_restart(void);
|
||||
// 获取设备编号
|
||||
void get_device_num(void);
|
||||
//设备温度初始化
|
||||
void device_temp_init(void);
|
||||
// 读取证书
|
||||
void read_cert(void);
|
||||
// 打开继电器
|
||||
void open_relay(void);
|
||||
//关闭继电器
|
||||
void close_relay(void);
|
||||
// 获取rssi
|
||||
void get_ap_info(void);
|
||||
// 433接收模块清码
|
||||
void rf_clear_code(void);
|
||||
// 433接收模块对码
|
||||
void rf_learn(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _DEVICE_TEMP_H_
|
||||
#define _DEVICE_TEMP_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/temp_sensor.h"
|
||||
|
||||
//获取设备温度
|
||||
void get_device_temp(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _FLASH_ENCRYPT_H_
|
||||
#define _FLASH_ENCRYPT_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_partition.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_efuse_table.h"
|
||||
|
||||
#define TARGET_CRYPT_CNT_EFUSE ESP_EFUSE_SPI_BOOT_CRYPT_CNT
|
||||
#define TARGET_CRYPT_CNT_WIDTH 3
|
||||
|
||||
void flash_encrypy_start(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _HTTP_SERVER_H_
|
||||
#define _HTTP_SERVER_H_
|
||||
|
||||
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_event.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_system.h>
|
||||
#include <nvs_flash.h>
|
||||
#include <sys/param.h>
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_eth.h"
|
||||
#include <esp_http_server.h>
|
||||
|
||||
void http_server_start(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _HTTPS_OTA_H_
|
||||
#define _HTTPS_OTA_H_
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_http_client.h"
|
||||
#include "esp_https_ota.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _I2C_TEMP_H_
|
||||
#define _I2C_TEMP_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include "esp_log.h"
|
||||
#include "driver/i2c.h"
|
||||
|
||||
//##被称为连接符(concatenator),用来将两个Token连接为一个Token。
|
||||
#define _I2C_NUMBER(num) I2C_NUM_##num
|
||||
#define I2C_NUMBER(num) _I2C_NUMBER(num)
|
||||
|
||||
// #define I2C_MASTER_NUM I2C_NUMBER(0) // I2C主机端口号
|
||||
#define I2C_MASTER_FREQ_HZ 100000 // I2C主机时钟频率
|
||||
#define I2C_MASTER_TX_BUF_DISABLE 0 //I2C主机不需要缓冲区
|
||||
#define I2C_MASTER_RX_BUF_DISABLE 0 //I2C主机不需要缓冲区
|
||||
|
||||
#define WRITE_BIT I2C_MASTER_WRITE // I2C主机写
|
||||
#define READ_BIT I2C_MASTER_READ // I2C主机读
|
||||
#define ACK_CHECK_EN 0x1 // I2C主机将检查从机的ack
|
||||
#define ACK_CHECK_DIS 0x0 // I2C主机将不检查从机的ack
|
||||
#define ACK_VAL 0x0 // I2C ack值
|
||||
#define NACK_VAL 0x1 // I2C nack值
|
||||
|
||||
//SHT30
|
||||
#define SHT30_WRITE_ADDR 0x44 //地址
|
||||
#define CMD_FETCH_DATA_H 0x22 //循环采样,参考sht30 datasheet
|
||||
#define CMD_FETCH_DATA_L 0x36
|
||||
|
||||
void i2c_temp_start(void);
|
||||
//获取空气温湿度
|
||||
void get_temp_humi();
|
||||
|
||||
#endif
|
||||
88
firmware/esp-idf/wumei-smart-firmware/main/include/led.h
Normal file
88
firmware/esp-idf/wumei-smart-firmware/main/include/led.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _LED_H_
|
||||
#define _LED_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "esp_err.h"
|
||||
#include "common.h"
|
||||
|
||||
#define LEDC_LS_TIMER LEDC_TIMER_1
|
||||
#define LEDC_LS_MODE LEDC_LOW_SPEED_MODE
|
||||
#define LEDC_LS_CH0_CHANNEL LEDC_CHANNEL_0
|
||||
#define LEDC_LS_CH1_CHANNEL LEDC_CHANNEL_1
|
||||
#define LEDC_LS_CH2_CHANNEL LEDC_CHANNEL_2
|
||||
|
||||
|
||||
// 颜色枚举
|
||||
typedef enum {
|
||||
RED = 0,
|
||||
YELLOW,
|
||||
GREEN,
|
||||
CYAN,
|
||||
BLUE,
|
||||
PURPLE,
|
||||
WHITE,
|
||||
} led_color;
|
||||
|
||||
// led灯闪烁的参数
|
||||
struct led_blink_parameter
|
||||
{
|
||||
uint32_t red;
|
||||
uint32_t green;
|
||||
uint32_t blue;
|
||||
uint32_t brightness;
|
||||
uint8_t times; //0-无限
|
||||
uint32_t fade_time; //渐变时间
|
||||
uint8_t mode; //0-固定颜色 1-七彩渐变 2-七彩动感 3-单色渐变 4-白光 5-暖光
|
||||
uint32_t interval; //渐变、动感模式闪烁间隔 毫秒
|
||||
} blink_parameter;
|
||||
|
||||
|
||||
void led_start(void);
|
||||
/**
|
||||
* @brief 设置灯闪烁
|
||||
*
|
||||
* @param red 红色0-255
|
||||
* @param green 绿色0-255
|
||||
* @param blue 蓝色0-255
|
||||
* @param brightness 亮度0-100
|
||||
* @param fade_tiime 渐变时间 毫秒
|
||||
* @param times 闪烁次数,0-无限次
|
||||
* @param mode 模式 0-固定颜色 1-七彩渐变 2-七彩动感 3-单色渐变 4-白光 5-暖光
|
||||
* @param interval 渐变、动感模式闪烁间隔 毫秒
|
||||
*/
|
||||
void led_rgb_blink(uint32_t red,uint32_t green,uint32_t blue, uint32_t brightness,uint32_t fade_tiime,uint8_t times,uint8_t mode,uint32_t interval);
|
||||
|
||||
/**
|
||||
* @brief 设置灯颜色
|
||||
*
|
||||
* @param red 红色
|
||||
* @param green 绿色
|
||||
* @param blue 蓝色
|
||||
* @param brightness 亮度
|
||||
* @param fade_time 渐变时间
|
||||
*/
|
||||
void led_rgb(uint32_t red,uint32_t green,uint32_t blue, uint32_t brightness,uint32_t fade_time);
|
||||
|
||||
/**
|
||||
* @brief 设置led灯实时状态
|
||||
*
|
||||
*/
|
||||
void led_status();
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _LWIP_SNTP_H_
|
||||
#define _LWIP_SNTP_H_
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_sntp.h"
|
||||
|
||||
void sntp_start(void);
|
||||
|
||||
|
||||
#endif
|
||||
45
firmware/esp-idf/wumei-smart-firmware/main/include/mqtt.h
Normal file
45
firmware/esp-idf/wumei-smart-firmware/main/include/mqtt.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _MQTT_H_
|
||||
#define _MQTT_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_netif.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "esp_log.h"
|
||||
#include "mqtt_client.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void mqtt_start(void);
|
||||
void mqtt_stop(void);
|
||||
void mqtt_continue(void);
|
||||
// 发布设备状态
|
||||
void publishStatus(void);
|
||||
//发布设备配置
|
||||
void publishSetting(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _MQTT_SSL_H_
|
||||
#define _MQTT_SSL_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_netif.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "esp_log.h"
|
||||
#include "mqtt_client.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _NATIVE_OTA_H_
|
||||
#define _NATIVE_OTA_H_
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_http_client.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "esp_partition.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "errno.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
#define BUFFSIZE 1024
|
||||
#define HASH_LEN 32 /* SHA-256 digest length */
|
||||
#define OTA_URL_SIZE 256
|
||||
|
||||
void native_ota_start(void);
|
||||
|
||||
|
||||
#endif
|
||||
129
firmware/esp-idf/wumei-smart-firmware/main/include/nvs_storage.h
Normal file
129
firmware/esp-idf/wumei-smart-firmware/main/include/nvs_storage.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/****************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
****************************************************************************/
|
||||
#ifndef _NVS_H_
|
||||
#define _NVS_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
|
||||
void read_config_data(); //读取nvs存储的配置信息
|
||||
void write_config_data(); //写入nvs存储的配置信息
|
||||
|
||||
|
||||
//----------------------------char----------------------------//
|
||||
|
||||
//写入wifi的SSID
|
||||
void write_ssid(void);
|
||||
//读取wifi的SSID
|
||||
void read_ssid(void);
|
||||
|
||||
//写入wifi密码
|
||||
void write_pwd(void);
|
||||
//读取wifi密码
|
||||
void read_pwd(void);
|
||||
|
||||
// 写入用户ID
|
||||
void write_owner_id(void);
|
||||
// 读取用户ID
|
||||
void read_owner_id(void);
|
||||
|
||||
// 写入二次开发mqtt地址
|
||||
void write_open_broken_url(void);
|
||||
// 读取二次开发mqtt地址
|
||||
void read_open_broken_url(void);
|
||||
|
||||
// 写入二次开发mqtt账号
|
||||
void write_open_account(void);
|
||||
// 读取二次开发mqtt账号
|
||||
void read_open_account(void);
|
||||
|
||||
// 写入二次开发mqtt密码
|
||||
void write_open_pwd(void);
|
||||
// 读取二次开发mqtt密码
|
||||
void read_open_pwd(void);
|
||||
|
||||
//------------------------uint8-----------------------//
|
||||
|
||||
void write_relay_status(void);
|
||||
void read_relay_status(void);
|
||||
|
||||
void write_light_status(void);
|
||||
void read_light_status(void);
|
||||
|
||||
void write_red(void);
|
||||
void read_red(void);
|
||||
|
||||
void write_green(void);
|
||||
void read_green(void);
|
||||
|
||||
void write_blue(void);
|
||||
void read_blue(void);
|
||||
|
||||
void write_light_mode(void);
|
||||
void read_light_mode(void);
|
||||
|
||||
void write_brightness(void);
|
||||
void read_brightness(void);
|
||||
|
||||
void write_is_smart_config(void);
|
||||
void read_is_smart_config(void);
|
||||
|
||||
void write_is_ap(void);
|
||||
void read_is_ap(void);
|
||||
|
||||
void write_is_radar(void);
|
||||
void read_is_radar(void);
|
||||
|
||||
void write_is_alarm(void);
|
||||
void read_is_alarm(void);
|
||||
|
||||
void write_is_wifi_offline(void);
|
||||
void read_is_wifi_offline(void);
|
||||
|
||||
void write_is_open_certifi(void);
|
||||
void read_is_open_certifi(void);
|
||||
|
||||
void write_is_host(void);
|
||||
void read_is_host(void);
|
||||
|
||||
void write_is_rf_control(void);
|
||||
void read_is_rf_control(void);
|
||||
|
||||
void write_rf_one_func(void);
|
||||
void read_rf_one_func(void);
|
||||
|
||||
void write_rf_two_func(void);
|
||||
void read_rf_two_func(void);
|
||||
|
||||
void write_rf_three_func(void);
|
||||
void read_rf_three_func(void);
|
||||
|
||||
void write_rf_four_func(void);
|
||||
void read_rf_four_func(void);
|
||||
|
||||
//----------------------------uint32-----------------------------//
|
||||
|
||||
void write_light_interval(void);
|
||||
void read_light_interval(void);
|
||||
|
||||
void write_radar_interval(void);
|
||||
void read_radar_interval(void);
|
||||
|
||||
void write_fade_time(void);
|
||||
void read_fade_time(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/**************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
*************************************************************************/
|
||||
#ifndef _SMART_CONFIG_H_
|
||||
#define _SMART_CONFIG_H_
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wpa2.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_smartconfig.h"
|
||||
|
||||
void smart_config_start(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
************************************************************************/
|
||||
#ifndef _STATISTIC_FREE_RTOS_H_
|
||||
#define _STATISTIC_FREE_RTOS_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#define NUM_OF_SPIN_TASKS 6
|
||||
#define SPIN_ITER 500000 //实际使用的CPU周期取决于编译器优化
|
||||
#define SPIN_TASK_PRIO 2
|
||||
#define STATS_TASK_PRIO 3
|
||||
#define STATS_TICKS pdMS_TO_TICKS(1000)
|
||||
#define ARRAY_SIZE_OFFSET 5 //如果print_real_time返回ESP_ERR_INVALID_SIZE则增加此值
|
||||
|
||||
void free_rtos_start(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
/*****************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#ifndef _STATISTIC_PERFMON_H_
|
||||
#define _STATISTIC_PERFMON_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "esp_timer.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "perfmon.h"
|
||||
|
||||
void perfmon_start(void);
|
||||
|
||||
#endif
|
||||
46
firmware/esp-idf/wumei-smart-firmware/main/include/wifi.h
Normal file
46
firmware/esp-idf/wumei-smart-firmware/main/include/wifi.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
*****************************************************************************/
|
||||
#ifndef _WIFI_H_
|
||||
#define _WIFI_H_
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
|
||||
#define LISTEN_INTERVAL 3 //站监听AP信标的间隔。监听间隔的单位是一个信标间隔。例如,如果信标间隔为100 ms,侦听间隔为3,则站侦听信标的间隔为300 ms。
|
||||
#define POWER_SAVE_MODE WIFI_PS_MIN_MODEM
|
||||
#define MAXIMUM_RETRY 5
|
||||
|
||||
#define AP_SSID "wumei"
|
||||
#define AP_PASS "wumei.live"
|
||||
#define AP_CHANNEL 1 //wifi频道1-13的值
|
||||
#define AP_MAX_STA_CONN 4
|
||||
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
void wifi_start(void);
|
||||
void wifi_mqtt_stop(void);
|
||||
void wifi_continue(void);
|
||||
void ap_start(void);
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user