Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

applications: connectivity_bridge #1960

Merged
merged 3 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# Applications
/applications/asset_tracker/ @joakimtoe @jtguggedal @rlubos
/applications/connectivity_bridge/ @jtguggedal @nordic-auko
/applications/nrf_desktop/ @pdunaj
# Boards
/boards/ @ioannisg @anangl
Expand Down
23 changes: 23 additions & 0 deletions applications/connectivity_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

cmake_minimum_required(VERSION 3.8.2)

include($ENV{ZEPHYR_BASE}/../nrf/cmake/boilerplate.cmake)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)

target_sources(app PRIVATE src/main.c)

# Include application events and disk files
zephyr_library_include_directories(
src/events
)

# Application sources
add_subdirectory(src/disk)
add_subdirectory(src/events)
add_subdirectory(src/modules)
14 changes: 14 additions & 0 deletions applications/connectivity_bridge/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

menu "Connectivity Bridge"
rsource "src/modules/Kconfig"
rsource "src/events/Kconfig"
endmenu

menu "Zephyr Kernel"
source "Kconfig.zephyr"
endmenu
101 changes: 101 additions & 0 deletions applications/connectivity_bridge/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.. _connectivity_bridge:

Connectivity bridge
###################

The Connectivity bridge application demonstrates the bridge functionality for the Thingy:91 hardware and is an enhancement to the :ref:`usb_uart_bridge_sample` sample.

Additionally, the application also provides an option of adding the bluetooth functionality by making use of the :ref:`nus_service_readme`.

Overview
********

The Connectivity bridge acts as a USB composite device, exposing two UART interfaces to a USB host as two CDC ACM devices.
The mapping of the UART interfaces are done in the following way:

.. list-table::
:header-rows: 1
:align: center

* - UART Interface
- CDC ACM port
* - UART_0
- CDC_0
* - UART_1
- CDC_1

See :ref:`thingy91_serialports` for information on the baud rate configuration for Thingy:91 serial ports.

The application adds the functionality of a USB Mass Storage device, which contains several utility files such as a :file:`README.txt` file.

The application also provides a Bluetooth LE UART Service, which can be enabled by the option ``CONFIG_BRIDGE_BLE_ENABLE``.
This service can be used for a wireless connection to one of the UART interfaces in the following way:

.. list-table::
:header-rows: 1
:align: center

* - USB Interface
- Service mapped
* - UART_0
- :ref:`nus_service_readme`

By default, the Bluetooth LE interface is off, as the connection is not encrypted or authenticated.
It can be turned on at runtime by setting the appropriate option in the :file:`Config.txt` file, which is located on the USB Mass storage Device.

Requirements
************

* One of the following development boards:

* |Thingy91|

* A USB host which can communicate with CDC ACM devices, such as a Windows or Linux PC


Building and running
********************
.. |sample path| replace:: :file:`applications/connectivity_bridge`

.. include:: /includes/build_and_run.txt


Testing
=======

After programming the sample to your board, test it by performing the following steps:

1. Connect the board to the host via a USB cable.
#. Observe that the CDC ACM devices enumerate on the USB host (COM ports on Windows, /dev/tty* on Linux).
#. Use a serial client on the USB host to communicate over the board's UART pins.


Dependencies
************

This sample uses the following |NCS| libraries:

* :ref:`event_manager`
* :ref:`nus_service_readme`

In addition, it uses the following Zephyr libraries:

* ``include/zephyr/types.h``
* ``boards/arm/nrf*/board.h``
* :ref:`zephyr:kernel`:

* ``include/kernel.h``

* :ref:`zephyr:api_peripherals`:

* ``include/uart.h``
* ``include/usb.h``

* :ref:`zephyr:usb_device_stack`

* :ref:`zephyr:bluetooth_api`:

* ``include/bluetooth/bluetooth.h``
* ``include/bluetooth/gatt.h``
* ``include/bluetooth/hci.h``
* ``include/bluetooth/uuid.h``
108 changes: 108 additions & 0 deletions applications/connectivity_bridge/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# General
CONFIG_REBOOT=y
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_GPIO=y
CONFIG_POLL=y
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_EVENT_MANAGER=y
CONFIG_LINKER_ORPHAN_SECTION_PLACE=y
CONFIG_MPU_STACK_GUARD=y
CONFIG_SPEED_OPTIMIZATIONS=y
CONFIG_DEVICE_POWER_MANAGEMENT=y
CONFIG_SYS_PM_POLICY_APP=y

