-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (43 loc) · 1 KB
/
Copy pathmain.cpp
File metadata and controls
52 lines (43 loc) · 1 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
#include <iostream>
#include <string>
#include <vector>
#include "BLEDevice.h"
using namespace std;
int main(){
BLEDevice alice("Alice");
BLEDevice bob("Bob");
BLEDevice alex("Alex");
BLEDevice ophelio("Ophelio");
BLEDevice nikita("nikita");
vector<BLEDevice*> devices = {&alice, &bob,&alex,&ophelio};
string msg;
int turn = 0;
bob.advertise();
ophelio.advertise();
alex.advertise();
BLEDevice* found = alice.scan(devices);
if(found){
alice.connect(*found);
}else{
return 1;
}
cout << "BLE Chat Simulation Started\n";
int i = 0;
while(i<=3){
if(turn == 0){
cout << "Alice: ";
getline(cin,msg);
alice.sendPacket("MSG",msg);
turn = 1;
}
else{
cout << (alice.device)->name<<":";
getline(cin,msg);
(alice.device)->sendPacket("MSG",msg);
turn = 0;
}
i++;
}
alice.disconnect();
return 0;
}