|
48 | 48 |
|
49 | 49 | //#include <UIPEthernet.h> |
50 | 50 |
|
51 | | -#if defined ethernet_h || defined UIPETHERNET_H |
| 51 | +/* |
| 52 | + * To execute Network Firmata on Yun uncomment Bridge.h and YunClient.h. |
| 53 | + * Do not include Ethernet.h or SPI.h in this case. |
| 54 | + * On Yun there's no need to configure local_ip and mac in the sketch |
| 55 | + * as this is configured on the linux-side of Yun. |
| 56 | + */ |
| 57 | + |
| 58 | +//#include <Bridge.h> |
| 59 | +//#include <YunClient.h> |
| 60 | + |
| 61 | +#if defined ethernet_h || defined UIPETHERNET_H || defined _YUN_CLIENT_H_ |
52 | 62 | /*============================================================================== |
53 | 63 | * Network configuration for Network Firmata |
54 | 64 | *============================================================================*/ |
|
59 | 69 | #define remote_host "server.local" |
60 | 70 | //replace with the port that your server is listening on |
61 | 71 | #define remote_port 3030 |
62 | | -//replace with arduinos ip-address. Comment out if Ethernet-startup should use dhcp |
| 72 | +//replace with arduinos ip-address. Comment out if Ethernet-startup should use dhcp. Is ignored on Yun |
63 | 73 | #define local_ip IPAddress(192,168,0,6) |
64 | | -//replace with ethernet shield mac. It's mandatory every device is assigned a unique mac |
| 74 | +//replace with ethernet shield mac. It's mandatory every device is assigned a unique mac. Is ignored on Yun |
65 | 75 | const byte mac[] = {0x90,0xA2,0xDA,0x0D,0x07,0x02}; |
66 | 76 | #endif |
67 | 77 |
|
@@ -126,7 +136,11 @@ FirmataReporting reporting; |
126 | 136 | #error "cannot define both remote_ip and remote_host at the same time!" |
127 | 137 | #endif |
128 | 138 | #include <utility/EthernetClientStream.h> |
| 139 | +#ifdef _YUN_CLIENT_H_ |
| 140 | +YunClient client; |
| 141 | +#else |
129 | 142 | EthernetClient client; |
| 143 | +#endif |
130 | 144 | #if defined remote_ip && !defined remote_host |
131 | 145 | #ifdef local_ip |
132 | 146 | EthernetClientStream stream(client,local_ip,remote_ip,NULL,remote_port); |
@@ -179,10 +193,14 @@ void systemResetCallback() |
179 | 193 | void setup() |
180 | 194 | { |
181 | 195 | #ifdef NETWORK_FIRMATA |
| 196 | +#ifdef _YUN_CLIENT_H_ |
| 197 | + Bridge.begin(); |
| 198 | +#else |
182 | 199 | #ifdef local_ip |
183 | 200 | Ethernet.begin((uint8_t*)mac,local_ip); //start ethernet |
184 | 201 | #else |
185 | 202 | Ethernet.begin((uint8_t*)mac); //start ethernet using dhcp |
| 203 | +#endif |
186 | 204 | #endif |
187 | 205 | delay(1000); |
188 | 206 | #endif |
@@ -306,7 +324,7 @@ runtasks: scheduler.runTasks(); |
306 | 324 | #ifdef StepperFirmata_h |
307 | 325 | stepper.update(); |
308 | 326 | #endif |
309 | | -#if defined NETWORK_FIRMATA && !defined local_ip |
| 327 | +#if defined NETWORK_FIRMATA && !defined local_ip &&!defined _YUN_CLIENT_H_ |
310 | 328 | if (Ethernet.maintain()) |
311 | 329 | { |
312 | 330 | stream.maintain(Ethernet.localIP()); |
|
0 commit comments