Skip to content

Commit

Permalink
Bootloader detection bug fixed. Initial update-over-BLE support added.
Browse files Browse the repository at this point in the history
  • Loading branch information
rasgo-cc committed Nov 9, 2016
1 parent 932ca99 commit 4d625a0
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 27 deletions.
8 changes: 4 additions & 4 deletions gecko_loader.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
QT += core
QT += gui

CONFIG += console
#CONFIG += console

greaterThan(QT_MAJOR_VERSION, 4): QT += serialport widgets bluetooth
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport widgets

TARGET = gecko_loader
TEMPLATE = app

#DEFINES += QT_NO_DEBUG_OUTPUT
DEFINES += EFM32_LOADER_GUI EFM32LOADER_SERIAL=1 EFM32LOADER_BLE=1
DEFINES += QT_NO_DEBUG_OUTPUT
DEFINES += EFM32_LOADER_GUI EFM32LOADER_SERIAL=1 EFM32LOADER_BLE=0

SOURCES += main.cpp\
mainwindow.cpp \
Expand Down
4 changes: 2 additions & 2 deletions geckoloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ bool GeckoLoader::waitForChipID()
}
else
{
QString line = QString(_serialPort->readLine());
if(line.contains("ChipID"))
QString line = QString(_serialPort->readLine()).toLower();
if(line.contains("chip"))
{
emit output(tr("Bootloader detected"));
return true;
Expand Down
34 changes: 29 additions & 5 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,51 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);

ui->comboTransport->addItem("UART");
ui->comboTransport->addItem("USB");
#if EFM32LOADER_BLE
ui->comboTransport->addItem("BLE");
#endif

//ui->lineASCII->hide();
ui->textLog->setFont(QFont("Courier New", 9));

loader = new GeckoLoader(this);
serialPort = loader->serialPort();


#if EFM32LOADER_BLE
bleDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
#endif

_connected = false;

readSettings();
slotReloadSerialPorts();

connect(loader, SIGNAL(output(QString)), this, SLOT(log(QString)));
connect(serialPort, SIGNAL(readyRead()), this, SLOT(slotDataReady()));
connect(ui->buttonScanBLE, SIGNAL(clicked(bool)), this, SLOT(slotScanBLE()));
connect(ui->buttonConnectBLE, SIGNAL(clicked(bool)), this, SLOT(slotConnectBLE()));
connect(ui->buttonHelp, SIGNAL(clicked()), this, SLOT(slotHelp()));
connect(ui->buttonReload, SIGNAL(clicked()), this, SLOT(slotReloadSerialPorts()));
connect(ui->buttonBrowse, SIGNAL(clicked()), this, SLOT(slotBrowse()));
connect(ui->buttonUpload, SIGNAL(clicked()), this, SLOT(slotUpload()));
connect(ui->buttonConnect, SIGNAL(clicked()), this, SLOT(slotConnect()));
connect(ui->comboTransport, SIGNAL(currentIndexChanged(int)), this, SLOT(slotTransport()));
connect(ui->buttonSendASCII, SIGNAL(clicked(bool)), this, SLOT(slotSendASCII()));

connect(ui->lineASCII, SIGNAL(returnPressed()), this, SLOT(slotSendASCII()));

#if EFM32LOADER_BLE
connect(ui->buttonScanBLE, SIGNAL(clicked(bool)), this, SLOT(slotScanBLE()));
connect(ui->buttonConnectBLE, SIGNAL(clicked(bool)), this, SLOT(slotConnectBLE()));
connect(bleDiscoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
this, SLOT(slotDeviceDiscovered(QBluetoothDeviceInfo)));
connect(bleDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
this, SLOT(slotDeviceScanError(QBluetoothDeviceDiscoveryAgent::Error)));
connect(bleDiscoveryAgent, SIGNAL(finished()),
this, SLOT(slotDeviceScanFinished()));
#endif

connect(ui->lineASCII, SIGNAL(returnPressed()), this, SLOT(slotSendASCII()));

updateInterface();
}
Expand Down Expand Up @@ -141,6 +156,7 @@ void MainWindow::slotTransport()
}


#if EFM32LOADER_BLE
void MainWindow::slotScanBLE()
{
log("BLE scanning...");
Expand Down Expand Up @@ -175,6 +191,7 @@ void MainWindow::slotDeviceScanFinished()
{
log("BLE scan finished");
}
#endif

void MainWindow::slotUpload()
{
Expand All @@ -191,7 +208,8 @@ void MainWindow::slotUpload()
void MainWindow::slotSendASCII()
{
QString text = ui->lineASCII->text();
serialPort->write(text.toLatin1());
if(serialPort->isOpen())
serialPort->write(text.toLatin1());
}

void MainWindow::slotDataReady()
Expand Down Expand Up @@ -239,6 +257,12 @@ void MainWindow::updateInterface()
{
ui->stackedWidget->setCurrentIndex(0);
}

ui->labelASCII->setVisible(!transportIsBLE);
ui->lineASCII->setVisible(!transportIsBLE);
ui->buttonSendASCII->setVisible(!transportIsBLE);

ui->buttonSendASCII->setEnabled(_connected);
}

#endif //EFM32_LOADER_GUI
7 changes: 7 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

#ifdef EFM32_LOADER_GUI
#include <QMainWindow>

#if EFM32LOADER_BLE
#include <QBluetoothDeviceDiscoveryAgent>
#endif

namespace Ui {
class MainWindow;
Expand All @@ -49,12 +52,14 @@ private slots:
void slotSendASCII();
void slotDataReady();

#if EFM32LOADER_BLE
void slotScanBLE();
void slotConnectBLE();
void slotTestBLE();
void slotDeviceDiscovered(QBluetoothDeviceInfo info);
void slotDeviceScanError(QBluetoothDeviceDiscoveryAgent::Error err);
void slotDeviceScanFinished();
#endif

void log(const QString &text);
void updateInterface();
Expand All @@ -64,7 +69,9 @@ private slots:

GeckoLoader *loader;
QSerialPort *serialPort;
#if EFM32LOADER_BLE
QBluetoothDeviceDiscoveryAgent *bleDiscoveryAgent;
#endif
bool _connected;

void readSettings();
Expand Down
48 changes: 32 additions & 16 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>UART</string>
</property>
</item>
<item>
<property name="text">
<string>USB</string>
</property>
</item>
<item>
<property name="text">
<string>BLE</string>
</property>
</item>
</widget>
</item>
<item>
Expand Down Expand Up @@ -285,6 +270,12 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Service UUID</string>
</property>
Expand All @@ -295,6 +286,12 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Char UUID</string>
</property>
Expand Down Expand Up @@ -346,7 +343,25 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineASCII"/>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="labelASCII">
<property name="text">
<string>ASCII</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineASCII"/>
</item>
<item>
<widget class="QPushButton" name="buttonSendASCII">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder>textLog</zorder>
Expand All @@ -356,6 +371,7 @@
<zorder>buttonHelp</zorder>
<zorder>stackedWidget</zorder>
<zorder>widgetBLE</zorder>
<zorder>labelASCII</zorder>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
Expand Down

0 comments on commit 4d625a0

Please sign in to comment.