#ifndef MODULEWIFI_H #define MODULEWIFI_H #include #include #include #include class WifiBase { public: WifiBase(){} virtual ~WifiBase(){} virtual WifiBase* run(WifiBase* p) = 0; virtual bool state() = 0; void connect(QString name, QString passwd); void disconnect(); bool connectCheck(); int quality(); private: int quality_val; }; //已经断开连接 class WifiDisConnected : public WifiBase { public: WifiDisConnected(){ qDebug("new WifiDisConnected"); } ~WifiDisConnected(){ qDebug("delete WifiDisConnected"); } virtual WifiBase* run(WifiBase* p); virtual bool state(){ return false; } }; //连接中 class WifiConnecting : public WifiBase { public: WifiConnecting(){ qDebug("new WifiConnecting"); } ~WifiConnecting(){ qDebug("delete WifiConnecting"); } virtual WifiBase* run(WifiBase* p); virtual bool state(){ return false; } }; //已经连接 class WifiConnected : public WifiBase { public: WifiConnected(){ qDebug("new WifiConnected"); } ~WifiConnected(){ qDebug("delete WifiConnected"); } virtual WifiBase* run(WifiBase* p); virtual bool state(){ return true; } }; class ModuleWifi : public QObject { Q_OBJECT public: explicit ModuleWifi(QObject *parent = nullptr); ~ModuleWifi(); signals: void sigStateChanged(bool state); public: bool isConnected(); QString getName(){ return name; } QString getPasswd(){ return passwd; } int getquality(); public slots: /** * @brief 连接WIFI账户 * @param name 用户名 * @param passwd 密码 */ void onConnect(QString name, QString passwd); /** * @brief 断开当前WIFI连接 */ void onDisconnect(); private slots: void onTimerTimeOutCheck(); private: WifiBase * pWifi; QString name; QString passwd; bool state; }; #endif // MODULEWIFI_H