From c04e3f80b93aa9883c7b85eb414e7585ab51f718 Mon Sep 17 00:00:00 2001 From: Dmitry Frank Date: Fri, 28 Oct 2016 11:57:21 +0100 Subject: [PATCH] Make mongoose compile for nRF51 PUBLISHED_FROM=6af3ed56802d2619f673c36059370440a0c06397 --- examples/Makefile | 2 +- examples/nRF51/http/bleconfig.c | 569 +++++++++++++++ examples/nRF51/http/bleconfig.h | 8 + .../iot_lwip_tcp_server_pca10028.uvguix | 28 + .../iot_lwip_tcp_server_pca10028.uvoptx | 665 +++++++++++++++++ .../iot_lwip_tcp_server_pca10028.uvprojx | 676 ++++++++++++++++++ .../http/boards/pca10028/armgcc/Makefile | 236 ++++++ .../armgcc/iot_lwip_tcp_server_gcc_nrf51.ld | 12 + examples/nRF51/http/config/nrf_drv_config.h | 139 ++++ examples/nRF51/http/main.c | 92 +++ examples/nRF51/http/myboard.h | 21 + examples/nRF51/http/sdk_config.h | 204 ++++++ mongoose.c | 2 +- mongoose.h | 41 ++ 14 files changed, 2693 insertions(+), 2 deletions(-) create mode 100644 examples/nRF51/http/bleconfig.c create mode 100644 examples/nRF51/http/bleconfig.h create mode 100644 examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvguix create mode 100644 examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvoptx create mode 100644 examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvprojx create mode 100644 examples/nRF51/http/boards/pca10028/armgcc/Makefile create mode 100644 examples/nRF51/http/boards/pca10028/armgcc/iot_lwip_tcp_server_gcc_nrf51.ld create mode 100644 examples/nRF51/http/config/nrf_drv_config.h create mode 100644 examples/nRF51/http/main.c create mode 100644 examples/nRF51/http/myboard.h create mode 100644 examples/nRF51/http/sdk_config.h diff --git a/examples/Makefile b/examples/Makefile index f7cf7bd3..08d173a8 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -3,7 +3,7 @@ # `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine SUBDIRS = $(sort $(dir $(wildcard ./*/))) -SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF52/, $(SUBDIRS)) +SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF51/ ./nRF52/, $(SUBDIRS)) ifeq ($(OS), Windows_NT) SUBDIRS:=$(filter-out ./load_balancer/ ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/, $(SUBDIRS)) diff --git a/examples/nRF51/http/bleconfig.c b/examples/nRF51/http/bleconfig.c new file mode 100644 index 00000000..d706aeda --- /dev/null +++ b/examples/nRF51/http/bleconfig.c @@ -0,0 +1,569 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/* clang-format off */ + +/** @file + * + * @defgroup iot_sdk_tcp_server main.c + * @{ + * @ingroup iot_sdk_app_lwip + * @brief This file contains the source code for LwIP TCP Server sample application. + * + */ + +#include +#include +#include "boards.h" +#include "app_timer_appsh.h" +#include "app_scheduler.h" +#include "app_button.h" +#include "nordic_common.h" +#include "softdevice_handler_appsh.h" +#include "ble_advdata.h" +#include "ble_srv_common.h" +#include "ble_ipsp.h" +#include "ble_6lowpan.h" +#include "mem_manager.h" +#include "app_trace.h" +#include "lwip/init.h" +#include "lwip/inet6.h" +#include "lwip/ip6.h" +#include "lwip/ip6_addr.h" +#include "lwip/netif.h" +/*lint -save -e607 */ +#include "lwip/tcp.h" +/*lint -restore */ +#include "lwip/timers.h" +#include "nrf_platform_port.h" +#include "app_util_platform.h" + +#define DEVICE_NAME "LwIPTCPServer" /**< Device name used in BLE undirected advertisement. */ + +#define APP_TIMER_PRESCALER NRF51_DRIVER_TIMER_PRESCALER /**< Value of the RTC1 PRESCALER register. */ +#define APP_TIMER_MAX_TIMERS 1 /**< Maximum number of simultaneously created timers. */ +#define APP_TIMER_OP_QUEUE_SIZE 1 +#define LWIP_SYS_TIMER_INTERVAL APP_TIMER_TICKS(250, APP_TIMER_PRESCALER) /**< Interval for timer used as trigger to send. */ + +#define SCHED_MAX_EVENT_DATA_SIZE 128 /**< Maximum size of scheduler events. */ +#define SCHED_QUEUE_SIZE 12 /**< Maximum number of events in the scheduler queue. */ + +#define ADVERTISING_LED BSP_LED_0_MASK /**< Is on when device is advertising. */ +#define CONNECTED_LED BSP_LED_1_MASK /**< Is on when device is connected. */ +#define TCP_CONNECTED_LED BSP_LED_2_MASK /**< Is on when device is connected. */ +#define DISPLAY_LED_0 BSP_LED_0_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define DISPLAY_LED_1 BSP_LED_1_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define DISPLAY_LED_2 BSP_LED_2_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define DISPLAY_LED_3 BSP_LED_3_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define ALL_APP_LED (BSP_LED_0_MASK | BSP_LED_1_MASK | \ + BSP_LED_2_MASK | BSP_LED_3_MASK) /**< Define used for simultaneous operation of all application LEDs. */ + +#define APP_ADV_TIMEOUT 0 /**< Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */ +#define APP_ADV_ADV_INTERVAL MSEC_TO_UNITS(100, UNIT_0_625_MS) /**< The advertising interval. This value can vary between 100ms to 10.24s). */ + +#define DEAD_BEEF 0xDEADBEEF /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */ + +#define APPL_LOG app_trace_log /**< Macro for logging application messages on UART, in case ENABLE_DEBUG_LOG_SUPPORT is not defined, no logging occurs. */ +#define APPL_DUMP app_trace_dump /**< Macro for dumping application data on UART, in case ENABLE_DEBUG_LOG_SUPPORT is not defined, no logging occurs. */ + +#define TCP_SERVER_PORT 9000 /**< TCP server listen port number. */ +#define TCP_DATA_SIZE 8 /**< UDP Data size sent on remote. */ + +typedef enum +{ + TCP_STATE_IDLE, + TCP_STATE_REQUEST_CONNECTION, + TCP_STATE_CONNECTED, + TCP_STATE_DATA_TX_IN_PROGRESS, + TCP_STATE_DISCONNECTED +}tcp_state_t; + +eui64_t eui64_local_iid; /**< Local EUI64 value that is used as the IID for*/ +static ble_gap_adv_params_t m_adv_params; /**< Parameters to be passed to the stack when starting advertising. */ +static app_timer_id_t m_sys_timer_id; /**< System Timer used to service LwIP timers periodically. */ +static struct tcp_pcb * mp_tcp_port; /**< TCP Port to listen on. */ +static tcp_state_t m_tcp_state; /**< TCP State information. */ + + + + +/**@brief Function for error handling, which is called when an error has occurred. + * + * @warning This handler is an example only and does not fit a final product. You need to analyse + * how your product is supposed to react in case of error. + * + * @param[in] error_code Error code supplied to the handler. + * @param[in] line_num Line number where the handler is called. + * @param[in] p_file_name Pointer to the file name. + */ +void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + //Halt the application and notify of error using the LEDs. + APPL_LOG("[** ASSERT **]: Error 0x%08lX, Line %ld, File %s\r\n",error_code, line_num, p_file_name); + LEDS_ON(ALL_APP_LED); + for(;;) + { + } + + // @note: In case on assert, it is desired to only recover and reset, uncomment the line below. + //NVIC_SystemReset(); +} + + +/**@brief Callback function for asserts in the SoftDevice. + * + * @details This function will be called in case of an assert in the SoftDevice. + * + * @warning This handler is an example only and does not fit a final product. You need to analyse + * how your product is supposed to react in case of Assert. + * @warning On assert from the SoftDevice, the system can only recover on reset. + * + * @param[in] line_num Line number of the failing ASSERT call. + * @param[in] file_name File name of the failing ASSERT call. + */ +void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) +{ + app_error_handler(DEAD_BEEF, line_num, p_file_name); +} + + +/**@brief Function for the LEDs initialization. + * + * @details Initializes all LEDs used by this application. + */ +static void leds_init(void) +{ + // Configure application LED pins. + LEDS_CONFIGURE(ALL_APP_LED); + + // Turn off all LED on initialization. + LEDS_OFF(ALL_APP_LED); +} + + +/**@brief Function for initializing the Advertising functionality. + * + * @details Encodes the required advertising data and passes it to the stack. + * Also builds a structure to be passed to the stack when starting advertising. + */ +static void advertising_init(void) +{ + uint32_t err_code; + ble_advdata_t advdata; + uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; + ble_gap_conn_sec_mode_t sec_mode; + ble_gap_addr_t my_addr; + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); + + err_code = sd_ble_gap_device_name_set(&sec_mode, + (const uint8_t *)DEVICE_NAME, + strlen(DEVICE_NAME)); + APP_ERROR_CHECK(err_code); + + err_code = sd_ble_gap_address_get(&my_addr); + APP_ERROR_CHECK(err_code); + + my_addr.addr[5] = 0x00; + my_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC; + + err_code = sd_ble_gap_address_set(&my_addr); + APP_ERROR_CHECK(err_code); + + IPV6_EUI64_CREATE_FROM_EUI48(eui64_local_iid.identifier, + my_addr.addr, + my_addr.addr_type); + + ble_uuid_t adv_uuids[] = + { + {BLE_UUID_IPSP_SERVICE, BLE_UUID_TYPE_BLE} + }; + + //Build and set advertising data. + memset(&advdata, 0, sizeof(advdata)); + + advdata.name_type = BLE_ADVDATA_FULL_NAME; + advdata.flags = flags; + advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]); + advdata.uuids_complete.p_uuids = adv_uuids; + + err_code = ble_advdata_set(&advdata, NULL); + APP_ERROR_CHECK(err_code); + + //Initialize advertising parameters (used when starting advertising). + memset(&m_adv_params, 0, sizeof(m_adv_params)); + + m_adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND; + m_adv_params.p_peer_addr = NULL; // Undirected advertisement. + m_adv_params.fp = BLE_GAP_ADV_FP_ANY; + m_adv_params.interval = APP_ADV_ADV_INTERVAL; + m_adv_params.timeout = APP_ADV_TIMEOUT; +} + + +/**@brief Function for starting advertising. +*/ +static void advertising_start(void) +{ + uint32_t err_code; + + err_code = sd_ble_gap_adv_start(&m_adv_params); + APP_ERROR_CHECK(err_code); + + LEDS_ON(ADVERTISING_LED); +} + + +/**@brief Function for handling the Application's BLE Stack events. + * + * @param[in] p_ble_evt Bluetooth stack event. + */ +static void on_ble_evt(ble_evt_t * p_ble_evt) +{ + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + APPL_LOG ("[APPL]: Connected.\r\n"); + break; + case BLE_GAP_EVT_DISCONNECTED: + APPL_LOG ("[APPL]: Disconnected.\r\n"); + advertising_start(); + break; + default: + break; + } +} + + +/**@brief Function for dispatching a BLE stack event to all modules with a BLE stack event handler. + * + * @details This function is called from the BLE Stack event interrupt handler after a BLE stack + * event has been received. + * + * @param[in] p_ble_evt Bluetooth stack event. + */ +static void ble_evt_dispatch(ble_evt_t * p_ble_evt) +{ + ble_ipsp_evt_handler(p_ble_evt); + on_ble_evt(p_ble_evt); +} + + +/**@brief Function for initializing the BLE stack. + * + * @details Initializes the SoftDevice and the BLE event interrupt. + */ +static void ble_stack_init(void) +{ + uint32_t err_code; + + // Initialize the SoftDevice handler module. + SOFTDEVICE_HANDLER_APPSH_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, true); + + // Register with the SoftDevice handler module for BLE events. + err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch); + APP_ERROR_CHECK(err_code); +} + + +/**@brief Function for the Event Scheduler initialization. +*/ +static void scheduler_init(void) +{ + APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); +} + + +/**@brief Function to TCP port. + * + * @details Function to close the TCP port and reset any information on the port. + */ +static void tcp_port_close(struct tcp_pcb * p_pcb) +{ + m_tcp_state = TCP_STATE_REQUEST_CONNECTION; + + //Reset all information set on and/or callback registered for the port. + tcp_arg(p_pcb, NULL); + tcp_sent(p_pcb, NULL); + tcp_recv(p_pcb, NULL); + tcp_err(p_pcb, NULL); + tcp_poll(p_pcb, NULL, 0); + + UNUSED_VARIABLE(tcp_close(p_pcb)); + + LEDS_OFF((DISPLAY_LED_0 | DISPLAY_LED_1 | DISPLAY_LED_2 | DISPLAY_LED_3)); + LEDS_ON(CONNECTED_LED); +} + + +/**@brief TCP Port Write complete callback. + * + * @details Calbback registered to be notified of the write complete event on the TCP port. + * In case write complete is notified with 'zero' length, port is closed. + * + * @param[in] p_arg Receive argument set on the port. + * @param[in] p_pcb PCB identifier of the port. + * @param[in] len Length of data written successfully. + * + * @retval ERR_OK. + */ +static err_t tcp_write_complete(void * p_arg, + struct tcp_pcb * p_pcb, + u16_t len) +{ + UNUSED_PARAMETER(p_arg); + UNUSED_PARAMETER(p_pcb); + + if (len != 0) + { + //Write complete, reset the state to connected from transmit pending. + m_tcp_state = TCP_STATE_CONNECTED; + } + else + { + //Something is not right on the port, close the port. + tcp_port_close(mp_tcp_port); + } + return ERR_OK; +} + + +/**@brief Send test data on the port. + * + * @details Sends TCP data in Request of size 8 in format described in description above. + * + * @param[in] p_pcb PCB identifier of the port. + */ +static void tcp_send_data(struct tcp_pcb * p_pcb, uint32_t sequence_number) +{ + err_t err = ERR_OK; + + if (m_tcp_state != TCP_STATE_DATA_TX_IN_PROGRESS) + { + //Register callback to get notification of data reception is complete. + tcp_sent(p_pcb, tcp_write_complete); + uint8_t tcp_data[TCP_DATA_SIZE]; + + tcp_data[0] = (uint8_t )((sequence_number >> 24) & 0x000000FF); + tcp_data[1] = (uint8_t )((sequence_number >> 16) & 0x000000FF); + tcp_data[2] = (uint8_t )((sequence_number >> 8) & 0x000000FF); + tcp_data[3] = (uint8_t )(sequence_number & 0x000000FF); + + tcp_data[4] = 'P'; + tcp_data[5] = 'o'; + tcp_data[6] = 'n'; + tcp_data[7] = 'g'; + + //Enqueue data for transmission. + err = tcp_write(p_pcb, tcp_data, TCP_DATA_SIZE, 1); + + if (err != ERR_OK) + { + APPL_LOG ("[APPL]: Failed to send TCP packet, reason %d\r\n", err); + } + else + { + m_tcp_state = TCP_STATE_DATA_TX_IN_PROGRESS; + } + } + else + { + //Wait for tx to be complete. + } +} + + +/**@brief Callback registered for receiving data on the TCP Port. + * + * @param[in] p_arg Receive argument set on the TCP port. + * @param[in] p_pcb TCP PCB on which data is received. + * @param[in] p_buffer Buffer with received data. + * @param[in] err Event result indicating error associated with the receive, + * if any, else ERR_OK. + */ +err_t tcp_recv_data_handler(void * p_arg, + struct tcp_pcb * p_pcb, + struct pbuf * p_buffer, + err_t err) +{ + APPL_LOG ("[APPL]: >> TCP Data.\r\n"); + + //Check event result before proceeding. + if (err == ERR_OK) + { + uint8_t *p_data = p_buffer->payload; + + if (p_buffer->len == TCP_DATA_SIZE) + { + uint32_t sequence_number = 0; + + sequence_number = ((p_data[0] << 24) & 0xFF000000); + sequence_number |= ((p_data[1] << 16) & 0x00FF0000); + sequence_number |= ((p_data[2] << 8) & 0x0000FF00); + sequence_number |= (p_data[3] & 0x000000FF); + + LEDS_OFF(ALL_APP_LED); + + if (sequence_number & 0x00000001) + { + LEDS_ON(DISPLAY_LED_0); + } + if (sequence_number & 0x00000002) + { + LEDS_ON(DISPLAY_LED_1); + } + if (sequence_number & 0x00000004) + { + LEDS_ON(DISPLAY_LED_2); + } + if (sequence_number & 0x00000008) + { + LEDS_ON(DISPLAY_LED_3); + } + + //Send Response + tcp_send_data(p_pcb, sequence_number); + } + else + { + APPL_LOG ("[APPL]: TCP data received in incorrect format.\r\n"); + } + // All is good with the data received, process it. + tcp_recved(p_pcb, p_buffer->tot_len); + UNUSED_VARIABLE(pbuf_free(p_buffer)); + } + else + { + //Free the buffer in case its not NULL. + if (p_buffer != NULL) + { + UNUSED_VARIABLE(pbuf_free(p_buffer)); + } + + //Something is not right with the port, close the port. + tcp_port_close(mp_tcp_port); + } + + return ERR_OK; +} + + + + + +/**@brief Function for initializing IP stack. + * + * @details Initialize the IP Stack and its driver. + */ +static void ip_stack_init(void) +{ + uint32_t err_code = nrf51_sdk_mem_init(); + APP_ERROR_CHECK(err_code); + + //Initialize LwIP stack. + lwip_init(); + + //Initialize LwIP stack driver. + err_code = nrf51_driver_init(); + APP_ERROR_CHECK(err_code); +} + + +/**@brief Timer callback used for periodic servicing of LwIP protocol timers. + * + * @details Timer callback used for periodic servicing of LwIP protocol timers. + * + * @param[in] p_context Pointer used for passing context. No context used in this application. + */ +static void system_timer_callback(void * p_context) +{ + UNUSED_VARIABLE(p_context); + sys_check_timeouts(); +} + + +/**@brief Function for the Timer initialization. + * + * @details Initializes the timer module. This creates and starts application timers. + */ +static void timers_init(void) +{ + uint32_t err_code; + + // Initialize timer module. + APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, true); + + // Create timers. + err_code = app_timer_create(&m_sys_timer_id, + APP_TIMER_MODE_REPEATED, + system_timer_callback); + APP_ERROR_CHECK(err_code); +} + + +/**@brief Function to handle interface up event. */ +void nrf51_driver_interface_up(void) +{ + uint32_t err_code; + + APPL_LOG ("[APPL]: IPv6 interface up.\r\n"); + + sys_check_timeouts(); + + m_tcp_state = TCP_STATE_REQUEST_CONNECTION; + + err_code = app_timer_start(m_sys_timer_id, LWIP_SYS_TIMER_INTERVAL, NULL); + APP_ERROR_CHECK(err_code); + + LEDS_OFF(ADVERTISING_LED); + LEDS_ON(CONNECTED_LED); +} + + +/**@brief Function to handle interface down event. */ +void nrf51_driver_interface_down(void) +{ + uint32_t err_code; + + APPL_LOG ("[APPL]: IPv6 interface down.\r\n"); + + err_code = app_timer_stop(m_sys_timer_id); + APP_ERROR_CHECK(err_code); + + LEDS_OFF((DISPLAY_LED_0 | DISPLAY_LED_1 | DISPLAY_LED_2 | DISPLAY_LED_3)); + LEDS_ON(ADVERTISING_LED); + + m_tcp_state = TCP_STATE_DISCONNECTED; +} + +void bleconfig_init(void) { + //Initialize. + app_trace_init(); + leds_init(); + timers_init(); + ble_stack_init(); + advertising_init(); + ip_stack_init (); + scheduler_init(); + + APPL_LOG ("\r\n"); + APPL_LOG ("[APPL]: Init done.\r\n"); + + //Start execution. + advertising_start(); +} + +void bleconfig_poll(void) { + //Execute event schedule. + app_sched_execute(); +} + diff --git a/examples/nRF51/http/bleconfig.h b/examples/nRF51/http/bleconfig.h new file mode 100644 index 00000000..512224fc --- /dev/null +++ b/examples/nRF51/http/bleconfig.h @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2014-2016 Cesanta Software Limited + * All rights reserved + */ + +void bleconfig_init(void); +void bleconfig_poll(void); + diff --git a/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvguix b/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvguix new file mode 100644 index 00000000..cf8cc03c --- /dev/null +++ b/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvguix @@ -0,0 +1,28 @@ + + + + -5.1 + +
### uVision Project, (C) Keil Software
+ + + + + 1 + 0 + + 100 + 0 + + ..\..\..\..\..\..\..\components\softdevice\s1xx_iot\doc\s1xx-iot-prototype2_licence_agreement.txt + 0 + 1 + 1 + 1 + + 0 + + + + +
\ No newline at end of file diff --git a/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvoptx b/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvoptx new file mode 100644 index 00000000..88f4442e --- /dev/null +++ b/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvoptx @@ -0,0 +1,665 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + + + + 0 + 0 + + + + nrf51422_xxac_s1xx_iot + 0x4 + ARM-ADS + + 16000000 + + 1 + 1 + 0 + 1 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\_build\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 5 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 0 + 0 + 6 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + JL2CM3 + -U408001579 -O78 -S0 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC2000 -FN1 -FF0nrf51xxx.flm -FS00 -FL0200000 -FP0($$Device:nRF51822_xxAA$Flash\nrf51xxx.flm) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0nrf51xxx -FS00 -FL0200000 -FP0($$Device:nRF51822_xxAA$Flash\nrf51xxx.flm)) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + Application + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + 0 + ..\..\..\main.c + main.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + 0 + ..\..\..\bleconfig.c + bleconfig.c + 0 + 0 + + + 1 + 3 + 5 + 0 + 0 + 0 + 0 + ..\..\..\bleconfig.h + bleconfig.h + 0 + 0 + + + 1 + 4 + 5 + 0 + 0 + 0 + 0 + ..\..\..\myboard.h + myboard.h + 0 + 0 + + + + + Documentation + 0 + 0 + 0 + 0 + + 2 + 5 + 5 + 0 + 0 + 0 + 0 + ..\..\..\Abstract.txt + Abstract.txt + 0 + 0 + + + 2 + 6 + 5 + 0 + 0 + 0 + 0 + ..\..\..\license.txt + license.txt + 0 + 0 + + + + + Third Parties + 0 + 0 + 0 + 0 + + 3 + 7 + 4 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\external\lwip\lib\liblwip.lib + liblwip.lib + 0 + 0 + + + 3 + 8 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\external\lwip\src\port\nrf_platform_port.c + nrf_platform_port.c + 0 + 0 + + + + + nRF_BLE + 0 + 0 + 0 + 0 + + 4 + 9 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\ble\common\ble_advdata.c + ble_advdata.c + 0 + 0 + + + 4 + 10 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\ble\common\ble_srv_common.c + ble_srv_common.c + 0 + 0 + + + + + nRF_Drivers + 0 + 0 + 0 + 0 + + 5 + 11 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\uart\app_uart_fifo.c + app_uart_fifo.c + 0 + 0 + + + 5 + 12 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\hal\nrf_delay.c + nrf_delay.c + 0 + 0 + + + 5 + 13 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\common\nrf_drv_common.c + nrf_drv_common.c + 0 + 0 + + + 5 + 14 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\gpiote\nrf_drv_gpiote.c + nrf_drv_gpiote.c + 0 + 0 + + + + + nRF_IoT + 0 + 0 + 0 + 0 + + 6 + 15 + 4 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\iot\ble_6lowpan\lib\ble_6lowpan.lib + ble_6lowpan.lib + 0 + 0 + + + 6 + 16 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\iot\context_manager\iot_context_manager.c + iot_context_manager.c + 0 + 0 + + + + + nRF_Libraries + 0 + 0 + 0 + 0 + + 7 + 17 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\button\app_button.c + app_button.c + 0 + 0 + + + 7 + 18 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\util\app_error.c + app_error.c + 0 + 0 + + + 7 + 19 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\fifo\app_fifo.c + app_fifo.c + 0 + 0 + + + 7 + 20 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\scheduler\app_scheduler.c + app_scheduler.c + 0 + 0 + + + 7 + 21 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\timer\app_timer.c + app_timer.c + 0 + 0 + + + 7 + 22 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\timer\app_timer_appsh.c + app_timer_appsh.c + 0 + 0 + + + 7 + 23 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\trace\app_trace.c + app_trace.c + 0 + 0 + + + 7 + 24 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\mem_manager\mem_manager.c + mem_manager.c + 0 + 0 + + + 7 + 25 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\util\nrf_assert.c + nrf_assert.c + 0 + 0 + + + 7 + 26 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\libraries\uart\retarget.c + retarget.c + 0 + 0 + + + + + nRF_SoftDevice + 0 + 0 + 0 + 0 + + 8 + 27 + 5 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\softdevice\s1xx_iot\doc\s1xx-iot-prototype2_licence_agreement.txt + s1xx-iot-prototype2_licence_agreement.txt + 0 + 0 + + + 8 + 28 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\softdevice\common\softdevice_handler\softdevice_handler.c + softdevice_handler.c + 0 + 0 + + + 8 + 29 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\nrf51_iot_sdk\components\softdevice\common\softdevice_handler\softdevice_handler_appsh.c + softdevice_handler_appsh.c + 0 + 0 + + + + + Mongoose + 1 + 0 + 0 + 0 + + 9 + 30 + 1 + 0 + 0 + 0 + 0 + ..\..\..\..\..\..\mongoose.c + mongoose.c + 0 + 0 + + + + + ::CMSIS + 0 + 0 + 0 + 1 + + + + ::Device + 0 + 0 + 0 + 1 + + 11 + 31 + 2 + 0 + 0 + 0 + 0 + RTE\Device\nRF51422_xxAC\arm_startup_nrf51.s + arm_startup_nrf51.s + 1 + 0 + + + 11 + 32 + 1 + 0 + 0 + 0 + 0 + RTE\Device\nRF51422_xxAC\system_nrf51.c + system_nrf51.c + 1 + 0 + + + +
diff --git a/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvprojx b/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvprojx new file mode 100644 index 00000000..053c8659 --- /dev/null +++ b/examples/nRF51/http/boards/pca10028/arm5_no_packs/iot_lwip_tcp_server_pca10028.uvprojx @@ -0,0 +1,676 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + nrf51422_xxac_s1xx_iot + 0x4 + ARM-ADS + + + nRF51422_xxAC + Nordic Semiconductor + NordicSemiconductor.nRF_DeviceFamilyPack.8.0.5 + http://developer.nordicsemi.com/nRF51_SDK/pieces/nRF_DeviceFamilyPack/ + IROM(0x00000000,0x40000) IRAM(0x20000000,0x8000) CPUTYPE("Cortex-M0") CLOCK(16000000) ELITTLE + + + UL2CM3(-UM0049BUE -O4175 -S0 -C0 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0nRF5Prog -FS00 -FL08000) + 0 + core.h + + + + + + + + + + ..\..\..\..\..\..\..\SVD\nrf51.xml + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\_build\ + nrf51422_xxac_s1xx_iot + 1 + 0 + 1 + 1 + 1 + .\_build\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + + + + SARMCM3.DLL + + TARMCM1.DLL + -pCM0 + + + + 1 + 0 + 0 + 0 + 16 + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + + + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + + 0 + 6 + + + + + + + + + + + + + + Segger\JL2CM3.dll + + + + + 1 + 0 + 0 + 1 + 1 + 4099 + + 1 + Segger\JL2CM3.dll + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 3 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x8000 + + + 1 + 0x0 + 0x40000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x18000 + 0x28000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20002000 + 0x6000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 4 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + --c99 + __HEAP_SIZE=1024 BOARD_PCA10028 BLE_STACK_SUPPORT_REQD S110 BSP_DEFINES_ONLY NRF51 SOFTDEVICE_PRESENT SWI_DISABLE0 MG_DISABLE_HTTP_DIGEST_AUTH MG_DISABLE_MD5 MG_DISABLE_HTTP_KEEP_ALIVE MG_ENABLE_HTTP_SSI=0 MG_ENABLE_HTTP_STREAMING_MULTIPART MG_NO_BSD_SOCKETS CS_PLATFORM=CS_P_NRF51 CS_ENABLE_STDIO + + ..\..\..\config;..\..\..;..\..\..\..\nrf51_iot_sdk\examples\bsp;..\..\..\..\nrf51_iot_sdk\components\softdevice\s1xx_iot\headers;..\..\..\..\nrf51_iot_sdk\components\ble\common;..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\uart;..\..\..\..\nrf51_iot_sdk\components\libraries\timer;..\..\..\..\nrf51_iot_sdk\components\softdevice\common\softdevice_handler;..\..\..\..\nrf51_iot_sdk\components\libraries\scheduler;..\..\..\..\nrf51_iot_sdk\components\libraries\button;..\..\..\..\nrf51_iot_sdk\external\lwip\src\include;..\..\..\..\nrf51_iot_sdk\external\lwip\src\include\netif;..\..\..\..\nrf51_iot_sdk\external\lwip\src\port;..\..\..\..\nrf51_iot_sdk\external\lwip\src\port\arch;..\..\..\..\nrf51_iot_sdk\components\iot\ble_6lowpan;..\..\..\..\nrf51_iot_sdk\components\device;..\..\..\..\nrf51_iot_sdk\components\toolchain;..\..\..\..\nrf51_iot_sdk\components\libraries\util;..\..\..\..\nrf51_iot_sdk\components\libraries\fifo;..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\gpiote;..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\config;..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\common;..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\hal;..\..\..\..\nrf51_iot_sdk\components\libraries\mem_manager;..\..\..\..\nrf51_iot_sdk\components\iot\include;..\..\..\..\nrf51_iot_sdk\components\iot\context_manager;..\..\..\..\nrf51_iot_sdk\components\iot\ble_ipsp;..\..\..\..\nrf51_iot_sdk\components\libraries\trace;..\..\..\..\..\.. + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + __HEAP_SIZE=1024 BOARD_PCA10028 BLE_STACK_SUPPORT_REQD S110 BSP_DEFINES_ONLY NRF51 SOFTDEVICE_PRESENT SWI_DISABLE0 + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x00000000 + + + + + + + + + + + + + Application + + + main.c + 1 + ..\..\..\main.c + + + bleconfig.c + 1 + ..\..\..\bleconfig.c + + + bleconfig.h + 5 + ..\..\..\bleconfig.h + + + myboard.h + 5 + ..\..\..\myboard.h + + + + + Documentation + + + Abstract.txt + 5 + ..\..\..\Abstract.txt + + + license.txt + 5 + ..\..\..\license.txt + + + + + Third Parties + + + liblwip.lib + 4 + ..\..\..\..\nrf51_iot_sdk\external\lwip\lib\liblwip.lib + + + nrf_platform_port.c + 1 + ..\..\..\..\nrf51_iot_sdk\external\lwip\src\port\nrf_platform_port.c + + + + + nRF_BLE + + + ble_advdata.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\ble\common\ble_advdata.c + + + ble_srv_common.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\ble\common\ble_srv_common.c + + + + + nRF_Drivers + + + app_uart_fifo.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\uart\app_uart_fifo.c + + + nrf_delay.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\hal\nrf_delay.c + + + nrf_drv_common.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\common\nrf_drv_common.c + + + nrf_drv_gpiote.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\drivers_nrf\gpiote\nrf_drv_gpiote.c + + + + + nRF_IoT + + + ble_6lowpan.lib + 4 + ..\..\..\..\nrf51_iot_sdk\components\iot\ble_6lowpan\lib\ble_6lowpan.lib + + + iot_context_manager.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\iot\context_manager\iot_context_manager.c + + + + + nRF_Libraries + + + app_button.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\button\app_button.c + + + app_error.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\util\app_error.c + + + app_fifo.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\fifo\app_fifo.c + + + app_scheduler.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\scheduler\app_scheduler.c + + + app_timer.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\timer\app_timer.c + + + app_timer_appsh.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\timer\app_timer_appsh.c + + + app_trace.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\trace\app_trace.c + + + mem_manager.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\mem_manager\mem_manager.c + + + nrf_assert.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\util\nrf_assert.c + + + retarget.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\libraries\uart\retarget.c + + + + + nRF_SoftDevice + + + s1xx-iot-prototype2_licence_agreement.txt + 5 + ..\..\..\..\nrf51_iot_sdk\components\softdevice\s1xx_iot\doc\s1xx-iot-prototype2_licence_agreement.txt + + + softdevice_handler.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\softdevice\common\softdevice_handler\softdevice_handler.c + + + softdevice_handler_appsh.c + 1 + ..\..\..\..\nrf51_iot_sdk\components\softdevice\common\softdevice_handler\softdevice_handler_appsh.c + + + + + Mongoose + + + mongoose.c + 1 + ..\..\..\..\..\..\mongoose.c + + + + + ::CMSIS + + + ::Device + + + arm_startup_nrf51.s + 2 + RTE\Device\nRF51422_xxAC\arm_startup_nrf51.s + + + system_nrf51.c + 1 + RTE\Device\nRF51422_xxAC\system_nrf51.c + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RTE\Device\nRF51422_xxAC\arm_startup_nrf51.s + + + + + + + + RTE\Device\nRF51422_xxAC\system_nrf51.c + + + + + + + + + +
diff --git a/examples/nRF51/http/boards/pca10028/armgcc/Makefile b/examples/nRF51/http/boards/pca10028/armgcc/Makefile new file mode 100644 index 00000000..99f461b5 --- /dev/null +++ b/examples/nRF51/http/boards/pca10028/armgcc/Makefile @@ -0,0 +1,236 @@ +PROJECT_NAME := iot_lwip_tcp_server_pca10028 + +export OUTPUT_FILENAME +#MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +MAKEFILE_NAME := $(MAKEFILE_LIST) +MAKEFILE_DIR := $(dir $(MAKEFILE_NAME) ) + +TEMPLATE_PATH = ../../../../nrf51_iot_sdk/components/toolchain/gcc +ifeq ($(OS),Windows_NT) +include $(TEMPLATE_PATH)/Makefile.windows +else +include $(TEMPLATE_PATH)/Makefile.posix +endif + +MK := mkdir +RM := rm -rf + +#echo suspend +ifeq ("$(VERBOSE)","1") +NO_ECHO := +else +NO_ECHO := @ +endif + +# Toolchain commands +CC := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc" +AS := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-as" +AR := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ar" -r +LD := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld" +NM := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-nm" +OBJDUMP := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objdump" +OBJCOPY := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objcopy" +SIZE := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-size" + +#function for removing duplicates in a list +remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1)))) + +#source common to all targets +C_SOURCE_FILES += \ +../../../../nrf51_iot_sdk/components/libraries/button/app_button.c \ +../../../../nrf51_iot_sdk/components/libraries/util/app_error.c \ +../../../../nrf51_iot_sdk/components/libraries/fifo/app_fifo.c \ +../../../../nrf51_iot_sdk/components/libraries/scheduler/app_scheduler.c \ +../../../../nrf51_iot_sdk/components/libraries/timer/app_timer.c \ +../../../../nrf51_iot_sdk/components/libraries/timer/app_timer_appsh.c \ +../../../../nrf51_iot_sdk/components/libraries/trace/app_trace.c \ +../../../../nrf51_iot_sdk/components/libraries/mem_manager/mem_manager.c \ +../../../../nrf51_iot_sdk/components/libraries/util/nrf_assert.c \ +../../../../nrf51_iot_sdk/components/libraries/uart/retarget.c \ +../../../../nrf51_iot_sdk/external/lwip/src/port/nrf_platform_port.c \ +../../../../nrf51_iot_sdk/components/drivers_nrf/uart/app_uart_fifo.c \ +../../../../nrf51_iot_sdk/components/drivers_nrf/hal/nrf_delay.c \ +../../../../nrf51_iot_sdk/components/drivers_nrf/common/nrf_drv_common.c \ +../../../../nrf51_iot_sdk/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \ +../../../main.c \ +../../../../nrf51_iot_sdk/components/ble/common/ble_advdata.c \ +../../../../nrf51_iot_sdk/components/ble/common/ble_srv_common.c \ +../../../../nrf51_iot_sdk/components/iot/context_manager/iot_context_manager.c \ +../../../../nrf51_iot_sdk/components/toolchain/system_nrf51.c \ +../../../../nrf51_iot_sdk/components/softdevice/common/softdevice_handler/softdevice_handler.c \ +../../../../nrf51_iot_sdk/components/softdevice/common/softdevice_handler/softdevice_handler_appsh.c \ + +#assembly files common to all targets +ASM_SOURCE_FILES = ../../../../nrf51_iot_sdk/components/toolchain/gcc/gcc_startup_nrf51.s + +#assembly files common to all targets +LIBS = ../../../../nrf51_iot_sdk/external/lwip/lib/liblwip.a +LIBS += ../../../../nrf51_iot_sdk/components/iot/ble_6lowpan/lib/ble_6lowpan.a + +#includes common to all targets +INC_PATHS = -I../../../config +INC_PATHS += -I../../../../nrf51_iot_sdk/components/softdevice/s1xx_iot/headers +INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/common +INC_PATHS += -I../../../../nrf51_iot_sdk/components/softdevice/common/softdevice_handler +INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/include +INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/ble_6lowpan +INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/hal +INC_PATHS += -I../../../../nrf51_iot_sdk/components/ble/common +INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/port +INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/fifo +INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/trace +INC_PATHS += -I../../../../nrf51_iot_sdk/components/device +INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/config +INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/mem_manager +INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/uart +INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/ble_ipsp +INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/scheduler +INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/include/netif +INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/include +INC_PATHS += -I../../.. +INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/context_manager +INC_PATHS += -I../../../../nrf51_iot_sdk/components/toolchain/gcc +INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/gpiote +INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/timer +INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/port/arch +INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/button +INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/util +INC_PATHS += -I../../../../nrf51_iot_sdk/examples/bsp +INC_PATHS += -I../../../../nrf51_iot_sdk/components/toolchain + +OBJECT_DIRECTORY = _build +LISTING_DIRECTORY = $(OBJECT_DIRECTORY) +OUTPUT_BINARY_DIRECTORY = $(OBJECT_DIRECTORY) + +# Sorting removes duplicates +BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY) $(LISTING_DIRECTORY) ) + +#flags common to all targets +CFLAGS = -D__HEAP_SIZE=512 +CFLAGS += -DSWI_DISABLE0 +CFLAGS += -DBOARD_PCA10028 +CFLAGS += -DSOFTDEVICE_PRESENT +CFLAGS += -DNRF51 +CFLAGS += -DS110 +CFLAGS += -DBLE_STACK_SUPPORT_REQD +CFLAGS += -DBSP_DEFINES_ONLY +CFLAGS += -mcpu=cortex-m0 +CFLAGS += -mthumb -mabi=aapcs --std=gnu99 +CFLAGS += -Wall -Werror -O3 +CFLAGS += -mfloat-abi=soft +# keep every function in separate section. This will allow linker to dump unused functions +CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing +CFLAGS += -fno-builtin --short-enums + +# keep every function in separate section. This will allow linker to dump unused functions +LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map +LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) +LDFLAGS += -mcpu=cortex-m0 +# let linker to dump unused sections +LDFLAGS += -Wl,--gc-sections +# use newlib in nano version +LDFLAGS += --specs=nano.specs -lc -lnosys + +# Assembler flags +ASMFLAGS += -x assembler-with-cpp +ASMFLAGS += -D__HEAP_SIZE=512 +ASMFLAGS += -DSWI_DISABLE0 +ASMFLAGS += -DBOARD_PCA10028 +ASMFLAGS += -DSOFTDEVICE_PRESENT +ASMFLAGS += -DNRF51 +ASMFLAGS += -DS110 +ASMFLAGS += -DBLE_STACK_SUPPORT_REQD +ASMFLAGS += -DBSP_DEFINES_ONLY +#default target - first one defined +default: clean nrf51422_xxac_s1xx_iot + +#building all targets +all: clean + $(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e cleanobj + $(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e nrf51422_xxac_s1xx_iot + +#target for printing all targets +help: + @echo following targets are available: + @echo nrf51422_xxac_s1xx_iot + + +C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES)) +C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) ) +C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES:.c=.o) ) + +ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES)) +ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) )) +ASM_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(ASM_SOURCE_FILE_NAMES:.s=.o) ) + +vpath %.c $(C_PATHS) +vpath %.s $(ASM_PATHS) + +OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS) + +nrf51422_xxac_s1xx_iot: OUTPUT_FILENAME := nrf51422_xxac_s1xx_iot +nrf51422_xxac_s1xx_iot: LINKER_SCRIPT=iot_lwip_tcp_server_gcc_nrf51.ld +nrf51422_xxac_s1xx_iot: $(BUILD_DIRECTORIES) $(OBJECTS) + @echo Linking target: $(OUTPUT_FILENAME).out + $(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out + $(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e finalize + +## Create build directories +$(BUILD_DIRECTORIES): + echo $(MAKEFILE_NAME) + $(MK) $@ + +# Create objects from C SRC files +$(OBJECT_DIRECTORY)/%.o: %.c + @echo Compiling file: $(notdir $<) + $(NO_ECHO)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $< + +# Assemble files +$(OBJECT_DIRECTORY)/%.o: %.s + @echo Compiling file: $(notdir $<) + $(NO_ECHO)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $< + + +# Link +$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(BUILD_DIRECTORIES) $(OBJECTS) + @echo Linking target: $(OUTPUT_FILENAME).out + $(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out + + +## Create binary .bin file from the .out file +$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out + @echo Preparing: $(OUTPUT_FILENAME).bin + $(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin + +## Create binary .hex file from the .out file +$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out + @echo Preparing: $(OUTPUT_FILENAME).hex + $(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex + +finalize: genbin genhex echosize + +genbin: + @echo Preparing: $(OUTPUT_FILENAME).bin + $(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin + +## Create binary .hex file from the .out file +genhex: + @echo Preparing: $(OUTPUT_FILENAME).hex + $(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex + +echosize: + -@echo "" + $(NO_ECHO)$(SIZE) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out + -@echo "" + +clean: + $(RM) $(BUILD_DIRECTORIES) + +cleanobj: + $(RM) $(BUILD_DIRECTORIES)/*.o + +flash: $(MAKECMDGOALS) + @echo Flashing: $(OUTPUT_BINARY_DIRECTORY)/$<.hex + nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$<.hex + +## Flash softdevice diff --git a/examples/nRF51/http/boards/pca10028/armgcc/iot_lwip_tcp_server_gcc_nrf51.ld b/examples/nRF51/http/boards/pca10028/armgcc/iot_lwip_tcp_server_gcc_nrf51.ld new file mode 100644 index 00000000..854c2d32 --- /dev/null +++ b/examples/nRF51/http/boards/pca10028/armgcc/iot_lwip_tcp_server_gcc_nrf51.ld @@ -0,0 +1,12 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000 + RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x6000 +} + +INCLUDE "gcc_nrf51_common.ld" \ No newline at end of file diff --git a/examples/nRF51/http/config/nrf_drv_config.h b/examples/nRF51/http/config/nrf_drv_config.h new file mode 100644 index 00000000..ca1c3bcc --- /dev/null +++ b/examples/nRF51/http/config/nrf_drv_config.h @@ -0,0 +1,139 @@ +/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/* clang-format off */ + +#ifndef NRF_DRV_CONFIG_H +#define NRF_DRV_CONFIG_H + +/* CLOCK */ +#define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_16MHz +#define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LF_SRC_Xtal +#define CLOCK_CONFIG_LF_RC_CAL_INTERVAL RC_2000MS_CALIBRATION_INTERVAL +#define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW + +/* GPIOTE */ +#define GPIOTE_ENABLED 1 + +#if (GPIOTE_ENABLED == 1) +#define GPIOTE_CONFIG_USE_SWI_EGU false +#define GPIOTE_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH +#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 6 +#endif + +/* TIMER */ +#define TIMER0_ENABLED 0 + +#if (TIMER0_ENABLED == 1) +#define TIMER0_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz +#define TIMER0_CONFIG_MODE TIMER_MODE_MODE_Timer +#define TIMER0_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit +#define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW + +#define TIMER0_INSTANCE_INDEX 0 +#endif + +#define TIMER1_ENABLED 0 + +#if (TIMER1_ENABLED == 1) +#define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz +#define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer +#define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit +#define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW + +#define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED) +#endif + +#define TIMER2_ENABLED 0 + +#if (TIMER2_ENABLED == 1) +#define TIMER2_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz +#define TIMER2_CONFIG_MODE TIMER_MODE_MODE_Timer +#define TIMER2_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit +#define TIMER2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW + +#define TIMER2_INSTANCE_INDEX (TIMER1_ENABLED+TIMER0_ENABLED) +#endif + +#define TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_ENABLED) + +/* RTC */ +#define RTC0_ENABLED 0 + +#if (RTC0_ENABLED == 1) +#define RTC0_CONFIG_FREQUENCY 32678 +#define RTC0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW +#define RTC0_CONFIG_RELIABLE false + +#define RTC0_INSTANCE_INDEX 0 +#endif + +#define RTC1_ENABLED 0 + +#if (RTC1_ENABLED == 1) +#define RTC1_CONFIG_FREQUENCY 32768 +#define RTC1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW +#define RTC1_CONFIG_RELIABLE false + +#define RTC1_INSTANCE_INDEX (RTC0_ENABLED) +#endif + +#define RTC_COUNT (RTC0_ENABLED+RTC1_ENABLED) + +#define NRF_MAXIMUM_LATENCY_US 2000 + +/* RNG */ +#define RNG_ENABLED 0 + +#if (RNG_ENABLED == 1) +#define RNG_CONFIG_ERROR_CORRECTION true +#define RNG_CONFIG_POOL_SIZE 8 +#define RNG_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW +#endif + + +/* QDEC */ +#define QDEC_ENABLED 0 + +#if (QDEC_ENABLED == 1) +#define QDEC_CONFIG_REPORTPER NRF_QDEC_REPORTPER_10 +#define QDEC_CONFIG_SAMPLEPER NRF_QDEC_SAMPLEPER_16384us +#define QDEC_CONFIG_PIO_A 1 +#define QDEC_CONFIG_PIO_B 2 +#define QDEC_CONFIG_PIO_LED 3 +#define QDEC_CONFIG_LEDPRE 511 +#define QDEC_CONFIG_LEDPOL NRF_QDEC_LEPOL_ACTIVE_HIGH +#define QDEC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW +#define QDEC_CONFIG_DBFEN false +#define QDEC_CONFIG_SAMPLE_INTEN false +#endif + +/* LPCOMP */ +#define LPCOMP_ENABLED 0 + +#if (LPCOMP_ENABLED == 1) +#define LPCOMP_CONFIG_REFERENCE NRF_LPCOMP_REF_SUPPLY_FOUR_EIGHT +#define LPCOMP_CONFIG_DETECTION NRF_LPCOMP_DETECT_DOWN +#define LPCOMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW +#define LPCOMP_CONFIG_INPUT NRF_LPCOMP_INPUT_0 +#endif + +/* WDT */ +#define WDT_ENABLED 0 + +#if (WDT_ENABLED == 1) +#define WDT_CONFIG_BEHAVIOUR NRF_WDT_BEHAVIOUR_RUN_SLEEP +#define WDT_CONFIG_RELOAD_VALUE 2000 +#define WDT_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH +#endif + +#endif // NRF_DRV_CONFIG_H diff --git a/examples/nRF51/http/main.c b/examples/nRF51/http/main.c new file mode 100644 index 00000000..54547535 --- /dev/null +++ b/examples/nRF51/http/main.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014-2016 Cesanta Software Limited + * All rights reserved + */ + +#include "bleconfig.h" +#include "myboard.h" + +#include "mongoose.h" + +/* + * This is a callback invoked by Mongoose to signal that a poll is needed soon. + * Since we're in a tight polling loop anyway (see below), we don't need to do anything. + */ +void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr) { +} + + +// Define an event handler function +void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { + if (ev == MG_EV_POLL) return; + /* printf("ev %d\r\n", ev); */ + switch (ev) { + case MG_EV_ACCEPT: { + char addr[32]; + mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr), + MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT); + printf("%p: Connection from %s\r\n", nc, addr); + break; + } + case MG_EV_HTTP_REQUEST: { + struct http_message *hm = (struct http_message *) ev_data; + char addr[32]; + mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr), + MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT); + printf("%p: %.*s %.*s\r\n", nc, (int) hm->method.len, hm->method.p, + (int) hm->uri.len, hm->uri.p); + mg_send_response_line(nc, 200, + "Content-Type: text/html\r\n" + "Connection: close"); + mg_printf(nc, + "\r\n

