Skip to content

Commit dce3814

Browse files
committed
ConfigurableFirmata: add support for Yun over Ethernet or Wifi
1 parent c84f58d commit dce3814

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

examples/ConfigurableFirmata/ConfigurableFirmata.ino

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@
4848

4949
//#include <UIPEthernet.h>
5050

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_
5262
/*==============================================================================
5363
* Network configuration for Network Firmata
5464
*============================================================================*/
@@ -59,9 +69,9 @@
5969
#define remote_host "server.local"
6070
//replace with the port that your server is listening on
6171
#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
6373
#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
6575
const byte mac[] = {0x90,0xA2,0xDA,0x0D,0x07,0x02};
6676
#endif
6777

@@ -126,7 +136,11 @@ FirmataReporting reporting;
126136
#error "cannot define both remote_ip and remote_host at the same time!"
127137
#endif
128138
#include <utility/EthernetClientStream.h>
139+
#ifdef _YUN_CLIENT_H_
140+
YunClient client;
141+
#else
129142
EthernetClient client;
143+
#endif
130144
#if defined remote_ip && !defined remote_host
131145
#ifdef local_ip
132146
EthernetClientStream stream(client,local_ip,remote_ip,NULL,remote_port);
@@ -179,10 +193,14 @@ void systemResetCallback()
179193
void setup()
180194
{
181195
#ifdef NETWORK_FIRMATA
196+
#ifdef _YUN_CLIENT_H_
197+
Bridge.begin();
198+
#else
182199
#ifdef local_ip
183200
Ethernet.begin((uint8_t*)mac,local_ip); //start ethernet
184201
#else
185202
Ethernet.begin((uint8_t*)mac); //start ethernet using dhcp
203+
#endif
186204
#endif
187205
delay(1000);
188206
#endif
@@ -306,7 +324,7 @@ runtasks: scheduler.runTasks();
306324
#ifdef StepperFirmata_h
307325
stepper.update();
308326
#endif
309-
#if defined NETWORK_FIRMATA && !defined local_ip
327+
#if defined NETWORK_FIRMATA && !defined local_ip &&!defined _YUN_CLIENT_H_
310328
if (Ethernet.maintain())
311329
{
312330
stream.maintain(Ethernet.localIP());

0 commit comments

Comments
 (0)