Nanostack Border Router is a generic mbed border router implementation that provides the 6LoWPAN ND or Thread border router initialization logic.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Thu Sep 26 10:02:16 2019 +0100
Parent:
104:bffd39796f7c
Child:
106:742475d45e8c
Commit message:
Merge branch 'mbed-os-5.14'

* mbed-os-5.14:
Updating mbed-os to mbed-os-5.14.0-rc3
Set extended heap on use to border router cell configuration
Added support for Cellular PPP interface
Edit README.md
Remove unnecessary checks
Enable extended heap for Wi-SUN
Updating mbed-os to mbed-os-5.14.0-rc1

.
Commit copied from https://github.com/ARMmbed/nanostack-border-router

Changed in this revision

README.md Show annotated file Show diff for this revision Revisions of this file
configs/6lowpan_Atmel_RF.json Show annotated file Show diff for this revision Revisions of this file
configs/6lowpan_Spirit1_RF.json Show annotated file Show diff for this revision Revisions of this file
configs/Thread_Atmel_RF.json Show annotated file Show diff for this revision Revisions of this file
configs/Thread_SLIP_Atmel_RF.json Show annotated file Show diff for this revision Revisions of this file
configs/Wisun_Stm_s2lp_RF.json Show annotated file Show diff for this revision Revisions of this file
configs/Wisun_Stm_s2lp_RF_cell.json Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
source/border_router_main.cpp Show annotated file Show diff for this revision Revisions of this file
source/borderrouter_ws.c Show annotated file Show diff for this revision Revisions of this file
source/nanostack_heap_region.c Show annotated file Show diff for this revision Revisions of this file
source/nanostack_heap_region.h Show annotated file Show diff for this revision Revisions of this file
--- a/README.md	Thu Sep 12 08:02:13 2019 +0100
+++ b/README.md	Thu Sep 26 10:02:16 2019 +0100
@@ -2,7 +2,7 @@
 
 Nanostack Border Router is a generic Mbed border router implementation that provides the 6LoWPAN ND, Thread or Wi-SUN border router initialization logic.
 
-A border router is a network gateway between a wireless 6LoWPAN mesh network and a backhaul network. It controls and relays traffic between the two networks. In a typical setup, a 6LoWPAN border router is connected to another router in the backhaul network (over Ethernet or a serial line) which in turn forwards traffic to and from the internet or a private company LAN, for instance.
+A border router is a network gateway between a wireless 6LoWPAN mesh network and a backhaul network. It controls and relays traffic between the two networks. In a typical setup, a 6LoWPAN border router is connected to another router in the backhaul network (over Ethernet, Cellular or a serial line) which in turn forwards traffic to and from the internet or a private company LAN, for instance.
 
 ![](images/br_role.png)
 
