bool ScanHandler::run() { if(m_addr < 33 ) { if(_rtu) { quint16 state; _rtu->setDeviceAddr(m_addr); int len = _rtu->read_registers(3,1,&state); qDebug() << "addr=" << m_addr << " len=" << len; if(len == 1) { emit scanResult(0,m_addr); if(m_findone) { m_addr = 1; emit scanResult(1,m_addr); return false; } } } emit scanResult(2,m_addr); m_addr++; return true; } m_addr = 1; emit scanResult(1,m_addr); return false; }
bool ScanHandler::stop() { m_addr = 33; // m_stop = true; emit scanResult(1,m_addr); return true; }
String WIFI::get(Topic &topic) { if (topic.itemIs(3, "macAddress")) { return macAddress(); } else if (topic.itemIs(3, "scanResult")){ return scanResult(); } else { return TOPIC_NO; } }
void WIFI::on_scanWifi_complete(){ String result = scanResult(); if (on_wifi_scan_result != nullptr) on_wifi_scan_result(result); }