Add some debugging output when pairing.
This commit is contained in:
parent
504a700b80
commit
cd52a6063e
16
server.cpp
16
server.cpp
|
@ -62,7 +62,7 @@ Server::Server(uint16_t port, QByteArray ssid, QByteArray password)
|
||||||
for (auto & x : nc) {
|
for (auto & x : nc) {
|
||||||
if (x.bearerType() == QNetworkConfiguration::BearerWLAN) {
|
if (x.bearerType() == QNetworkConfiguration::BearerWLAN) {
|
||||||
if (x.name() == "WiWo-S20") {
|
if (x.name() == "WiWo-S20") {
|
||||||
qWarning() << "Connecting to WiWo-S20 wireless";
|
qDebug() << "Connecting to WiWo-S20 wireless";
|
||||||
cfg = &x;
|
cfg = &x;
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,9 @@ Server::Server(uint16_t port, QByteArray ssid, QByteArray password)
|
||||||
|
|
||||||
QNetworkSession *session = new QNetworkSession(*cfg, this);
|
QNetworkSession *session = new QNetworkSession(*cfg, this);
|
||||||
session->open();
|
session->open();
|
||||||
qWarning() << "Wait for connected!";
|
qDebug() << "Wait for connected!";
|
||||||
if (session->waitForOpened())
|
if (session->waitForOpened())
|
||||||
qWarning() << "Connected!";
|
qDebug() << "Connected!";
|
||||||
|
|
||||||
QUdpSocket *udpSocketSend = new QUdpSocket();
|
QUdpSocket *udpSocketSend = new QUdpSocket();
|
||||||
udpSocketGet = new QUdpSocket();
|
udpSocketGet = new QUdpSocket();
|
||||||
|
@ -82,20 +82,27 @@ Server::Server(uint16_t port, QByteArray ssid, QByteArray password)
|
||||||
|
|
||||||
QByteArray reply;
|
QByteArray reply;
|
||||||
|
|
||||||
|
qDebug() << "Send: HF-A11ASSISTHREAD";
|
||||||
udpSocketGet->writeDatagram(QByteArray::fromStdString("HF-A11ASSISTHREAD"), QHostAddress::Broadcast, port);
|
udpSocketGet->writeDatagram(QByteArray::fromStdString("HF-A11ASSISTHREAD"), QHostAddress::Broadcast, port);
|
||||||
reply = listen(QByteArray::fromStdString("HF-A11ASSISTHREAD"));
|
reply = listen(QByteArray::fromStdString("HF-A11ASSISTHREAD"));
|
||||||
QList<QByteArray> list = reply.split(',');
|
QList<QByteArray> list = reply.split(',');
|
||||||
QHostAddress ip(QString::fromLatin1(list[0]));
|
QHostAddress ip(QString::fromLatin1(list[0]));
|
||||||
qWarning() << "IP: " << ip.toString();
|
qDebug() << "IP: " << ip.toString();
|
||||||
|
qDebug() << "Send: +ok";
|
||||||
udpSocketGet->writeDatagram(QByteArray::fromStdString("+ok"), ip, port);
|
udpSocketGet->writeDatagram(QByteArray::fromStdString("+ok"), ip, port);
|
||||||
|
qDebug() << "Send: AT+WSSSID=" + QString::fromLatin1(ssid) + "\r";
|
||||||
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+WSSSID=") + ssid + QByteArray::fromStdString("\r"), ip, port);
|
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+WSSSID=") + ssid + QByteArray::fromStdString("\r"), ip, port);
|
||||||
listen();
|
listen();
|
||||||
|
qDebug() << "Send: AT+WSKEY=WPA2PSK,AES," + QString::fromLatin1(password) + "\r";
|
||||||
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+WSKEY=WPA2PSK,AES,") + password + QByteArray::fromStdString("\r"), ip, port); // FIXME: support different security settings
|
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+WSKEY=WPA2PSK,AES,") + password + QByteArray::fromStdString("\r"), ip, port); // FIXME: support different security settings
|
||||||
// OPEN, SHARED, WPAPSK......NONE, WEP, TKIP, AES
|
// OPEN, SHARED, WPAPSK......NONE, WEP, TKIP, AES
|
||||||
listen();
|
listen();
|
||||||
|
qDebug() << "Send: AT+WMODE=STA\\r";
|
||||||
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+WMODE=STA\r"), ip, port);
|
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+WMODE=STA\r"), ip, port);
|
||||||
listen();
|
listen();
|
||||||
|
qDebug() << "Send: AT+Z\\r";
|
||||||
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+Z\r"), ip, port); // reboot
|
udpSocketGet->writeDatagram(QByteArray::fromStdString("AT+Z\r"), ip, port); // reboot
|
||||||
|
listen();
|
||||||
session->close();
|
session->close();
|
||||||
// FIXME: discover the new socket
|
// FIXME: discover the new socket
|
||||||
qWarning() << "Finished";
|
qWarning() << "Finished";
|
||||||
|
@ -122,6 +129,7 @@ QByteArray Server::listen(QByteArray message)
|
||||||
while (udpSocketGet->hasPendingDatagrams()) {
|
while (udpSocketGet->hasPendingDatagrams()) {
|
||||||
reply.resize(udpSocketGet->pendingDatagramSize());
|
reply.resize(udpSocketGet->pendingDatagramSize());
|
||||||
udpSocketGet->readDatagram(reply.data(), reply.size(), &sender, &senderPort);
|
udpSocketGet->readDatagram(reply.data(), reply.size(), &sender, &senderPort);
|
||||||
|
qDebug() << "Reply: " << QString::fromLatin1(reply.data());
|
||||||
if (reply != message) {
|
if (reply != message) {
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ Socket::Socket(QHostAddress IPaddress, QByteArray reply)
|
||||||
|
|
||||||
commandID[QueryAll] = QStringLiteral("qa").toLatin1();
|
commandID[QueryAll] = QStringLiteral("qa").toLatin1();
|
||||||
commandID[Discover] = QStringLiteral("qg").toLatin1(); // qg
|
commandID[Discover] = QStringLiteral("qg").toLatin1(); // qg
|
||||||
commandID[Subscribe] = QStringLiteral("cl").toLatin1(); // Login Command
|
commandID[Subscribe] = QStringLiteral("cl").toLatin1(); // Claim
|
||||||
commandID[PowerOn] = QStringLiteral("sf").toLatin1(); // State Flip (change of power state)
|
commandID[PowerOn] = QStringLiteral("sf").toLatin1(); // State Flip (change of power state)
|
||||||
commandID[PowerOff] = commandID[PowerOn];
|
commandID[PowerOff] = commandID[PowerOn];
|
||||||
commandID[ReadTable] = QStringLiteral("rt").toLatin1();
|
commandID[ReadTable] = QStringLiteral("rt").toLatin1();
|
||||||
|
@ -49,7 +49,7 @@ Socket::Socket(QHostAddress IPaddress, QByteArray reply)
|
||||||
datagram[Subscribe] = commandID[Subscribe] + mac + twenties + rmac + twenties;
|
datagram[Subscribe] = commandID[Subscribe] + mac + twenties + rmac + twenties;
|
||||||
datagram[PowerOn] = commandIDPower + mac + twenties + zeros + one;
|
datagram[PowerOn] = commandIDPower + mac + twenties + zeros + one;
|
||||||
datagram[PowerOff] = commandIDPower + mac + twenties + zeros + zero;
|
datagram[PowerOff] = commandIDPower + mac + twenties + zeros + zero;
|
||||||
datagram[ReadTable] = commandID[ReadTable] + mac + twenties + /*zeros*/QByteArray::fromHex("72 00 00 00") + QByteArray::fromHex("01 00 00") + zeros;
|
datagram[ReadTable] = commandID[ReadTable] + mac + twenties + /*zeros*/QByteArray::fromHex("00 00 00 00") /*cookie*/ + QByteArray::fromHex("01 00") + zero + zeros;
|
||||||
|
|
||||||
udpSocket = new QUdpSocket();
|
udpSocket = new QUdpSocket();
|
||||||
udpSocket->connectToHost(ip, 10000);
|
udpSocket->connectToHost(ip, 10000);
|
||||||
|
|
Loading…
Reference in New Issue