-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwidget.cpp
More file actions
64 lines (53 loc) · 1.43 KB
/
Copy pathwidget.cpp
File metadata and controls
64 lines (53 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
m_ble = new BLE(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_scan_clicked()
{
connect(m_ble,&BLE::signal_scanFinished,[=]{
auto list = m_ble->getDevices();
if(list.isEmpty())
return ;
ui->listWidget_dev->clear();
for(auto s : list){
ui->listWidget_dev->addItem(s.address().toString());
}
});
if(!m_ble->getScanning())
m_ble->startScanDevices();
}
void Widget::on_pushButton_connect_clicked()
{
connect(m_ble,&BLE::signal_findservicesFinished,[=]{
auto list = m_ble->getServicesUUID();
if(list.isEmpty())
return ;
ui->listWidget_services->clear();
for(auto s : list){
ui->listWidget_services->addItem(s.toString());
}
});
m_ble->connectDevice(ui->listWidget_dev->currentItem()->text());
}
void Widget::on_pushButton_service_clicked()
{
connect(m_ble,&BLE::signal_findcharsFinished,[=]{
auto list = m_ble->getChars();
if(list.isEmpty())
return ;
ui->listWidget_character->clear();
for(auto s : list){
ui->listWidget_character->addItem(s.uuid().toString());
}
});
m_ble->connectService(ui->listWidget_services->currentItem()->text());
}