diff --git a/workspace/__lib__/xod-dev/w5500/connect-blocking/patch.cpp b/workspace/__lib__/xod-dev/w5500/connect-blocking/patch.cpp new file mode 100644 index 00000000..16c3e5ec --- /dev/null +++ b/workspace/__lib__/xod-dev/w5500/connect-blocking/patch.cpp @@ -0,0 +1,35 @@ +{{#global}} +#include +#include +{{/global}} + +struct State { +}; + +{{ GENERATED_CODE }} + +void evaluate(Context ctx) { + if (!isInputDirty(ctx)) + return; + + auto dev = getValue(ctx); + + Ethernet.init(dev.cs); + ValueType::T inet; + +#if defined(WIZ550io_WITH_MACADDRESS) + if (Ethernet.begin() == 0) { +#else + if (Ethernet.begin(dev.mac) == 0) { +#endif + inet.ip = (uint32_t)0; + inet.isConnected = false; + emitValue(ctx, 1); + } else { + inet.ip = (uint32_t)Ethernet.localIP(); + inet.isConnected = true; + emitValue(ctx, 1); + } + + emitValue(ctx, inet); +} diff --git a/workspace/__lib__/xod-dev/w5500/connect-blocking/patch.xodp b/workspace/__lib__/xod-dev/w5500/connect-blocking/patch.xodp new file mode 100644 index 00000000..f2a468c4 --- /dev/null +++ b/workspace/__lib__/xod-dev/w5500/connect-blocking/patch.xodp @@ -0,0 +1,74 @@ +{ + "description": "Establish an internet connection by automatically getting all required configuration info from a DHCP server", + "nodes": [ + { + "id": "BJXXLBwPfQ", + "position": { + "x": -1, + "y": 101 + }, + "type": "xod/patch-nodes/not-implemented-in-xod" + }, + { + "boundLiterals": { + "__out__": "On Boot" + }, + "description": "Establish the connection", + "id": "BJfXLrPDzm", + "label": "CONN", + "position": { + "x": 102, + "y": 0 + }, + "type": "xod/patch-nodes/input-pulse" + }, + { + "id": "ByF36Re7Q", + "position": { + "x": 204, + "y": 0 + }, + "type": "xod/patch-nodes/utility" + }, + { + "description": "Pulses on a successful connection", + "id": "H1b7LrDPGm", + "label": "DONE", + "position": { + "x": 102, + "y": 204 + }, + "type": "xod/patch-nodes/output-pulse" + }, + { + "description": "A W5500-based internet provider device", + "id": "HkhKBPPfX", + "label": "DEV", + "position": { + "x": 0, + "y": 0 + }, + "type": "@/input-ethernet-shield-device" + }, + { + "description": "An internet connection", + "id": "rJ6H7ovfQ", + "label": "INET", + "position": { + "x": 0, + "y": 204 + }, + "type": "@/output-inet" + }, + { + "description": "Pulses if the connection failed", + "id": "ryx7LHwPfm", + "label": "ERR", + "position": { + "x": 204, + "y": 204 + }, + "type": "xod/patch-nodes/output-pulse" + } + ] +} diff --git a/workspace/__lib__/xod-dev/w5500/connect-manual-blocking/patch.cpp b/workspace/__lib__/xod-dev/w5500/connect-manual-blocking/patch.cpp new file mode 100644 index 00000000..072b1a6e --- /dev/null +++ b/workspace/__lib__/xod-dev/w5500/connect-manual-blocking/patch.cpp @@ -0,0 +1,51 @@ +{{#global}} +#include +#include +{{/global}} + +struct State { +}; + +{{ GENERATED_CODE }} + +void evaluate(Context ctx) { + if (!isInputDirty(ctx)) + return; + + auto dev = getValue(ctx); + Ethernet.init(dev.cs); + ValueType::T inet; + + auto ip = IPAddress(getValue(ctx)); + auto dns = IPAddress(getValue(ctx)); + auto gateway = IPAddress(getValue(ctx)); + auto subnet = IPAddress(getValue(ctx)); + + // if no DNS was provided + if((uint32_t)dns == 0) { + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + dns = ip; + dns[3] = 1; + } + + if((uint32_t)gateway == 0) { + gateway = ip; + gateway[3] = 1; + } + + if((uint32_t)subnet == 0) { + subnet = IPAddress(255,255,255,0); + } + +#if defined(WIZ550io_WITH_MACADDRESS) + Ethernet.begin(ip, dns, gateway, subnet); +#else + Ethernet.begin(dev.mac, ip, dns, gateway, subnet); +#endif + + inet.ip = (uint32_t)Ethernet.localIP(); + inet.isConnected = true; + emitValue(ctx, inet); + emitValue(ctx, 1); +} diff --git a/workspace/__lib__/xod-dev/w5500/connect-manual-blocking/patch.xodp b/workspace/__lib__/xod-dev/w5500/connect-manual-blocking/patch.xodp new file mode 100644 index 00000000..2287c6bf --- /dev/null +++ b/workspace/__lib__/xod-dev/w5500/connect-manual-blocking/patch.xodp @@ -0,0 +1,114 @@ +{ + "description": "Establish an internet connection configured manually", + "nodes": [ + { + "description": "The internet connection", + "id": "B1UUEfYMX", + "label": "INET", + "position": { + "x": 0, + "y": 204 + }, + "type": "@/output-inet" + }, + { + "id": "BkXLMdSIWm", + "position": { + "x": -1, + "y": 101 + }, + "type": "xod/patch-nodes/not-implemented-in-xod" + }, + { + "description": "Pulses on a successful connection", + "id": "H1ZLMdSLWQ", + "label": "DONE", + "position": { + "x": 102, + "y": 204 + }, + "type": "xod/patch-nodes/output-pulse" + }, + { + "description": "An IP address of the gateway. Defaults to `IP` with the last octet being `1`", + "id": "HyVxSMFzQ", + "label": "GTW", + "position": { + "x": 238, + "y": 0 + }, + "type": "xod/net/input-ip-address" + }, + { + "boundLiterals": { + "__out__": "On Boot" + }, + "description": "Establish the connection", + "id": "Syz8zur8WQ", + "label": "CONN", + "position": { + "x": 374, + "y": 0 + }, + "type": "xod/patch-nodes/input-pulse" + }, + { + "description": "A subnet mask. Defaults to `255.255.255.0`", + "id": "r1XbSzFz7", + "label": "SBN", + "position": { + "x": 306, + "y": 0 + }, + "type": "xod/net/input-ip-address" + }, + { + "id": "rk4aTAe7X", + "position": { + "x": 476, + "y": 0 + }, + "type": "xod/patch-nodes/utility" + }, + { + "description": "An IP address of the DNS server. Defaults to `IP` with the last octet being `1`", + "id": "rkZSNzKz7", + "label": "DNS", + "position": { + "x": 170, + "y": 0 + }, + "type": "xod/net/input-ip-address" + }, + { + "description": "Pulses if the connection failed", + "id": "rkgIz_SLW7", + "label": "ERR", + "position": { + "x": 204, + "y": 204 + }, + "type": "xod/patch-nodes/output-pulse" + }, + { + "description": "Own IP address", + "id": "rkuXdr8-Q", + "label": "IP", + "position": { + "x": 102, + "y": 0 + }, + "type": "xod/net/input-ip-address" + }, + { + "description": "A W5500-based internet provider device", + "id": "rygPuMYz7", + "label": "DEV", + "position": { + "x": -2, + "y": -2 + }, + "type": "@/input-ethernet-shield-device" + } + ] +} diff --git a/workspace/__lib__/xod-dev/w5500/connect-manual/patch.xodp b/workspace/__lib__/xod-dev/w5500/connect-manual/patch.xodp index 22380d99..acf0148b 100644 --- a/workspace/__lib__/xod-dev/w5500/connect-manual/patch.xodp +++ b/workspace/__lib__/xod-dev/w5500/connect-manual/patch.xodp @@ -1,5 +1,131 @@ { + "comments": [ + { + "content": "give everything else a chance to initialize before `connect` blocks execution", + "id": "r1NFR0e7X", + "position": { + "x": 306, + "y": 102 + }, + "size": { + "height": 51, + "width": 272 + } + } + ], "description": "Establish an internet connection configured manually", + "links": [ + { + "id": "BkVfCCxXX", + "input": { + "nodeId": "H1ZLMdSLWQ", + "pinKey": "__in__" + }, + "output": { + "nodeId": "HJ6-RRlQm", + "pinKey": "H1ZLMdSLWQ" + } + }, + { + "id": "ByFzCReX7", + "input": { + "nodeId": "HJ6-RRlQm", + "pinKey": "rkuXdr8-Q" + }, + "output": { + "nodeId": "rkuXdr8-Q", + "pinKey": "__out__" + } + }, + { + "id": "BykmARxm7", + "input": { + "nodeId": "HJ6-RRlQm", + "pinKey": "r1XbSzFz7" + }, + "output": { + "nodeId": "r1XbSzFz7", + "pinKey": "__out__" + } + }, + { + "id": "HJZVRAlX7", + "input": { + "nodeId": "HJ6-RRlQm", + "pinKey": "Syz8zur8WQ" + }, + "output": { + "nodeId": "BkhXCAlXQ", + "pinKey": "HJhXDIY9-" + } + }, + { + "id": "HyjG0CeQX", + "input": { + "nodeId": "HJ6-RRlQm", + "pinKey": "rkZSNzKz7" + }, + "output": { + "nodeId": "rkZSNzKz7", + "pinKey": "__out__" + } + }, + { + "id": "S11VCRxXQ", + "input": { + "nodeId": "BkhXCAlXQ", + "pinKey": "BJI7P8t9Z" + }, + "output": { + "nodeId": "Syz8zur8WQ", + "pinKey": "__out__" + } + }, + { + "id": "SkIGCAgmm", + "input": { + "nodeId": "rkgIz_SLW7", + "pinKey": "__in__" + }, + "output": { + "nodeId": "HJ6-RRlQm", + "pinKey": "rkgIz_SLW7" + } + }, + { + "id": "r1ffAAlm7", + "input": { + "nodeId": "B1UUEfYMX", + "pinKey": "__in__" + }, + "output": { + "nodeId": "HJ6-RRlQm", + "pinKey": "B1UUEfYMX" + } + }, + { + "id": "r1uf0CeX7", + "input": { + "nodeId": "HJ6-RRlQm", + "pinKey": "rygPuMYz7" + }, + "output": { + "nodeId": "rygPuMYz7", + "pinKey": "__out__" + } + }, + { + "id": "rypGCAxQX", + "input": { + "nodeId": "HJ6-RRlQm", + "pinKey": "HyVxSMFzQ" + }, + "output": { + "nodeId": "HyVxSMFzQ", + "pinKey": "__out__" + } + } + ], "nodes": [ { "description": "The internet connection", @@ -7,17 +133,17 @@ "label": "INET", "position": { "x": 0, - "y": 204 + "y": 306 }, "type": "@/output-inet" }, { - "id": "BkXLMdSIWm", + "id": "BkhXCAlXQ", "position": { - "x": -1, - "y": 101 + "x": 272, + "y": 102 }, - "type": "xod/patch-nodes/not-implemented-in-xod" + "type": "xod/core/defer" }, { "description": "Pulses on a successful connection", @@ -25,16 +151,24 @@ "label": "DONE", "position": { "x": 102, - "y": 204 + "y": 306 }, "type": "xod/patch-nodes/output-pulse" }, + { + "id": "HJ6-RRlQm", + "position": { + "x": 0, + "y": 204 + }, + "type": "@/connect-manual-blocking" + }, { "description": "An IP address of the gateway. Defaults to `IP` with the last octet being `1`", "id": "HyVxSMFzQ", "label": "GTW", "position": { - "x": 238, + "x": 204, "y": 0 }, "type": "xod/net/input-ip-address" @@ -47,7 +181,7 @@ "id": "Syz8zur8WQ", "label": "CONN", "position": { - "x": 374, + "x": 340, "y": 0 }, "type": "xod/patch-nodes/input-pulse" @@ -57,7 +191,7 @@ "id": "r1XbSzFz7", "label": "SBN", "position": { - "x": 306, + "x": 272, "y": 0 }, "type": "xod/net/input-ip-address" @@ -67,7 +201,7 @@ "id": "rkZSNzKz7", "label": "DNS", "position": { - "x": 170, + "x": 136, "y": 0 }, "type": "xod/net/input-ip-address" @@ -78,7 +212,7 @@ "label": "ERR", "position": { "x": 204, - "y": 204 + "y": 306 }, "type": "xod/patch-nodes/output-pulse" }, @@ -87,7 +221,7 @@ "id": "rkuXdr8-Q", "label": "IP", "position": { - "x": 102, + "x": 68, "y": 0 }, "type": "xod/net/input-ip-address" diff --git a/workspace/__lib__/xod-dev/w5500/connect/patch.xodp b/workspace/__lib__/xod-dev/w5500/connect/patch.xodp index 12b18543..e2e17fec 100644 --- a/workspace/__lib__/xod-dev/w5500/connect/patch.xodp +++ b/workspace/__lib__/xod-dev/w5500/connect/patch.xodp @@ -1,14 +1,88 @@ { - "description": "Establish an internet connection by automatically getting all required configuration info from a DHCP server", - "nodes": [ + "comments": [ { - "id": "BJXXLBwPfQ", + "content": "give everything else a chance to initialize before `connect` blocks execution", + "id": "S1T3RAg77", "position": { - "x": -1, - "y": 101 + "x": 102, + "y": 102 }, - "type": "xod/patch-nodes/not-implemented-in-xod" + "size": { + "height": 51, + "width": 272 + } + } + ], + "description": "Establish an internet connection by automatically getting all required configuration info from a DHCP server", + "links": [ + { + "id": "BJ-ApRx7m", + "input": { + "nodeId": "H1b7LrDPGm", + "pinKey": "__in__" + }, + "output": { + "nodeId": "rynaT0e7Q", + "pinKey": "H1b7LrDPGm" + } }, + { + "id": "BJSJRRl7Q", + "input": { + "nodeId": "rynaT0e7Q", + "pinKey": "BJfXLrPDzm" + }, + "output": { + "nodeId": "r1G10Al7X", + "pinKey": "HJhXDIY9-" + } + }, + { + "id": "H1QRTClQm", + "input": { + "nodeId": "ryx7LHwPfm", + "pinKey": "__in__" + }, + "output": { + "nodeId": "rynaT0e7Q", + "pinKey": "ryx7LHwPfm" + } + }, + { + "id": "HJU1CAxQm", + "input": { + "nodeId": "r1G10Al7X", + "pinKey": "BJI7P8t9Z" + }, + "output": { + "nodeId": "BJfXLrPDzm", + "pinKey": "__out__" + } + }, + { + "id": "HyxCp0x77", + "input": { + "nodeId": "rJ6H7ovfQ", + "pinKey": "__in__" + }, + "output": { + "nodeId": "rynaT0e7Q", + "pinKey": "rJ6H7ovfQ" + } + }, + { + "id": "SJ0ppAx7Q", + "input": { + "nodeId": "rynaT0e7Q", + "pinKey": "HkhKBPPfX" + }, + "output": { + "nodeId": "HkhKBPPfX", + "pinKey": "__out__" + } + } + ], + "nodes": [ { "boundLiterals": { "__out__": "On Boot" @@ -17,7 +91,7 @@ "id": "BJfXLrPDzm", "label": "CONN", "position": { - "x": 102, + "x": 68, "y": 0 }, "type": "xod/patch-nodes/input-pulse" @@ -27,8 +101,8 @@ "id": "H1b7LrDPGm", "label": "DONE", "position": { - "x": 102, - "y": 204 + "x": 68, + "y": 306 }, "type": "xod/patch-nodes/output-pulse" }, @@ -42,23 +116,39 @@ }, "type": "@/input-ethernet-shield-device" }, + { + "id": "r1G10Al7X", + "position": { + "x": 68, + "y": 102 + }, + "type": "xod/core/defer" + }, { "description": "An internet connection", "id": "rJ6H7ovfQ", "label": "INET", "position": { "x": 0, - "y": 204 + "y": 306 }, "type": "@/output-inet" }, + { + "id": "rynaT0e7Q", + "position": { + "x": 0, + "y": 204 + }, + "type": "@/connect-blocking" + }, { "description": "Pulses if the connection failed", "id": "ryx7LHwPfm", "label": "ERR", "position": { - "x": 204, - "y": 204 + "x": 136, + "y": 306 }, "type": "xod/patch-nodes/output-pulse" } diff --git a/workspace/__lib__/xod-dev/w5500/example-get-data-from-dweet/patch.xodp b/workspace/__lib__/xod-dev/w5500/example-get-data-from-dweet/patch.xodp index 9c20f1a2..0257decb 100644 --- a/workspace/__lib__/xod-dev/w5500/example-get-data-from-dweet/patch.xodp +++ b/workspace/__lib__/xod-dev/w5500/example-get-data-from-dweet/patch.xodp @@ -11,18 +11,6 @@ "height": 51, "width": 442 } - }, - { - "content": "`connect-dhcp` is blocking.\nGive lcd-display a chance to update", - "id": "SJdsubtwM7", - "position": { - "x": 306, - "y": 204 - }, - "size": { - "height": 51, - "width": 204 - } } ], "links": [ @@ -92,17 +80,6 @@ "pinKey": "ryx7LHwPfm" } }, - { - "id": "By8s_WFDGX", - "input": { - "nodeId": "SJQsuZKDMX", - "pinKey": "BJfXLrPDzm" - }, - "output": { - "nodeId": "HkZiObFPfm", - "pinKey": "HJhXDIY9-" - } - }, { "id": "ByemSsPGX", "input": { @@ -147,17 +124,6 @@ "pinKey": "rkWHDAW_f" } }, - { - "id": "HkNsuWtvzQ", - "input": { - "nodeId": "HkZiObFPfm", - "pinKey": "BJI7P8t9Z" - }, - "output": { - "nodeId": "Hysd-tDzX", - "pinKey": "ryVmUAOrvkb" - } - }, { "id": "HyNbTY7G7", "input": { @@ -493,14 +459,6 @@ }, "type": "xod/net/mac-address" }, - { - "id": "HkZiObFPfm", - "position": { - "x": 272, - "y": 204 - }, - "type": "xod/core/defer" - }, { "boundLiterals": { "B1TSE9tZ-": "\"IP:\"", @@ -514,14 +472,6 @@ }, "type": "xod/common-hardware/text-lcd-16x2-i2c" }, - { - "id": "Hysd-tDzX", - "position": { - "x": 408, - "y": 102 - }, - "type": "xod/core/boot" - }, { "id": "SJQsuZKDMX", "position": { diff --git a/workspace/__lib__/xod-dev/w5500/example-get-your-ip/patch.xodp b/workspace/__lib__/xod-dev/w5500/example-get-your-ip/patch.xodp index ddb986d1..91936f21 100644 --- a/workspace/__lib__/xod-dev/w5500/example-get-your-ip/patch.xodp +++ b/workspace/__lib__/xod-dev/w5500/example-get-your-ip/patch.xodp @@ -1,18 +1,4 @@ { - "comments": [ - { - "content": "`connect-dhcp` is blocking.\nGive lcd display a chance to update", - "id": "B1iWF68KRZQ", - "position": { - "x": 306, - "y": 102 - }, - "size": { - "height": 51, - "width": 204 - } - } - ], "links": [ { "id": "B1VFPoR-Q", @@ -25,17 +11,6 @@ "pinKey": "SkSGwoAZQ" } }, - { - "id": "B1xhSDDMm", - "input": { - "nodeId": "SJoiSDPz7", - "pinKey": "BJfXLrPDzm" - }, - "output": { - "nodeId": "rJOKpUF0WQ", - "pinKey": "HJhXDIY9-" - } - }, { "id": "BJmhHPPfQ", "input": { @@ -212,17 +187,6 @@ "pinKey": "S1yaHC6UW" } }, - { - "id": "rJfxFpUFC-m", - "input": { - "nodeId": "rJOKpUF0WQ", - "pinKey": "BJI7P8t9Z" - }, - "output": { - "nodeId": "ByZYpUKAZX", - "pinKey": "ryVmUAOrvkb" - } - }, { "id": "rk-4ltPGQ", "input": { @@ -312,14 +276,6 @@ }, "type": "xod/common-hardware/text-lcd-16x2-i2c" }, - { - "id": "ByZYpUKAZX", - "position": { - "x": 408, - "y": 0 - }, - "type": "xod/core/boot" - }, { "boundLiterals": { "S1a8PX0Wm": "On Boot", @@ -444,14 +400,6 @@ "y": 0 }, "type": "xod/net/mac-address" - }, - { - "id": "rJOKpUF0WQ", - "position": { - "x": 272, - "y": 102 - }, - "type": "xod/core/defer" } ] }