From e70b8bb75a4592f232e97f5cb33c768ac09d7a46 Mon Sep 17 00:00:00 2001 From: toss007 Date: Fri, 14 Jan 2022 16:53:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tosser.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tosser.h diff --git a/tosser.h b/tosser.h new file mode 100644 index 0000000..46e5434 --- /dev/null +++ b/tosser.h @@ -0,0 +1,52 @@ +/******************* + 智能配网 +*******************/ + +#ifndef tosser_h +#define tosser_h + +//导入Arduino核心头文件 +#include +#include +#include +//#include + +class tosserClass { + private: + int Relay_mode; // 断电记忆(1:保持, 2:常开, 3:常关) + bool Relay_state; // GPIO0引脚断电前状态 + struct config_type + { + char stassid[32]; // WIFI名称 + char stapswd[64]; // WIFI密码 + uint8_t magic; // 运行模式 + } config; + uint8_t *p = (uint8_t*)(&config); + int count = 0; // 开关灯次数计数 + uint32_t Time_start; // 开关开始计数时间 + public: + //tosserClass(); // 构造函数,在建立对象的时候执行 + //~tosserClass(); // 析构函数,在函数完成的最后一刻执行 + void Begin(); // 未配网则配置,否则连接网络 + void ReadConfig(); // 读取配置信息 + void GPIO_Init(); // GPIO引脚初始化 + void SmartConfig(); // 智能配网 + void joinWiFi(); // 连接WiFi + void PrintWiFiInfo(); // 检查wifi是否连接 + void WiFiReset(); // 重置WIFI + void Count_Reset(int Inr_sec, int Inr_cnt); // Inr_sec秒内打开Inr_cnt次开关相应的操作 +}; + +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_tosser) +extern tosserClass tosser; +#endif +#ifndef Pin_0 +#define Pin_0 0 +const int pinRelay = 0; //需要控制的引脚 +#endif + +#ifndef LED_BUILTIN +#define LED_BUILTIN 2 +#endif + +#endif -- GitLab