Hello, %s!

\r\n" + "You asked for %.*s\r\n", + addr, (int) hm->uri.len, hm->uri.p); + nc->flags |= MG_F_SEND_AND_CLOSE; + LEDS_INVERT(LED_THREE); + break; + } + case MG_EV_CLOSE: { + printf("%p: Connection closed\r\n", nc); + break; + } + } +} + + +/** + * @brief Function for application main entry. + */ +int main(void) +{ + + cs_log_set_file(stdout); + + bleconfig_init(); + + { + struct mg_mgr mgr; + + mg_mgr_init(&mgr, NULL); // Initialize event manager object + + // Note that many connections can be added to a single event manager + // Connections can be created at any point, e.g. in event handler function + const char *err; + struct mg_bind_opts opts; + struct mg_connection *nc = NULL; + memset(&opts, 0x00, sizeof(opts)); + opts.error_string = &err; + nc = mg_bind_opt(&mgr, "80", ev_handler, opts); // Create listening connection and add it to the event manager + if (nc == NULL) { + printf("Failed to create listener: %s\n", err); + return 1; + } + mg_set_protocol_http_websocket(nc); + + for (;;) { // Start infinite event loop + bleconfig_poll(); + mg_mgr_poll(&mgr, 0); + } + } + +} diff --git a/examples/nRF51/http/myboard.h b/examples/nRF51/http/myboard.h new file mode 100644 index 00000000..56db3976 --- /dev/null +++ b/examples/nRF51/http/myboard.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2014-2016 Cesanta Software Limited + * All rights reserved + */ + +/* clang-format off */ + +#include "boards.h" + +#define LED_ONE BSP_LED_0_MASK /**< Is on when device is advertising. */ +#define LED_TWO BSP_LED_1_MASK /**< Is on when device is connected. */ +#define LED_THREE BSP_LED_2_MASK +#define LED_FOUR BSP_LED_3_MASK +#define TCP_CONNECTED_LED BSP_LED_2_MASK /**< Is on when a TCP connection is established. */ +#define DISPLAY_LED_0 BSP_LED_0_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define DISPLAY_LED_1 BSP_LED_1_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define DISPLAY_LED_2 BSP_LED_2_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define DISPLAY_LED_3 BSP_LED_3_MASK /**< LED used for displaying mod 4 of data payload received on UDP port. */ +#define ALL_APP_LED (BSP_LED_0_MASK | BSP_LED_1_MASK | \ + BSP_LED_2_MASK | BSP_LED_3_MASK) /**< Define used for simultaneous operation of all application LEDs. */ + diff --git a/examples/nRF51/http/sdk_config.h b/examples/nRF51/http/sdk_config.h new file mode 100644 index 00000000..db0d5ad1 --- /dev/null +++ b/examples/nRF51/http/sdk_config.h @@ -0,0 +1,204 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/* clang-format off */ + +#ifndef SDK_CONFIG_H__ +#define SDK_CONFIG_H__ + +/** + * @defgroup sdk_config SDK Configuration + * @{ + * @ingroup sdk_common + * @{ + * @details All parameters that allow configuring/tuning the SDK based on application/ use case + * are defined here. + */ + + +/** + * @defgroup mem_manager_config Memory Manager Configuration + * @{ + * @addtogroup sdk_config + * @{ + * @details This section defines configuration of memory manager module. + */ + +/** + * @brief Maximum memory blocks identified as 'small' blocks. + * + * @details Maximum memory blocks identified as 'small' blocks. + * Minimum value : 0 (Setting to 0 disables all 'small' blocks) + * Maximum value : 255 + * Dependencies : None. + */ +#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 8 + +/** + * @brief Size of each memory blocks identified as 'small' block. + * + * @details Size of each memory blocks identified as 'small' block. + * Memory block are recommended to be word-sized. + * Minimum value : 32 + * Maximum value : A value less than the next pool size. If only small pool is used, this + * can be any value based on availability of RAM. + * Dependencies : MEMORY_MANAGER_SMALL_BLOCK_COUNT is non-zero. + */ +#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 128 + +/** + * @brief Maximum memory blocks identified as 'medium' blocks. + * + * @details Maximum memory blocks identified as 'medium' blocks. + * Minimum value : 0 (Setting to 0 disables all 'medium' blocks) + * Maximum value : 255 + * Dependencies : None. + */ +#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 4 + +/** + * @brief Size of each memory blocks identified as 'medium' block. + * + * @details Size of each memory blocks identified as 'medium' block. + * Memory block are recommended to be word-sized. + * Minimum value : A value greater than the small pool size if defined, else 32. + * Maximum value : A value less than the next pool size. If only medium pool is used, this + * can be any value based on availability of RAM. + * Dependencies : MEMORY_MANAGER_MEDIUM_BLOCK_COUNT is non-zero. + */ +#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256 + +/** + * @brief Maximum memory blocks identified as 'medium' blocks. + * + * @details Maximum memory blocks identified as 'medium' blocks. + * Minimum value : 0 (Setting to 0 disables all 'large' blocks) + * Maximum value : 255 + * Dependencies : None. + */ +#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 3 + +/** + * @brief Size of each memory blocks identified as 'medium' block. + * + * @details Size of each memory blocks identified as 'medium' block. + * Memory block are recommended to be word-sized. + * Minimum value : A value greater than the small &/ medium pool size if defined, else 32. + * Maximum value : Any value based on availability of RAM. + * Dependencies : MEMORY_MANAGER_MEDIUM_BLOCK_COUNT is non-zero. + */ +#define MEMORY_MANAGER_LARGE_BLOCK_SIZE 1024 + +/** + * @brief Disable debug trace in the module. + * + * @details Set this define to 1 to enable debug trace in the module, else set to 0. + * Possible values : 0 or 1. + * Dependencies : ENABLE_DEBUG_LOG_SUPPORT. If this flag is not defined, no + * trace is observed even if this define is set to 1. + */ +#define MEM_MANAGER_DISABLE_LOGS 1 + +/** + * @brief Disables API parameter checks in the module. + * + * @details Set this define to 1 to disable checks on API parameters in the module. + * API parameter checks are added to ensure right parameters are passed to the + * module. These checks are useful during development phase but be redundant + * once application is developed. Disabling this can result in some code saving. + * Possible values : 0 or 1. + * Dependencies : None. + */ +#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0 +/** @} */ +/** @} */ + + +/** + * @defgroup iot_context_manager Context Manager Configurations. + * @{ + * @addtogroup iot_config + * @{ + * @details This section defines configuration of Context Manager. + */ + +/** + * @brief Disable debug trace in the module. + * + * @details Set this define to 1 to enable debug trace in the module, else set to 0. + * Possible values : 0 or 1. + * Dependencies : ENABLE_DEBUG_LOG_SUPPORT. If this flag is not defined, no + * trace is observed even if this define is set to 1. + */ +#define IOT_CONTEXT_MANAGER_DISABLE_LOGS 1 + +/** + * @brief Disables API parameter checks in the module. + * + * @details Set this define to 1 to disable checks on API parameters in the module. + * API parameter checks are added to ensure right parameters are passed to the + * module. These checks are useful during development phase but be redundant + * once application is developed. Disabling this can result in some code saving. + * Possible values : 0 or 1. + * Dependencies : None. + */ +#define IOT_CONTEXT_MANAGER_DISABLE_API_PARAM_CHECK 0 + +/** + * @brief Maximum number of supported context identifiers. + * + * @details Maximum value of 16 is preferable to correct decompression. + * Minimum value : 1 + * Maximum value : 16 + * Dependencies : None. + */ +#define IOT_CONTEXT_MANAGER_MAX_CONTEXTS 16 + +/** + * @brief Maximum number of supported context's table. + * + * @details If value is equal to BLE_IPSP_MAX_CHANNELS then all interface will have + * its own table which is preferable. + * Minimum value : 1 + * Maximum value : BLE_IPSP_MAX_CHANNELS + * Dependencies : None. + */ +#define IOT_CONTEXT_MANAGER_MAX_TABLES 1 +/** @} */ +/** @} */ + + +/** + * @defgroup lwip_nrf51_driver nRF51 lwIP driver + * @{ + * @addtogroup iot_config + * @{ + * @details This section defines configuration of nRF51 lwIP driver. + */ + +/** + * @brief Disable debug trace in the module. + * + * @details Set this define to 1 to enable debug trace in the module, else set to 0. + * Possible values : 0 or 1. + * Dependencies : ENABLE_DEBUG_LOG_SUPPORT. If this flag is not defined, no + * trace is observed even if this define is set to 1. + */ +#define NRF51_LWIP_DRIVER_DISABLE_LOGS 1 + +/** @} */ +/** @} */ + +/** @} */ +/** @} */ + +#endif // SDK_CONFIG_H__ diff --git a/mongoose.c b/mongoose.c index 9a311930..477e8edf 100644 --- a/mongoose.c +++ b/mongoose.c @@ -10243,7 +10243,7 @@ int gettimeofday(struct timeval *tp, void *tzp) { * All rights reserved */ -#if CS_PLATFORM == CS_P_NRF52 && defined(__ARMCC_VERSION) +#if (CS_PLATFORM == CS_P_NRF51 || CS_PLATFORM == CS_P_NRF52) && defined(__ARMCC_VERSION) int gettimeofday(struct timeval *tp, void *tzp) { /* TODO */ tp->tv_sec = 0; diff --git a/mongoose.h b/mongoose.h index 08b6b90b..387ed145 100644 --- a/mongoose.h +++ b/mongoose.h @@ -53,6 +53,7 @@ #define CS_P_NXP_KINETIS 9 #define CS_P_NRF52 10 #define CS_P_PIC32_HARMONY 11 +#define CS_P_NRF51 12 /* If not specified explicitly, we guess platform by defines. */ #ifndef CS_PLATFORM @@ -834,6 +835,46 @@ int inet_pton(int af, const char *src, void *dst); #endif /* CS_PLATFORM == CS_P_MBED */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ */ #ifdef MG_MODULE_LINES +#line 1 "common/platforms/platform_nrf51.h" +#endif +/* + * Copyright (c) 2014-2016 Cesanta Software Limited + * All rights reserved + */ +#ifndef CS_COMMON_PLATFORMS_PLATFORM_NRF51_H_ +#define CS_COMMON_PLATFORMS_PLATFORM_NRF51_H_ +#if CS_PLATFORM == CS_P_NRF51 + +#include +#include +#include +#include +#include +#include + +#define to64(x) strtoll(x, NULL, 10) + +#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL +#define MG_ENABLE_IPV6 1 + +/* + * For ARM C Compiler, make lwip to export `struct timeval`; for other + * compilers, suppress it. + */ +#if !defined(__ARMCC_VERSION) +# define LWIP_TIMEVAL_PRIVATE 0 +#else +struct timeval; +int gettimeofday(struct timeval *tp, void *tzp); +#endif + +#define INT64_FMT PRId64 +#define SIZE_T_FMT "u" + + +#endif /* CS_PLATFORM == CS_P_NRF51 */ +#endif /* CS_COMMON_PLATFORMS_PLATFORM_NRF51_H_ */ +#ifdef MG_MODULE_LINES #line 1 "common/platforms/platform_nrf52.h" #endif /*