Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 3cb024c

Browse files
update naming for rest server
1 parent 74f090a commit 3cb024c

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

examples/ciaoBraccio/ciaoBraccio.ino

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int parseCommand(String command, String type) {
6767
void loop() {
6868

6969
//Select REST connector
70-
CiaoData data = Ciao.read("rest");
70+
CiaoData data = Ciao.read("restserver");
7171
//If data is not empry
7272
if (!data.isEmpty()) {
7373
//ID of the command
@@ -86,11 +86,11 @@ void loop() {
8686
//Turn OFF Led 13
8787
digitalWrite(13, HIGH);
8888
//Return message to the sender (Eg: the browser)
89-
Ciao.writeResponse("rest", id, "Led D13 ON");
89+
Ciao.writeResponse("restserver", id, "Led D13 ON");
9090
}
9191
else if (message == "LEDOFF") {
9292
digitalWrite(13, LOW);
93-
Ciao.writeResponse("rest", id, "Led D13 OFF");
93+
Ciao.writeResponse("restserver", id, "Led D13 OFF");
9494
}
9595
//This command allow you to move a desired servo motor giving the
9696
//PWM pin where is connected
@@ -100,67 +100,67 @@ void loop() {
100100
//Parse the message to retrive what is the value for the servo
101101
int value = parseCommand(message, "VALUE");
102102

103-
Ciao.writeResponse("rest", id, "Message:" + String(message) + "SERVO: " + String(servo) + " " + String(value));
103+
Ciao.writeResponse("restserver", id, "Message:" + String(message) + "SERVO: " + String(servo) + " " + String(value));
104104
}
105105
//Command for the base of the braccio (M1)
106106
else if (message.startsWith("BASE")) {
107107
m1 = parseCommand(message, "VALUE");
108108
moveBraccio = true;
109-
Ciao.writeResponse("rest", id, "BASE: " + String(m1));
109+
Ciao.writeResponse("restserver", id, "BASE: " + String(m1));
110110
}
111111
//Command for the shoulder of the braccio (M2)
112112
else if (message.startsWith("SHOULDER")) {
113113
m2 = parseCommand(message, "VALUE");
114114
moveBraccio = true;
115-
Ciao.writeResponse("rest", id, "SHOULDER: " + String(m2));
115+
Ciao.writeResponse("restserver", id, "SHOULDER: " + String(m2));
116116
}
117117
//Command for the elbow of the braccio (M3)
118118
else if (message.startsWith("ELBOW")) {
119119
m3 = parseCommand(message, "VALUE");
120120
moveBraccio = true;
121-
Ciao.writeResponse("rest", id, "ELBOW: " + String(m3));
121+
Ciao.writeResponse("restserver", id, "ELBOW: " + String(m3));
122122
}
123123
//Command for the wrist of the braccio to move it up and down (M4)
124124
else if (message.startsWith("WRISTV")) {
125125
m4 = parseCommand(message, "VALUE");
126126
moveBraccio = true;
127-
Ciao.writeResponse("rest", id, "WRISTV: " + String(m4));
127+
Ciao.writeResponse("restserver", id, "WRISTV: " + String(m4));
128128
}
129129
//Command for the wrist of the braccio to rotate it (M5)
130130
else if (message.startsWith("WRISTR")) {
131131
m5 = parseCommand(message, "VALUE");
132132
moveBraccio = true;
133-
Ciao.writeResponse("rest", id, "WRISTR: " + String(m5));
133+
Ciao.writeResponse("restserver", id, "WRISTR: " + String(m5));
134134
}
135135
//Command for the gripper of the braccio to open and close it (M6)
136136
else if (message.startsWith("GRIPPER")) {
137137
m6 = parseCommand(message, "VALUE");
138138
moveBraccio = true;
139-
Ciao.writeResponse("rest", id, "GRIPPER: " + String(m6));
139+
Ciao.writeResponse("restserver", id, "GRIPPER: " + String(m6));
140140
}
141141
//Command to say "Ciao"
142142
else if (message.startsWith("SAYCIAO")) {
143143
sayCiao();
144-
Ciao.writeResponse("rest", id, "SAYCIAO: " + String(m6));
144+
Ciao.writeResponse("restserver", id, "SAYCIAO: " + String(m6));
145145
}
146146
//Command for take the sponge
147147
else if (message.startsWith("TAKESPONGE")) {
148148
takesponge();
149-
Ciao.writeResponse("rest", id, "TAKESPONGE: " + String(m6));
149+
Ciao.writeResponse("restserver", id, "TAKESPONGE: " + String(m6));
150150
}
151151
//Command for show the sponge
152152
else if (message.startsWith("SHOWSPONGE")) {
153153
showsponge();
154-
Ciao.writeResponse("rest", id, "SHOWSPONGE: " + String(m6));
154+
Ciao.writeResponse("restserver", id, "SHOWSPONGE: " + String(m6));
155155
}
156156
//Command for throw away the sponge
157157
else if (message.startsWith("THROWSPONGE")) {
158158
throwsponge();
159-
Ciao.writeResponse("rest", id, "THROWSPONGE: " + String(m6));
159+
Ciao.writeResponse("restserver", id, "THROWSPONGE: " + String(m6));
160160
}
161161

162162
else
163-
Ciao.writeResponse("rest", id, "command error");
163+
Ciao.writeResponse("restserver", id, "command error");
164164

165165
//if flag moveBraccio is true fire the movement
166166
if (moveBraccio) {
@@ -229,6 +229,3 @@ void throwsponge() {
229229

230230
Braccio.ServoMovement(5, 0, 90, 150, 90, 90, 0);
231231
}
232-
233-
234-

0 commit comments

Comments
 (0)