# Features
CONFIG_BRIDGE_CDC_ENABLE=y
CONFIG_BRIDGE_MSC_ENABLE=y
CONFIG_BRIDGE_BLE_ENABLE=y

# USB
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor"
CONFIG_USB_DEVICE_PRODUCT="Thingy:91 UART"
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x9100
CONFIG_USB_DEVICE_SN="PCA20035 12PLACEHLDRS" # This is overridden at runtime
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=32768
CONFIG_USB_CDC_ACM_DEVICE_COUNT=2

# Disk and file system
CONFIG_DISK_ACCESS=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_LFN=y

# Settings
CONFIG_FCB=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# Logging
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_RTT_MODE_DROP=y

# Event logs
CONFIG_BRIDGE_LOG_MODULE_STATE_EVENT=n
CONFIG_BRIDGE_LOG_UART_DATA_EVENT=n
CONFIG_BRIDGE_LOG_CDC_DATA_EVENT=n
CONFIG_BRIDGE_LOG_BLE_DATA_EVENT=n
CONFIG_BRIDGE_LOG_PEER_CONN_EVENT=n
CONFIG_BRIDGE_LOG_FS_EVENT=n
CONFIG_BRIDGE_LOG_POWER_DOWN_EVENT=n

# UART
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_0_INTERRUPT_DRIVEN=n
CONFIG_UART_1_INTERRUPT_DRIVEN=n
CONFIG_UART_LINE_CTRL=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_0_ASYNC=y
CONFIG_UART_1_ASYNC=y
CONFIG_UART_0_NRF_HW_ASYNC=y
CONFIG_UART_1_NRF_HW_ASYNC=y
CONFIG_UART_0_NRF_HW_ASYNC_TIMER=1
CONFIG_UART_1_NRF_HW_ASYNC_TIMER=2
CONFIG_NRFX_UARTE=y
CONFIG_NRFX_UARTE0=y
CONFIG_NRFX_UARTE1=y
CONFIG_NRFX_TIMER=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_TIMER2=y
CONFIG_NRFX_PPI=y

# BLE
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="Thingy:91 UART"
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=16
CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY=0
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
CONFIG_BT_BONDABLE=n
CONFIG_BT_LL_NRFXLIB=y
CONFIG_BT_MAX_CONN=1
CONFIG_BT_ATT_TX_MAX=10
CONFIG_BT_AUTO_PHY_UPDATE=y
CONFIG_BT_DATA_LEN_UPDATE=y
CONFIG_BT_HCI_ACL_FLOW_CONTROL=y
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_L2CAP_RX_MTU=247
CONFIG_BT_GATT_NUS=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_SMP=y
CONFIG_BT_CTLR=y
CONFIG_BT_CTLR_RX_BUFFERS=10
CONFIG_BT_CTLR_TX_BUFFERS=10
CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
9 changes: 9 additions & 0 deletions applications/connectivity_bridge/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sample:
description: Connectivity Bridge application
name: Connectivity Bridge
tests:
test_build:
build_only: true
build_on_all: true
platform_whitelist: nrf52840_pca20035
tags: ci_build
19 changes: 19 additions & 0 deletions applications/connectivity_bridge/src/disk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

# Write the generated files into the include/generated directory, which
# is already in the system path
set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/)
generate_inc_file_for_target(app thingy91_cdc_acm.cat ${gen_dir}/thingy91_cdc_acm.cat.inc)
generate_inc_file_for_target(app thingy91_cdc_acm.inf ${gen_dir}/thingy91_cdc_acm.inf.inc)

target_sources_ifdef(
CONFIG_BRIDGE_MSC_ENABLE
app PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/readme.c
${CMAKE_CURRENT_SOURCE_DIR}/config.c
${CMAKE_CURRENT_SOURCE_DIR}/thingy91_cdc_acm.cat.c
${CMAKE_CURRENT_SOURCE_DIR}/thingy91_cdc_acm.inf.c)