@@ -75,7 +75,7 @@
 
 * [STM Spirit1](https://github.com/ARMmbed/stm-spirit1-rf-driver).
 
-The backhaul is either SLIP or Ethernet. For Ethernet either an Mbed OS "EMAC" driver can be used, or a native Nanostack driver. Currently, native Nanostack drivers exists for the following backhauls:
+The backhaul is either SLIP, Ethernet or Cellular. For Ethernet either an Mbed OS "EMAC" driver can be used, or a native Nanostack driver. Currently, native Nanostack drivers exists for the following backhauls:
 
 * [K64F Ethernet](https://github.com/ARMmbed/sal-nanostack-driver-k64f-eth).
 * [SLIP driver](https://github.com/ARMmbed/sal-stack-nanostack-slip).
@@ -182,12 +182,12 @@
 
 #### Backhaul connectivity
 
-The Nanostack border router application can be connected to a backhaul network. This enables you to connect the devices in a 6LoWPAN mesh network to the internet or a private LAN. The application supports SLIP (IPv6 encapsulation over a serial line) and Ethernet backhaul connectivity:
+The Nanostack border router application can be connected to a backhaul network. This enables you to connect the devices in a 6LoWPAN mesh network to the internet or a private LAN. The application supports SLIP (IPv6 encapsulation over a serial line), Ethernet and Cellular backhaul connectivity:
 
 ```
 "config": {
     "backhaul-driver": {
-        "help": "options are ETH, SLIP, EMAC",
+        "help": "options are ETH, SLIP, EMAC, CELL",
         "value": "EMAC"
     },
     "backhaul-mac-src": {
@@ -203,7 +203,7 @@
 }
 ```
 
-You can select your preferred option through the configuration file (field `backhaul-driver` in the `config` section). The value `SLIP` includes the SLIP driver, and the value `ETH` compiles the border router application with Nanostack native Ethernet backhaul support. `EMAC` uses the board's default Mbed OS network driver, which must be EMAC-based (derived from EMACInterface).
+You can select your preferred option through the configuration file (field `backhaul-driver` in the `config` section). The value `SLIP` includes the SLIP driver, and the value `ETH` compiles the border router application with Nanostack native Ethernet backhaul support. `EMAC` uses the board's default Mbed OS network driver, which must be EMAC-based (derived from EMACInterface). `CELL` uses the boards's default Mbed OS cellular device or external cellular device that is configured to provide the default cellular device.
 
 You can define the MAC address on the backhaul interface manually (field `backhaul-mac-src` value `CONFIG`). Alternatively, you can use the MAC address provided by the development board (field `backhaul-mac-src` value `BOARD`). By default, the backhaul driver is set to `EMAC` and the MAC address source is `BOARD`.
 
@@ -213,6 +213,8 @@
 
 When using the autonomous mode in the 6LoWPAN ND configuration, you can set the `prefix-from-backhaul` option to `true` to use the same backhaul prefix on the mesh network side as well. This allows the mesh nodes to be directly connectable from the outside of the mesh network. In the Thread network, it is enough that `backhaul-dynamic-bootstrap` is set to true.
 
+For `CELL` backhaul, no configuration options for addresses are provided. Cellular backhaul device works always in autonomous mode and the border router learns the IPv6 prefix information from the cellular access.
+
 #### Note on the SLIP backhaul driver
 
 If you are using a K64F board, use the UART1 serial line of the board with the SLIP driver. See the `pins` section in the [mbed_app.json](./mbed_app.json) configuration file. To use a different UART line, replace the `SERIAL_TX` and `SERIAL_RX` values with correct TX/RX pin names.
@@ -241,6 +243,10 @@
 
 To use Wi-Fi or other more complex EMAC drivers, necessary configuration parameters must be supplied, either using `mbed_app.json` or configuration in the `NetworkInterface::get_default_instance` override. Also, the driver must follow the guidelines of `EMACInterface` - the border router does not call the `EMACInterface`'s `connect` method, so the driver must work with only a `powerup` call to the `EMAC`.
 
+#### Note on CELL backhaul
+
+When `backhaul_driver` is set to `CELL`, the border router will use the target's default cellular device, as supplied by `CellularInterface::get_default_instance`. Cellular device must support IPv6 PPP connection mode. Board must supply the default Mbed OS cellular device or there must be an external cellular device that is configured to provide default cellular device to Mbed OS.
+
 ### Switching the RF shield
 
 By default, the application uses an Atmel AT86RF233/212B RF driver. You can alternatively use any RF driver provided in the `drivers/` folder or link in your own driver. You can set the configuration for the RF driver in the `json` file.
--- a/configs/6lowpan_Atmel_RF.json	Thu Sep 12 08:02:13 2019 +0100
+++ b/configs/6lowpan_Atmel_RF.json	Thu Sep 26 10:02:16 2019 +0100
@@ -1,15 +1,11 @@
 {
     "config": {
-        "heap-size": {
-             "help": "The amount of static RAM to reserve for nsdynmemlib heap",
-             "value": 40000
-        },
         "radio-type":{
             "help": "options are ATMEL, MCR20, SPIRIT1",
             "value": "ATMEL"
         },
         "backhaul-driver": {
-            "help": "options are ETH, SLIP, EMAC",
+            "help": "options are ETH, SLIP, EMAC, CELL",
             "value": "EMAC"
         },
         "mesh-mode": {
@@ -24,6 +20,10 @@
             "help": "Enable proxying Multicast Listener Discovery messages to backhaul network",
             "value": "false"
         },
+        "nanostack_extended_heap": {
+            "help": "Add additional memory region to nanostack heap. Valid only for selected platforms. Region size may vary depending of the toolchain.",
+            "value": false
+        },
         "backhaul-mac": "{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}",
         "slip_hw_flow_control": "false",
         "slip_serial_baud_rate": "921600",
@@ -74,7 +74,9 @@
             "nanostack.configuration": "lowpan_border_router",
             "platform.stdio-convert-newlines": true,
             "platform.stdio-baud-rate": 115200,
-            "mbed-mesh-api.use-malloc-for-heap": true
+            "mbed-mesh-api.heap-size": 40000,
+            "mbed-mesh-api.heap-stat-info": "&memory_heap_stat",
+            "mbed-mesh-api.heap-stat-info-definition": "mem_stat_t memory_heap_stat;"
         },
         "K64F": {
             "LED": "LED_GREEN",
--- a/configs/6lowpan_Spirit1_RF.json	Thu Sep 12 08:02:13 2019 +0100
+++ b/configs/6lowpan_Spirit1_RF.json	Thu Sep 26 10:02:16 2019 +0100
@@ -1,15 +1,11 @@
 {
     "config": {
-        "heap-size": {
-             "help": "The amount of static RAM to reserve for nsdynmemlib heap",
-             "value": 40000
-        },
         "radio-type":{
             "help": "options are ATMEL, MCR20, SPIRIT1",
             "value": "SPIRIT1"
         },
         "backhaul-driver": {
-            "help": "options are ETH, SLIP, EMAC",
+            "help": "options are ETH, SLIP, EMAC, CELL",
             "value": "EMAC"
         },
         "mesh-mode": {
@@ -24,6 +20,10 @@
             "help": "Enable proxying Multicast Listener Discovery messages to backhaul network",
             "value": "false"
         },
+        "nanostack_extended_heap": {
+            "help": "Add additional memory region to nanostack heap. Valid only for selected platforms. Region size may vary depending of the toolchain.",
+            "value": false
+        },
         "backhaul-mac": "{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}",
         "slip_hw_flow_control": "false",
         "slip_serial_baud_rate": "921600",
@@ -75,9 +75,11 @@
             "nanostack.configuration": "lowpan_border_router",
             "platform.stdio-convert-newlines": true,
             "platform.stdio-baud-rate": 115200,
+            "mbed-mesh-api.heap-size": 40000,
+            "mbed-mesh-api.heap-stat-info": "&memory_heap_stat",
+            "mbed-mesh-api.heap-stat-info-definition": "mem_stat_t memory_heap_stat;",
             "kinetis-emac.tx-ring-len":4,
-            "kinetis-emac.rx-ring-len":4,
-            "mbed-mesh-api.use-malloc-for-heap": true
+            "kinetis-emac.rx-ring-len":4
         },
         "NUCLEO_F429ZI": {
             "LED": "LED1",
--- a/configs/Thread_Atmel_RF.json	Thu Sep 12 08:02:13 2019 +0100
+++ b/configs/Thread_Atmel_RF.json	Thu Sep 26 10:02:16 2019 +0100
@@ -1,15 +1,11 @@
 {
     "config": {
-        "heap-size": {
-             "help": "The amount of static RAM to reserve for nsdynmemlib heap",
-             "value": 65535
-        },
         "radio-type":{
             "help": "options are ATMEL, MCR20",
             "value": "ATMEL"
         },
         "backhaul-driver": {
-            "help": "options are ETH, SLIP, EMAC",
+            "help": "options are ETH, SLIP, EMAC, CELL",
             "value": "EMAC"
         },
         "mesh-mode": {
@@ -24,6 +20,10 @@
             "help": "Enable proxying Multicast Listener Discovery messages to backhaul network",
             "value": "false"
         },
+        "nanostack_extended_heap": {
+            "help": "Add additional memory region to nanostack heap. Valid only for selected platforms. Region size may vary depending of the toolchain.",
+            "value": false
+        },
         "backhaul-mac": "{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}",
         "rf-channel": 22,
         "rf-channel-page": 0,
@@ -58,7 +58,9 @@
             "nanostack.configuration": "thread_border_router",
             "platform.stdio-convert-newlines": true,
             "platform.stdio-baud-rate": 115200,
-            "mbed-mesh-api.use-malloc-for-heap": true
+            "mbed-mesh-api.heap-size": 65535,
+            "mbed-mesh-api.heap-stat-info": "&memory_heap_stat",
+            "mbed-mesh-api.heap-stat-info-definition": "mem_stat_t memory_heap_stat;"
         },
         "K64F": {
             "LED": "LED_GREEN",
--- a/configs/Thread_SLIP_Atmel_RF.json	Thu Sep 12 08:02:13 2019 +0100
+++ b/configs/Thread_SLIP_Atmel_RF.json	Thu Sep 26 10:02:16 2019 +0100
@@ -1,15 +1,11 @@
 {
     "config": {
-        "heap-size": {
-             "help": "The amount of static RAM to reserve for nsdynmemlib heap",
-             "value": 65535
-        },
         "radio-type":{
             "help": "options are ATMEL, MCR20",
             "value": "ATMEL"
         },
         "backhaul-driver": {
-            "help": "options are ETH, SLIP, EMAC",
+            "help": "options are ETH, SLIP, EMAC, CELL",
             "value": "SLIP"
         },
         "mesh-mode": {
@@ -24,6 +20,10 @@
             "help": "Enable proxying Multicast Listener Discovery messages to backhaul network",
             "value": "false"
         },
+        "nanostack_extended_heap": {
+            "help": "Add additional memory region to nanostack heap. Valid only for selected platforms. Region size may vary depending of the toolchain.",
+            "value": false
+        },
         "backhaul-mac": "{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}",
         "slip_hw_flow_control": "true",
         "slip_serial_baud_rate": "921600",
@@ -60,7 +60,9 @@
             "nanostack.configuration": "thread_border_router",
             "platform.stdio-convert-newlines": true,
             "platform.stdio-baud-rate": 115200,
-            "mbed-mesh-api.use-malloc-for-heap": true
+            "mbed-mesh-api.heap-size": 65535,
+            "mbed-mesh-api.heap-stat-info": "&memory_heap_stat",
+            "mbed-mesh-api.heap-stat-info-definition": "mem_stat_t memory_heap_stat;"
         },
         "K64F": {
             "LED": "LED_GREEN",
--- a/configs/Wisun_Stm_s2lp_RF.json	Thu Sep 12 08:02:13 2019 +0100
+++ b/configs/Wisun_Stm_s2lp_RF.json	Thu Sep 26 10:02:16 2019 +0100
@@ -1,15 +1,11 @@
 {
     "config": {
-        "heap-size": {
-             "help": "The amount of static RAM to reserve for nsdynmemlib heap",
-             "value": 100000
-        },
         "radio-type":{
             "help": "options are ATMEL, MCR20, SPIRIT1, S2LP",
             "value": "S2LP"
         },
         "backhaul-driver": {
-            "help": "options are ETH, SLIP, EMAC",
+            "help": "options are ETH, SLIP, EMAC, CELL",
             "value": "EMAC"
         },
         "mesh-mode": {
@@ -24,8 +20,12 @@
             "help": "Enable proxying Multicast Listener Discovery messages to backhaul network",
             "value": "false"
         },
+        "nanostack_extended_heap": {
+            "help": "Add additional memory region to nanostack heap. Valid only for selected platforms. Region size may vary depending of the toolchain.",
+            "value": true
+        },
         "backhaul-mac": "{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}",
-        "debug-trace": "false",
+        "debug-trace": "true",
         "backhaul-dynamic-bootstrap": true,
         "backhaul-prefix": "\"fd00:db8:ff1::\"",
         "backhaul-default-route": "\"::/0\"",
@@ -71,8 +71,10 @@
             "nanostack.configuration": "ws_border_router",
             "platform.stdio-convert-newlines": true,
             "platform.stdio-baud-rate": 115200,
-            "platform.stdio-buffered-serial": true,
-            "mbed-mesh-api.use-malloc-for-heap": true
+            "mbed-mesh-api.heap-size": 65535,
+            "mbed-mesh-api.heap-stat-info": "&memory_heap_stat",
+            "mbed-mesh-api.heap-stat-info-definition": "mem_stat_t memory_heap_stat;",
+            "platform.stdio-buffered-serial": true
         },
         "K64F": {
             "kinetis-emac.tx-ring-len":4,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/Wisun_Stm_s2lp_RF_cell.json	Thu Sep 26 10:02:16 2019 +0100
@@ -0,0 +1,100 @@
+{
+    "config": {
+        "radio-type":{
+            "help": "options are ATMEL, MCR20, SPIRIT1, S2LP",
+            "value": "S2LP"
+        },
+        "backhaul-driver": {
+            "help": "options are ETH, SLIP, EMAC, CELL",
+            "value": "CELL"
+        },
+        "mesh-mode": {
+            "help": "Mesh networking mode. Options are LOWPAN_ND, LOWPAN_WS and THREAD",
+            "value": "LOWPAN_WS"
+        },
+        "backhaul-mac-src": {
+            "help": "Where to get EUI48 address. Options are BOARD, CONFIG",
+            "value": "BOARD"
+        },
+        "backhaul-mld": {
+            "help": "Enable proxying Multicast Listener Discovery messages to backhaul network",
+            "value": "false"
+        },
+        "nanostack_extended_heap": {
+            "help": "Add additional memory region to nanostack heap. Valid only for selected platforms. Region size may vary depending of the toolchain.",
+            "value": true
+        },        
+        "backhaul-mac": "{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}",
+        "debug-trace": "true",
+        "backhaul-dynamic-bootstrap": true,
+        "backhaul-prefix": "\"fd00:db8:ff1::\"",
+        "backhaul-default-route": "\"::/0\"",
+        "backhaul-next-hop": "\"fe80::1\"",
+        "multicast-addr": "ff05::7",
+        "LED": "NC",
+        "SERIAL_TX": "NC",
+        "SERIAL_RX": "NC",
+        "SERIAL_CTS": "NC",
+        "SERIAL_RTS": "NC",
+        "uc-channel-function": 255,
+        "bc-channel-function": 255,
+        "regulatory-domain": 3,
+        "operating-class": 255,
+        "operating-mode": 255,
+        "uc-fixed-channel": "0xffff",
+        "bc-fixed-channel": "0xffff",
+        "network-name": "\"Wi-SUN Network\"",
+        "certificate-header": {
+            "help": "Certificate header",
+            "value": "\"wisun_certificates.h\""
+        },
+        "root-certificate": {
+            "help": "Root certificate in PEM format (must be a null terminated c-string)",
+            "value": "WISUN_ROOT_CERTIFICATE"
+        },
+        "own-certificate": {
+            "help": "Own certificate in PEM format (must be a null terminated c-string)",
+            "value": "WISUN_SERVER_CERTIFICATE"
+        },
+        "own-certificate-key": {
+            "help": "Own certificate's key in PEM format (must be a null terminated c-string)",
+            "value": "WISUN_SERVER_KEY"
+        }
+    },
+    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"source/mbedtls_wisun_config.h\""],    
+    "target_overrides": {
+        "*": {
+            "nsapi.default-stack": "NANOSTACK",
+            "mbed-trace.enable": 1,
+            "nanostack.configuration": "ws_border_router",
+            "platform.stdio-convert-newlines": true,
+            "platform.stdio-baud-rate": 115200,
+            "mbed-mesh-api.heap-size": 65535,
+            "mbed-mesh-api.heap-stat-info": "&memory_heap_stat",
+            "mbed-mesh-api.heap-stat-info-definition": "mem_stat_t memory_heap_stat;",
+            "platform.stdio-buffered-serial": true,
+            "ppp.enabled": true,
+            "ppp.ipv4-enabled": false,
+            "ppp.ipv6-enabled": true,
+            "nsapi.default-cellular-plmn": 0,
+            "nsapi.default-cellular-sim-pin": null,
+            "nsapi.default-cellular-apn": 0,
+            "nsapi.default-cellular-username": 0,
+            "nsapi.default-cellular-password": 0,
+            "cellular.debug-at": false,
+            "QUECTEL_EC2X.provide-default": true,
+            "QUECTEL_EC2X.tx": "D1",
+            "QUECTEL_EC2X.rx": "D0",
+            "QUECTEL_EC2X.pwr": "D2",
+            "QUECTEL_EC2X.rst": "D4"
+        },
+        "K64F": {
+            "kinetis-emac.tx-ring-len":4,
+            "kinetis-emac.rx-ring-len":4
+        },
+        "K66F": {
+            "kinetis-emac.tx-ring-len":4,
+            "kinetis-emac.rx-ring-len":4
+        }
+    }
+}
--- a/mbed-os.lib	Thu Sep 12 08:02:13 2019 +0100
+++ b/mbed-os.lib	Thu Sep 26 10:02:16 2019 +0100
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#1bf6b20df9d3cd5f29f001ffc6f0d0fcbbb96118
+https://github.com/ARMmbed/mbed-os/#b6e5a0a8afa34dec9dae8963778aebce0c82a54b
--- a/mbed_app.json	Thu Sep 12 08:02:13 2019 +0100
+++ b/mbed_app.json	Thu Sep 26 10:02:16 2019 +0100
@@ -1,9 +1,5 @@
 {
     "config": {
-        "heap-size": {
-             "help": "The amount of static RAM to reserve for nsdynmemlib heap",
-             "value": 40000
-        },
         "radio-type":{
             "help": "options are ATMEL, MCR20, SPIRIT1",
             "value": "ATMEL"
@@ -20,6 +16,10 @@
             "help": "Where to get EUI48 address. Options are BOARD, CONFIG",
             "value": "BOARD"
         },
+        "nanostack_extended_heap": {
+            "help": "Add additional memory region to nanostack heap. Valid only for selected platforms. Region size may vary depending of the toolchain.",
+            "value": false
+        },
         "backhaul-mac": "{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}",
         "slip_hw_flow_control": "false",
         "slip_serial_baud_rate": "921600",
@@ -70,7 +70,9 @@
             "nanostack.configuration": "lowpan_border_router",
             "platform.stdio-convert-newlines": true,
             "platform.stdio-baud-rate": 115200,
-            "mbed-mesh-api.use-malloc-for-heap": true
+            "mbed-mesh-api.heap-size": 40000,
+            "mbed-mesh-api.heap-stat-info": "&memory_heap_stat",
+            "mbed-mesh-api.heap-stat-info-definition": "mem_stat_t memory_heap_stat;"
         },
         "K64F": {
             "LED": "LED_GREEN",
--- a/source/border_router_main.cpp	Thu Sep 12 08:02:13 2019 +0100
+++ b/source/border_router_main.cpp	Thu Sep 26 10:02:16 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 ARM Limited. All rights reserved.
+ * Copyright (c) 2016-2019 ARM Limited. All rights reserved.
  */
 
 #include <string.h>
@@ -16,6 +16,21 @@
 #include "EMACInterface.h"
 #include "EMAC.h"
 
+#undef ETH
+#undef SLIP
+#undef EMAC
+#undef CELL
+#define ETH 1
+#define SLIP 2
+#define EMAC 3
+#define CELL 4
+
+#if MBED_CONF_APP_BACKHAUL_DRIVER == CELL
+#include "NanostackPPPInterface.h"
+#include "PPPInterface.h"
+#include "PPP.h"
+#endif
+
 #ifdef  MBED_CONF_APP_DEBUG_TRACE
 #if MBED_CONF_APP_DEBUG_TRACE == 1
 #define APP_TRACE_LEVEL TRACE_ACTIVE_LEVEL_DEBUG
@@ -28,15 +43,11 @@
 #include "mesh_system.h"
 #include "cmsis_os.h"
 #include "arm_hal_interrupt.h"
-
+#include "nanostack_heap_region.h"
 
 #include "mbed_trace.h"
 #define TRACE_GROUP "app"
 
-#define APP_DEFINED_HEAP_SIZE MBED_CONF_APP_HEAP_SIZE
-static uint8_t app_stack_heap[APP_DEFINED_HEAP_SIZE];
-static mem_stat_t heap_info;
-
 #define BOARD 1
 #define CONFIG 2
 #if MBED_CONF_APP_BACKHAUL_MAC_SRC == BOARD
@@ -51,8 +62,6 @@
 
 static Ticker led_ticker;
 
-static void app_heap_error_handler(heap_fail_t event);
-
 static void toggle_led1()
 {
     led1 = !led1;
@@ -66,12 +75,6 @@
     printf("%s\n", str);
 }
 
-#undef ETH
-#undef SLIP
-#undef EMAC
-#define ETH 1
-#define SLIP 2
-#define EMAC 3
 #if MBED_CONF_APP_BACKHAUL_DRIVER == EMAC
 static void (*emac_actual_cb)(uint8_t, int8_t);
 static int8_t emac_driver_id;
@@ -149,6 +152,40 @@
         emac_driver_id = ns_if->get_driver_id();
         emac.set_link_state_cb(emac_link_cb);
     }
+#elif MBED_CONF_APP_BACKHAUL_DRIVER == CELL
+    tr_info("Using CELLULAR backhaul driver...");
+    /* Creates PPP service and onboard network stack already here for cellular
+     * connection to be able to override the link state changed callback */
+    PPP *ppp = &PPP::get_default_instance();
+    if (!ppp) {
+        tr_error("PPP not found");
+        exit(1);
+    }
+    OnboardNetworkStack *stack = &OnboardNetworkStack::get_default_instance();
+    if (!stack) {
+        tr_error("Onboard network stack not found");
+        exit(1);
+    }
+    OnboardNetworkStack::Interface *interface;
+    if (stack->add_ppp_interface(*ppp, true, &interface) != NSAPI_ERROR_OK) {
+        tr_error("Cannot add PPP interface");
+        exit(1);
+    }
+    Nanostack::PPPInterface *ns_if = static_cast<Nanostack::PPPInterface *>(interface);
+    ns_if->set_link_state_changed_callback(backhaul_driver_status_cb);
+
+    // Cellular interface configures it to PPP service and onboard stack created above
+    CellularInterface *net = CellularInterface::get_default_instance();
+    if (!net) {
+        tr_error("Default cellular interface not found");
+        exit(1);
+    }
+    net->set_default_parameters(); // from cellular nsapi .json configuration
+    net->set_blocking(false);
+    if (net->connect() != NSAPI_ERROR_OK) {
+        tr_error("Connect failure");
+        exit(1);
+    }
 #elif MBED_CONF_APP_BACKHAUL_DRIVER == ETH
     tr_info("Using ETH backhaul driver...");
     arm_eth_phy_device_register(mac, backhaul_driver_status_cb);
@@ -156,9 +193,10 @@
 #else
 #error "Unsupported backhaul driver"
 #endif
+#undef ETH
 #undef SLIP
-#undef ETH
 #undef EMAC
+#undef CELL
 }
 
 
@@ -191,8 +229,6 @@
  */
 int main(int argc, char **argv)
 {
-    ns_hal_init(app_stack_heap, APP_DEFINED_HEAP_SIZE, app_heap_error_handler, &heap_info);
-
     mbed_trace_init(); // set up the tracing library
     mbed_trace_print_function_set(trace_printer);
     mbed_trace_config_set(TRACE_MODE_COLOR | APP_TRACE_LEVEL | TRACE_CARRIAGE_RETURN);
@@ -201,6 +237,8 @@
     // Nanostack::add_ethernet_interface()
     mesh_system_init();
 
+    nanostack_heap_region_add();
+
 #if MBED_CONF_APP_BACKHAUL_MAC_SRC == BOARD
     mbed_mac_address((char *)mac);
 #endif
@@ -210,31 +248,3 @@
     }
     border_router_tasklet_start();
 }
-
-/**
- * \brief Error handler for errors in dynamic memory handling.
- */
-static void app_heap_error_handler(heap_fail_t event)
-{
-    tr_error("Dyn mem error %x", (int8_t)event);
-
-    switch (event) {
-        case NS_DYN_MEM_NULL_FREE:
-            break;
-        case NS_DYN_MEM_DOUBLE_FREE:
-            break;
-        case NS_DYN_MEM_ALLOCATE_SIZE_NOT_VALID:
-            break;
-        case NS_DYN_MEM_POINTER_NOT_VALID:
-            break;
-        case NS_DYN_MEM_HEAP_SECTOR_CORRUPTED:
-            break;
-        case NS_DYN_MEM_HEAP_SECTOR_UNITIALIZED:
-            break;
-        default:
-            break;
-    }
-
-    while (1);
-}
-
--- a/source/borderrouter_ws.c	Thu Sep 12 08:02:13 2019 +0100
+++ b/source/borderrouter_ws.c	Thu Sep 26 10:02:16 2019 +0100
@@ -71,7 +71,7 @@
 
 typedef struct {
     int8_t  ws_interface_id;
-    int8_t  eth_interface_id;
+    int8_t  net_interface_id;
 } ws_br_handler_t;
 
 static ws_br_handler_t ws_br_handler;
@@ -255,8 +255,8 @@
         }
 
         if (ws_br_handler.ws_interface_id > -1 &&
-                ws_br_handler.eth_interface_id > -1) {
-            ws_bbr_start(ws_br_handler.ws_interface_id, ws_br_handler.eth_interface_id);
+                ws_br_handler.net_interface_id > -1) {
+            ws_bbr_start(ws_br_handler.ws_interface_id, ws_br_handler.net_interface_id);
         }
     }
 }
@@ -335,7 +335,7 @@
 void border_router_tasklet_start(void)
 {
     ws_br_handler.ws_interface_id = -1;
-    ws_br_handler.eth_interface_id = -1;
+    ws_br_handler.net_interface_id = -1;
 
     load_config();
     wisun_rf_init();
@@ -346,11 +346,20 @@
         ARM_LIB_TASKLET_INIT_EVENT);
 }
 
+#undef ETH
+#undef SLIP
+#undef EMAC
+#undef CELL
+#define ETH 1
+#define SLIP 2
+#define EMAC 3
+#define CELL 4
+
 static int backhaul_interface_up(int8_t driver_id)
 {
     int retval = -1;
     tr_debug("backhaul_interface_up: %i", driver_id);
-    if (ws_br_handler.eth_interface_id != -1) {
+    if (ws_br_handler.net_interface_id != -1) {
         tr_debug("Border RouterInterface already at active state");
         return retval;
     }
@@ -359,17 +368,24 @@
         eth_mac_api = ethernet_mac_create(driver_id);
     }
 
-    ws_br_handler.eth_interface_id = arm_nwk_interface_ethernet_init(eth_mac_api, "bh0");
+#if MBED_CONF_APP_BACKHAUL_DRIVER == CELL
+    if (eth_mac_api->iid64_get) {
+        ws_br_handler.net_interface_id = arm_nwk_interface_ppp_init(eth_mac_api, "ppp0");
+    } else
+#endif
+    {
+        ws_br_handler.net_interface_id = arm_nwk_interface_ethernet_init(eth_mac_api, "bh0");
+    }
 
-    MBED_ASSERT(ws_br_handler.eth_interface_id >= 0);
-    if (ws_br_handler.eth_interface_id >= 0) {
-        tr_debug("Backhaul interface ID: %d", ws_br_handler.eth_interface_id);
+    MBED_ASSERT(ws_br_handler.net_interface_id >= 0);
+    if (ws_br_handler.net_interface_id >= 0) {
+        tr_debug("Backhaul interface ID: %d", ws_br_handler.net_interface_id);
         if (ws_br_handler.ws_interface_id > -1) {
-            ws_bbr_start(ws_br_handler.ws_interface_id, ws_br_handler.eth_interface_id);
+            ws_bbr_start(ws_br_handler.ws_interface_id, ws_br_handler.net_interface_id);
         }
         arm_nwk_interface_configure_ipv6_bootstrap_set(
-            ws_br_handler.eth_interface_id, backhaul_bootstrap_mode, backhaul_prefix);
-        arm_nwk_interface_up(ws_br_handler.eth_interface_id);
+            ws_br_handler.net_interface_id, backhaul_bootstrap_mode, backhaul_prefix);
+        arm_nwk_interface_up(ws_br_handler.net_interface_id);
         retval = 0;
     } else {
         tr_error("Could not init ethernet");
@@ -378,12 +394,17 @@
     return retval;
 }
 
+#undef ETH
+#undef SLIP
+#undef EMAC
+#undef CELL
+
 static int backhaul_interface_down(void)
 {
     int retval = -1;
-    if (ws_br_handler.eth_interface_id != -1) {
-        arm_nwk_interface_down(ws_br_handler.eth_interface_id);
-        ws_br_handler.eth_interface_id = -1;
+    if (ws_br_handler.net_interface_id != -1) {
+        arm_nwk_interface_down(ws_br_handler.net_interface_id);
+        ws_br_handler.net_interface_id = -1;
         retval = 0;
     } else {
         tr_debug("Could not set eth down");
@@ -411,7 +432,7 @@
 static void print_interface_addresses(void)
 {
     tr_info("Backhaul interface addresses:");
-    print_interface_addr(ws_br_handler.eth_interface_id);
+    print_interface_addr(ws_br_handler.net_interface_id);
 
     tr_info("RF interface addresses:");
     print_interface_addr(ws_br_handler.ws_interface_id);
@@ -435,7 +456,7 @@
     switch (event_type) {
         case ARM_LIB_NWK_INTERFACE_EVENT:
 
-            if (event->event_id == ws_br_handler.eth_interface_id) {
+            if (event->event_id == ws_br_handler.net_interface_id) {
                 network_interface_event_handler(event);
             } else {
                 wisun_interface_event_handler(event);
@@ -514,10 +535,10 @@
     switch (status) {
         case (ARM_NWK_BOOTSTRAP_READY): { // Interface configured Bootstrap is ready
 
-            tr_info("BR interface_id: %d", ws_br_handler.eth_interface_id);
-            if (-1 != ws_br_handler.eth_interface_id) {
+            tr_info("BR interface_id: %d", ws_br_handler.net_interface_id);
+            if (-1 != ws_br_handler.net_interface_id) {
                 // metric set to high priority
-                if (0 != arm_net_interface_set_metric(ws_br_handler.eth_interface_id, 0)) {
+                if (0 != arm_net_interface_set_metric(ws_br_handler.net_interface_id, 0)) {
                     tr_warn("Failed to set metric for eth0.");
                 }
 
@@ -537,10 +558,10 @@
                     arm_net_route_add(backhaul_route.prefix,
                                       backhaul_route.prefix_len,
                                       next_hop_ptr, 0xffffffff, 128,
-                                      ws_br_handler.eth_interface_id);
+                                      ws_br_handler.net_interface_id);
                 }
                 tr_info("Backhaul interface addresses:");
-                print_interface_addr(ws_br_handler.eth_interface_id);
+                print_interface_addr(ws_br_handler.net_interface_id);
             }
             break;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/nanostack_heap_region.c	Thu Sep 26 10:02:16 2019 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019 ARM Limited. All rights reserved.
+ */
+
+#include "nsdynmemLIB.h"
+
+/* Enable nanostack extended heap only for specific targets and toolchains */
+#if (MBED_CONF_APP_NANOSTACK_EXTENDED_HEAP == true)
+
+#if defined(TARGET_K64F)
+#define NANOSTACK_EXTENDED_HEAP_REGION_SIZE (60*1024)
+#endif
+
+#if defined(TARGET_NUCLEO_F429ZI)
+#define NANOSTACK_EXTENDED_HEAP_REGION_SIZE (60*1024)
+#endif
+
+#if defined(TARGET_DISCO_F769NI)
+#define NANOSTACK_EXTENDED_HEAP_REGION_SIZE (250*1024)
+#endif
+
+#if defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ASM__) || defined(__ICCARM__)
+// currently - no IAR suport
+#undef NANOSTACK_EXTENDED_HEAP_REGION_SIZE
+#endif
+
+#endif // MBED_CONF_APP_NANOSTACK_EXTENDED_HEAP
+
+
+#ifdef NANOSTACK_EXTENDED_HEAP_REGION_SIZE
+
+// Heap region for GCC_ARM, ARMCC and ARMCLANG
+static uint8_t nanostack_extended_heap_region[NANOSTACK_EXTENDED_HEAP_REGION_SIZE];
+
+void nanostack_heap_region_add(void)
+{
+    ns_dyn_mem_region_add(nanostack_extended_heap_region, NANOSTACK_EXTENDED_HEAP_REGION_SIZE);
+}
+
+#else // NANOSTACK_EXTENDED_HEAP_REGION_SIZE
+
+void nanostack_heap_region_add(void)
+{
+}
+
+#endif // NANOSTACK_EXTENDED_HEAP_REGION_SIZE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/nanostack_heap_region.h	Thu Sep 26 10:02:16 2019 +0100
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2019 ARM Limited. All rights reserved.
+ */
+
+#ifndef NANOSTACK_HEAP_REGION_H
+#define NANOSTACK_HEAP_REGION_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+void nanostack_heap_region_add(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NANOSTACK_HEAP_REGION_H */