@@ -67,7 +67,7 @@ int parseCommand(String command, String type) {
67
67
void loop () {
68
68
69
69
// Select REST connector
70
- CiaoData data = Ciao.read (" rest " );
70
+ CiaoData data = Ciao.read (" restserver " );
71
71
// If data is not empry
72
72
if (!data.isEmpty ()) {
73
73
// ID of the command
@@ -86,11 +86,11 @@ void loop() {
86
86
// Turn OFF Led 13
87
87
digitalWrite (13 , HIGH);
88
88
// Return message to the sender (Eg: the browser)
89
- Ciao.writeResponse (" rest " , id, " Led D13 ON" );
89
+ Ciao.writeResponse (" restserver " , id, " Led D13 ON" );
90
90
}
91
91
else if (message == " LEDOFF" ) {
92
92
digitalWrite (13 , LOW);
93
- Ciao.writeResponse (" rest " , id, " Led D13 OFF" );
93
+ Ciao.writeResponse (" restserver " , id, " Led D13 OFF" );
94
94
}
95
95
// This command allow you to move a desired servo motor giving the
96
96
// PWM pin where is connected
@@ -100,67 +100,67 @@ void loop() {
100
100
// Parse the message to retrive what is the value for the servo
101
101
int value = parseCommand (message, " VALUE" );
102
102
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));
104
104
}
105
105
// Command for the base of the braccio (M1)
106
106
else if (message.startsWith (" BASE" )) {
107
107
m1 = parseCommand (message, " VALUE" );
108
108
moveBraccio = true ;
109
- Ciao.writeResponse (" rest " , id, " BASE: " + String (m1));
109
+ Ciao.writeResponse (" restserver " , id, " BASE: " + String (m1));
110
110
}
111
111
// Command for the shoulder of the braccio (M2)
112
112
else if (message.startsWith (" SHOULDER" )) {
113
113
m2 = parseCommand (message, " VALUE" );
114
114
moveBraccio = true ;
115
- Ciao.writeResponse (" rest " , id, " SHOULDER: " + String (m2));
115
+ Ciao.writeResponse (" restserver " , id, " SHOULDER: " + String (m2));
116
116
}
117
117
// Command for the elbow of the braccio (M3)
118
118
else if (message.startsWith (" ELBOW" )) {
119
119
m3 = parseCommand (message, " VALUE" );
120
120
moveBraccio = true ;
121
- Ciao.writeResponse (" rest " , id, " ELBOW: " + String (m3));
121
+ Ciao.writeResponse (" restserver " , id, " ELBOW: " + String (m3));
122
122
}
123
123
// Command for the wrist of the braccio to move it up and down (M4)
124
124
else if (message.startsWith (" WRISTV" )) {
125
125
m4 = parseCommand (message, " VALUE" );
126
126
moveBraccio = true ;
127
- Ciao.writeResponse (" rest " , id, " WRISTV: " + String (m4));
127
+ Ciao.writeResponse (" restserver " , id, " WRISTV: " + String (m4));
128
128
}
129
129
// Command for the wrist of the braccio to rotate it (M5)
130
130
else if (message.startsWith (" WRISTR" )) {
131
131
m5 = parseCommand (message, " VALUE" );
132
132
moveBraccio = true ;
133
- Ciao.writeResponse (" rest " , id, " WRISTR: " + String (m5));
133
+ Ciao.writeResponse (" restserver " , id, " WRISTR: " + String (m5));
134
134
}
135
135
// Command for the gripper of the braccio to open and close it (M6)
136
136
else if (message.startsWith (" GRIPPER" )) {
137
137
m6 = parseCommand (message, " VALUE" );
138
138
moveBraccio = true ;
139
- Ciao.writeResponse (" rest " , id, " GRIPPER: " + String (m6));
139
+ Ciao.writeResponse (" restserver " , id, " GRIPPER: " + String (m6));
140
140
}
141
141
// Command to say "Ciao"
142
142
else if (message.startsWith (" SAYCIAO" )) {
143
143
sayCiao ();
144
- Ciao.writeResponse (" rest " , id, " SAYCIAO: " + String (m6));
144
+ Ciao.writeResponse (" restserver " , id, " SAYCIAO: " + String (m6));
145
145
}
146
146
// Command for take the sponge
147
147
else if (message.startsWith (" TAKESPONGE" )) {
148
148
takesponge ();
149
- Ciao.writeResponse (" rest " , id, " TAKESPONGE: " + String (m6));
149
+ Ciao.writeResponse (" restserver " , id, " TAKESPONGE: " + String (m6));
150
150
}
151
151
// Command for show the sponge
152
152
else if (message.startsWith (" SHOWSPONGE" )) {
153
153
showsponge ();
154
- Ciao.writeResponse (" rest " , id, " SHOWSPONGE: " + String (m6));
154
+ Ciao.writeResponse (" restserver " , id, " SHOWSPONGE: " + String (m6));
155
155
}
156
156
// Command for throw away the sponge
157
157
else if (message.startsWith (" THROWSPONGE" )) {
158
158
throwsponge ();
159
- Ciao.writeResponse (" rest " , id, " THROWSPONGE: " + String (m6));
159
+ Ciao.writeResponse (" restserver " , id, " THROWSPONGE: " + String (m6));
160
160
}
161
161
162
162
else
163
- Ciao.writeResponse (" rest " , id, " command error" );
163
+ Ciao.writeResponse (" restserver " , id, " command error" );
164
164
165
165
// if flag moveBraccio is true fire the movement
166
166
if (moveBraccio) {
@@ -229,6 +229,3 @@ void throwsponge() {
229
229
230
230
Braccio.ServoMovement (5 , 0 , 90 , 150 , 90 , 90 , 0 );
231
231
}
232
-
233
-
234
-
0 commit comments