|
@@ -1,5 +1,6 @@
|
1
|
1
|
#include <iostream>
|
2
|
2
|
#include<signal.h>
|
|
3
|
+#include <sstream>
|
3
|
4
|
#include "DataAccess/ArduinoSerial.h"
|
4
|
5
|
|
5
|
6
|
|
|
@@ -16,6 +17,21 @@ std::string hexStr(std::string str)
|
16
|
17
|
return s;
|
17
|
18
|
}
|
18
|
19
|
|
|
20
|
+std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
|
|
21
|
+ std::stringstream ss(s);
|
|
22
|
+ std::string item;
|
|
23
|
+ while (std::getline(ss, item, delim)) {
|
|
24
|
+ elems.push_back(item);
|
|
25
|
+ }
|
|
26
|
+ return elems;
|
|
27
|
+}
|
|
28
|
+
|
|
29
|
+std::vector<std::string> split(const std::string &s, char delim) {
|
|
30
|
+ std::vector<std::string> elems;
|
|
31
|
+ split(s, delim, elems);
|
|
32
|
+ return elems;
|
|
33
|
+}
|
|
34
|
+
|
19
|
35
|
int lastSignal = 0;
|
20
|
36
|
|
21
|
37
|
void sig_handler(int signo)
|
|
@@ -49,6 +65,15 @@ int main()
|
49
|
65
|
SERIAL_PACKET_TYPE_INT status = ERROR_NONE;
|
50
|
66
|
arduinoSerial.write((const char*)&status, sizeof(status));
|
51
|
67
|
}
|
|
68
|
+ if (data.getData().first == PACKET_LOGIN) {
|
|
69
|
+ std::vector<std::string> login = split(data.getData().second, '\n');
|
|
70
|
+ if (login.size() == 2) {
|
|
71
|
+ std::string uid = login[0];
|
|
72
|
+ std::string passwd = login[1];
|
|
73
|
+ SERIAL_PACKET_TYPE_INT status = (uid == "4242" ? LOGIN_OK : LOGIN_FAILED);
|
|
74
|
+ arduinoSerial.write((const char *) &status, sizeof(status));
|
|
75
|
+ }
|
|
76
|
+ }
|
52
|
77
|
}
|
53
|
78
|
return 0;
|
54
|
79
|
|