|
38 | 38 |
|
39 | 39 | #define STRINGIFY(s) #s
|
40 | 40 |
|
41 |
| -//Select network stack mode: IPv4 or IPv6 |
42 |
| -M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv4; |
| 41 | +#if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true) |
| 42 | + // Mesh is always IPV6 - also WiFi and ETH can be IPV6 if IPV6 is enabled |
| 43 | + M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv6; |
| 44 | +#else |
| 45 | + // Everything else - we assume it's IPv4 |
| 46 | + M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv4; |
| 47 | +#endif |
43 | 48 |
|
44 |
| -//Select binding mode: UDP or TCP |
45 |
| -M2MInterface::BindingMode SOCKET_MODE = M2MInterface::TCP; |
| 49 | +//Select binding mode: UDP or TCP -- note - Mesh networking is IPv6 UDP ONLY |
| 50 | +#ifdef MESH |
| 51 | + M2MInterface::BindingMode SOCKET_MODE = M2MInterface::UDP; |
| 52 | +#else |
| 53 | + // WiFi or Ethernet supports both - TCP by default to avoid |
| 54 | + // NAT problems, but UDP will also work - IF you configure |
| 55 | + // your network right. |
| 56 | + M2MInterface::BindingMode SOCKET_MODE = M2MInterface::TCP; |
| 57 | +#endif |
46 | 58 |
|
47 | 59 |
|
48 | 60 | // MBED_DOMAIN and MBED_ENDPOINT_NAME come
|
@@ -107,13 +119,6 @@ class MbedClient: public M2MInterfaceObserver {
|
107 | 119 | _server_address = server_address;
|
108 | 120 | uint16_t port = rand() % 65535 + 12345;
|
109 | 121 |
|
110 |
| - // In case of Mesh or Thread use M2MInterface::Nanostack_IPv6 |
111 |
| -#if MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND |
112 |
| - NETWORK_STACK = M2MInterface::Nanostack_IPv6; |
113 |
| -#elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD |
114 |
| - NETWORK_STACK = M2MInterface::Nanostack_IPv6; |
115 |
| -#endif |
116 |
| - |
117 | 122 | // create mDS interface object, this is the base object everything else attaches to
|
118 | 123 | _interface = M2MInterfaceFactory::create_interface(*this,
|
119 | 124 | MBED_ENDPOINT_NAME, // endpoint name string
|
|
0 commit comments