|
2 | 2 |
|
3 | 3 | #include <Process.h>
|
4 | 4 |
|
5 |
| -void sendCommand(const char *name, const char * cmd, const char * param1, const char * param2) { |
| 5 | +void sendCommand(const char *name, const char * cmd) { |
6 | 6 | Serial.print("=== ");
|
7 |
| - Serial.print(name); |
8 |
| - Serial.println(" ==="); |
| 7 | + Serial.println(name); |
9 | 8 |
|
10 |
| - Process p; |
11 |
| - p.begin(cmd); |
12 |
| - p.addParameter(param1); |
13 |
| - |
14 |
| - if(param2 != NULL) { |
15 |
| - p.addParameter(param2); |
16 |
| - } |
17 |
| - |
18 |
| - Serial.print("> running '"); |
| 9 | + Serial.print("--> running '"); |
19 | 10 | Serial.print(cmd);
|
20 |
| - Serial.print(' '); |
21 |
| - Serial.print(param1); |
22 |
| - |
23 |
| - if(param2 != NULL) { |
24 |
| - Serial.print(' '); |
25 |
| - Serial.print(param2); |
26 |
| - } |
27 |
| - |
28 | 11 | Serial.println("'");
|
29 | 12 |
|
30 |
| - p.run(); |
| 13 | + Process p; |
| 14 | + p.begin(cmd); |
| 15 | + p.runShellCommand(cmd); |
31 | 16 |
|
32 | 17 | while (p.available() > 0) {
|
33 | 18 | char c = p.read();
|
34 | 19 | Serial.print(c);
|
35 | 20 | }
|
36 | 21 |
|
37 |
| - Serial.flush(); |
38 |
| - |
39 |
| - Serial.println("> finished!"); |
40 |
| - Serial.println(""); |
| 22 | + Serial.println("--> finished!\n"); |
41 | 23 | }
|
42 | 24 |
|
43 | 25 | void YunMQTTInstall() {
|
44 |
| - Serial.println("Starting Installation!"); |
45 |
| - Serial.println(""); |
46 |
| - |
47 |
| - sendCommand("Update", "opkg", "update", NULL); |
48 |
| - sendCommand("Install 'easy_install'", "opkg", "install", "distribute"); |
49 |
| - sendCommand("Install python SSL support", "opkg", "install", "python-openssl"); |
50 |
| - sendCommand("Install 'pip'", "easy_install", "pip", NULL); |
51 |
| - sendCommand("Install 'paho-mqtt'", "pip", "install", "paho-mqtt"); |
52 |
| - sendCommand("Download script", "wget", "https://raw.githubusercontent.com/256dpi/arduino-mqtt/yun-client/yun/client.py", NULL); |
| 26 | + Serial.println("Starting Installation!\n"); |
| 27 | + |
| 28 | + sendCommand("Update", "opkg update"); |
| 29 | + sendCommand("Install 'easy_install'", "opkg install distribute"); |
| 30 | + sendCommand("Install python SSL support", "opkg install python-openssl"); |
| 31 | + sendCommand("Install 'pip'", "easy_install pip"); |
| 32 | + sendCommand("Install 'paho-mqtt'", "pip install paho-mqtt"); |
| 33 | + sendCommand("Download script", "wget https://raw.githubusercontent.com/256dpi/arduino-mqtt/yun-client/yun/client.py --no-check-certificate -o /usr/client.py"); |
53 | 34 |
|
54 | 35 | Serial.println("Installation finished!");
|
55 | 36 | }
|
0 commit comments