From 8693907db5a460d7536ba805a912564d1e3278eb Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 2 Apr 2024 11:42:30 -0500 Subject: [PATCH] WIP for Tello Connect button --- include/botui/TelloWidget.h | 2 +- src/TelloWidget.cpp | 47 +++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/include/botui/TelloWidget.h b/include/botui/TelloWidget.h index 537001a5..a342e31e 100644 --- a/include/botui/TelloWidget.h +++ b/include/botui/TelloWidget.h @@ -20,7 +20,7 @@ Q_OBJECT ~TelloWidget(); private slots: - + int telloConnect(); private: Ui::TelloWidget *ui; diff --git a/src/TelloWidget.cpp b/src/TelloWidget.cpp index 5585d04e..5485a377 100644 --- a/src/TelloWidget.cpp +++ b/src/TelloWidget.cpp @@ -1,9 +1,5 @@ #include "TelloWidget.h" #include "ui_TelloWidget.h" -#include "Create3SensorListWidget.h" -#include "Create3ExampleWidget.h" -#include "Create3SensorModel.h" -#include #include #include "NumpadDialog.h" #include @@ -17,7 +13,7 @@ #include #include #include "RootController.h" - +#include TelloWidget::TelloWidget(Device *device, QWidget *parent) : StandardWidget(device, parent), @@ -26,6 +22,9 @@ TelloWidget::TelloWidget(Device *device, QWidget *parent) ui->setupUi(this); performStandardSetup(tr("Tello"), false); setStyleSheet("QScrollBar:vertical {border: 2px solid grey;background:grey ;width: 100px; margin: 22px 0 22px 0; } QScrollBar::handle:vertical { border: 2px solid grey;background: white; min-height: 20px; } QScrollBar::add-line:vertical { border: 2px solid grey;background: #32CC99; height: 20px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical {border: 2px solid grey; background: #32CC99; height: 20px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 2px solid grey;width: 3px; height: 3px; background: white; }QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {border: 2px solid grey; background: none;}"); + connect(ui->TelloConnect, SIGNAL(clicked()), SLOT(telloConnect())); + + } TelloWidget::~TelloWidget() @@ -33,4 +32,42 @@ TelloWidget::~TelloWidget() delete ui; } +int TelloWidget::telloConnect() +{ + + int result; + char buf[TELLO_BUFSIZE]; + int len; + int n; + struct tello_ssid *tellos; + struct tello_info tello; + int send_result; + + + if (wpa_sup_connect() == -1) + { + qDebug() << "failed to open wpa_supplicant\n"; + return -1; + } + else + qDebug() << "wpa_supplicant opened\n"; + + tellos = tellos_find(); + + n = 0; + qDebug() << "List of Tellos\n"; + + while (tellos[n].ssid[0] != '\0') + { + qDebug() << "Tellos: %s\n" + << tellos[n].ssid; + // printf("Tellos: %s\n", tellos[n].ssid); + n++; + } + fflush(NULL); + + // for this example select only the first Tello in the list + + tello_connect(&tello, tellos[0].ssid); +}