Commit 0d235075 authored by cacu's avatar cacu
Browse files

Include only the driver extracted from pc-ble-driver-js as a dependency

for bindings
parent 541f868c
# 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.
cmake_minimum_required (VERSION 2.6)
# Do not allow in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-source build. Build out-of-source instead.")
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# Environment settings (nrf51_sdk location)
if("${NRF51_SDK_PATH}" STREQUAL "")
message(FATAL_ERROR "NRF51_SDK_PATH must be set to a valid SDK path.")
endif()
set (nrf51_sdk ${NRF51_SDK_PATH})
# Project root path
set (repo_root_path ${CMAKE_SOURCE_DIR})
# Check if necessary parameters is passed to cmake
if("${SERIALIZATION_VERSION}" STREQUAL "")
message(FATAL_ERROR "SERIALIZATION_VERSION not set. Not able to continue build. Please set with -DSERIALIZATION_VERSION=X.Y.Z invoking cmake.")
endif()
if("${SERIALIZATION_REVISION}" STREQUAL "")
message(FATAL_ERROR "SERIALIZATION_REVISION not set. Not able to continue build. Please set with -DSERIALIZATION_REVISION=X when invoking cmake.")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(
-g -O0
)
set(Boost_USE_MULTITHREADED ON)
# Find the necessary boost components on system
find_package ( Boost 1.54.0 REQUIRED COMPONENTS thread system regex date_time chrono )
# Include boost as a system include so that the compiler do not nag about issues in boost header files
include_directories (
src/serialization
include
include/internal
include/internal/transport
include/internal/sdk/codec
include/internal/sdk/misc
SYSTEM ${Boost_INCLUDE_DIRS}
)
add_definitions(
-DDEBUG
)
file(GLOB_RECURSE LIB_C_SOURCES src/*.c)
file(GLOB_RECURSE LIB_CPP_SOURCES src/*.cpp)
# Determine if we must add -fPIC since it is required for x64 architectures
if(UNIX AND NOT WIN32 AND NOT APPLE)
find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
if(CMAKE_UNAME)
exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
add_definitions(-fPIC)
endif()
endif()
endif()
# Add definitions used by compiler when compiling source files
add_definitions(
-DSD_RPC_EXPORTS
-DHCI_LINK_CONTROL # Adds support for Link Control packets according to the HCI standard
)
# Remove nRF51 hardware specific files from the SDK that prevents compilation.
# Since the C++ preprocessor will try to search the local directory first before searching
# other directories the we have to remove the files below. That way the preprocessor will use
# nrf_svc.h from override folder instead.
file(REMOVE ${nrf51_sdk}/components/softdevice/s130/headers/nrf_svc.h) # included by ${nrf51_sdk_components}/softdevice/s130/headers/ble_gap.h
# Force .c files to be compiled with the C++ compiler
set_source_files_properties(
${LIB_C_SOURCES}
PROPERTIES
LANGUAGE CXX
)
# S130 specific include paths
set (nrf51_sdk_components ${nrf51_sdk}/components)
set (nrf51_sdk_codecs ${nrf51_sdk_components}/serialization/application/codecs)
set (nrf51_sdk_codecs_s130 ${nrf51_sdk_codecs}/s130)
add_library(pc-ble-driver STATIC ${LIB_C_SOURCES} ${LIB_CPP_SOURCES})
set (s130_includes
${repo_root_path}/driver/inc
${repo_root_path}/driver/inc_override
${nrf51_sdk}/framework/cunit/include_override
${nrf51_sdk_components}/drivers_nrf/hal
${nrf51_sdk_components}/drivers_nrf/uart
${nrf51_sdk_components}/libraries/crc16
${nrf51_sdk_components}/libraries/scheduler
${nrf51_sdk_components}/libraries/timer
${nrf51_sdk_components}/libraries/util
${nrf51_sdk_components}/serialization/application/hal
${nrf51_sdk_components}/serialization/application/transport
${nrf51_sdk_components}/serialization/common
${nrf51_sdk_components}/serialization/common/transport
${nrf51_sdk_components}/serialization/common/transport/ser_phy
${nrf51_sdk_components}/softdevice/common/softdevice_handler
${nrf51_sdk_components}/toolchain/gcc
${nrf51_sdk_components}/toolchain
${nrf51_sdk_components}/device
${nrf51_sdk_components}/drivers_nrf/hal
${nrf51_sdk_codecs_s130}/serializers
${nrf51_sdk_components}/serialization/common/struct_ser/s130
${nrf51_sdk_components}/softdevice/s130 #needed for '#include "headers/nrf_soc.h"'
${nrf51_sdk_components}/softdevice/s130/headers
)
# Specify libraries to link serialization library with
target_link_libraries (pc-ble-driver PRIVATE ${Boost_LIBRARIES})
# Add subdirectories
if("${ARTIFACT}" STREQUAL "driver")
add_subdirectory(driver)
elseif("${ARTIFACT}" STREQUAL "binding")
add_subdirectory(python)
else()
message(FATAL_ERROR "ARTIFACT variable has to be specified, it can be driver or binding")
endif()
add_executable(test_uart test/test_uart.cpp)
target_link_libraries(test_uart PRIVATE ${Boost_LIBRARIES})
License Agreement
Nordic Semiconductor ASA (“Nordic”)
nRF51 Bluetooth Smart GATT/GAP Driver
You (“You” or “Licensee”) must carefully and thoroughly read this License Agreement (“Agreement”), and accept to adhere to this Agreement before downloading, installing and/or using any software or content in the nRF51 Bluetooth Smart GATT/GAP Driver (“NRF51_BLE_DRIVER”) provided herewith.
YOU ACCEPT THIS LICENSE AGREEMENT BY (A) CLICKING ACCEPT OR AGREE TO THIS LICENSE AGREEMENT, WHERE THIS OPTION IS MADE AVAILABLE TO YOU; OR (B) BY ACTUALLY USING THE NRF51_BLE_DRIVER, IN THIS CASE YOU AGREE THAT THE USE OF THE NRF51_BLE_DRIVER CONSTITUTES ACCEPTANCE OF THE LICENSING AGREEMENT FROM THAT POINT ONWARDS.
IF YOU DO NOT AGREE TO BE BOUND BY THE TERMS OF THIS AGREEMENT, THEN DO NOT DOWNLOAD, INSTALL/COMPLETE INSTALLATION OF, OR IN ANY OTHER WAY MAKE USE OF THE NRF51_BLE_DRIVER OR RELATED CONTENT.
1. Grant of License
Subject to the terms in this Agreement Nordic grants Licensee a limited, non-exclusive, non-transferable, non-sub licensable, revocable license (“License”): (a) to use the NRF51_BLE_DRIVER as a development platform solely in connection with a Nordic Integrated Circuit (“nRF IC”), (b) to modify any source code contained in the NRF51_BLE_DRIVER solely as necessary to implement products developed by Licensee that incorporate an nRF IC (“Licensee Product”), and (c) to distribute the NRF51_BLE_DRIVER solely as implemented in Licensee Product. Licensee shall not use the NRF51_BLE_DRIVER for any purpose other than specifically authorized herein.
2. Title
As between the parties, Nordic retains full rights, title, and ownership of the NRF51_BLE_DRIVER and any and all patents, copyrights, trade secrets, trade names, trademarks, and other intellectual property rights in and to the NRF51_BLE_DRIVER.
3. No Modifications or Reverse Engineering
Licensee shall not, modify, reverse engineer, disassemble, decompile or otherwise attempt to discover the source code of any non-source code parts of the NRF51_BLE_DRIVER including, but not limited to pre-compiled binaries and object code.
4. Distribution Restrictions
Except as set forward in Section 1 above, the Licensee may not disclose or distribute any or all parts of the NRF51_BLE_DRIVER to any third party. Licensee agrees to provide reasonable security precautions to prevent unauthorized access to or use of the NRF51_BLE_DRIVER as proscribed herein. Licensee also agrees that use of and access to the NRF51_BLE_DRIVER will be strictly limited to the employees and subcontractors of the Licensee necessary for the performance of development, verification and production tasks under this Agreement. The Licensee is responsible for making such employees and subcontractors agree on complying with the obligations concerning use and non-disclosure of the NRF51_BLE_DRIVER.
5. No Other Rights
Licensee shall use the NRF51_BLE_DRIVER only in compliance with this Agreement and shall refrain from using the NRF51_BLE_DRIVER in any way that may be contrary to this Agreement.
6. Fees
Nordic grants the License to the Licensee free of charge provided that the Licensee undertakes the obligations in the Agreement and warrants to comply with the Agreement.
7. DISCLAIMER OF WARRANTY
THE NRF51_BLE_DRIVER IS PROVIDED “AS IS" WITHOUT WARRANTY OF ANY KIND EXPRESS OR IMPLIED AND NEITHER NORDIC, ITS LICENSORS OR AFFILIATES NOR THE COPYRIGHT HOLDERS MAKE ANY REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR THAT THE NRF51_BLE_DRIVER WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. THERE IS NO WARRANTY BY NORDIC OR BY ANY OTHER PARTY THAT THE FUNCTIONS CONTAINED IN THE NRF51_BLE_DRIVER WILL MEET THE REQUIREMENTS OF LICENSEE OR THAT THE OPERATION OF THE NRF51_BLE_DRIVER WILL BE UNINTERRUPTED OR ERROR-FREE. LICENSEE ASSUMES ALL RESPONSIBILITY AND RISK FOR THE SELECTION OF THE NRF51_BLE_DRIVER TO ACHIEVE LICENSEE’S INTENDED RESULTS AND FOR THE INSTALLATION, USE AND RESULTS OBTAINED FROM IT.
8. No Support
Nordic is not obligated to furnish or make available to Licensee any further information, software, technical information, know-how, show-how, bug-fixes or support. Nordic reserves the right to make changes to the NRF51_BLE_DRIVER without further notice.
9. Limitation of Liability
In no event shall Nordic, its employees or suppliers or affiliates be liable for any lost profits, revenue, sales, data or costs of procurement of substitute goods or services, property damage, personal injury, interruption of business, loss of business information or for any special, direct, indirect, incidental, economic, punitive, special or consequential damages, however caused and whether arising under contract, tort, negligence, or other theory of liability arising out of the use of or inability to use the NRF51_BLE_DRIVER, even if Nordic or its employees or suppliers or affiliates are advised of the possibility of such damages. Because some countries/states/ jurisdictions do not allow the exclusion or limitation of liability, but may allow liability to be limited, in such cases, Nordic, its employees or licensors or affiliates’ liability shall be limited to USD 50.
10. Breach of Contract
Upon a breach of contract by the Licensee, Nordic is entitled to damages in respect of any direct loss which can be reasonably attributed to the breach by the Licensee. If the Licensee has acted with gross negligence or willful misconduct, the Licensee shall cover both direct and indirect costs for Nordic.
11. Indemnity
Licensee undertakes to indemnify, hold harmless and defend Nordic and its directors, officers, affiliates, shareholders, employees and agents from and against any claims or lawsuits, including attorney's fees, that arise or result of the Licensee’s execution of the License and which is not due to causes for which Nordic is responsible.
12. Governing Law
This Agreement shall be construed according to the laws of Norway, and hereby submits to the exclusive jurisdiction of the Oslo tingrett.
13. Assignment
Licensee shall not assign this Agreement or any rights or obligations hereunder without the prior written consent of Nordic.
14. Termination
Without prejudice to any other rights, Nordic may cancel this Agreement if Licensee does not abide by the terms and conditions of this Agreement. Upon termination Licensee must promptly cease the use of the License and destroy all copies of the Licensed Technology and any other material provided by Nordic or its affiliate, or produced by the Licensee in connection with the Agreement or the Licensed Technology.
License Agreement
Nordic Semiconductor ASA (“Nordic”)
pc-ble-driver-js: NodeJS AddOn for pc-ble-driver
You (“You” or “Licensee”) must carefully and thoroughly read this License Agreement (“Agreement”), and accept to adhere to this Agreement before downloading, installing and/or using any software or content in the “PC-BLE-DRIVER-JS” provided herewith.
YOU ACCEPT THIS LICENSE AGREEMENT BY (A) CLICKING ACCEPT OR AGREE TO THIS LICENSE AGREEMENT, WHERE THIS OPTION IS MADE AVAILABLE TO YOU; OR (B) BY ACTUALLY USING THE PC-BLE-DRIVER-JS, IN THIS CASE YOU AGREE THAT THE USE OF THE PC-BLE-DRIVER-JS CONSTITUTES ACCEPTANCE OF THE LICENSING AGREEMENT FROM THAT POINT ONWARDS.
IF YOU DO NOT AGREE TO BE BOUND BY THE TERMS OF THIS AGREEMENT, THEN DO NOT DOWNLOAD, INSTALL/COMPLETE INSTALLATION OF, OR IN ANY OTHER WAY MAKE USE OF THE PC-BLE-DRIVER-JS OR RELATED CONTENT.
1. Grant of License
Subject to the terms in this Agreement Nordic grants Licensee a limited, non-exclusive, non-transferable, non-sub licensable, revocable license (“License”): (a) to use the PC-BLE-DRIVER-JS as a development platform solely in connection with a Nordic Integrated Circuit (“nRF IC”), (b) to modify any source code contained in the PC-BLE-DRIVER-JS solely as necessary to implement products developed by Licensee that incorporate an nRF IC (“Licensee Product”), and (c) to distribute the PC-BLE-DRIVER-JS solely as implemented in Licensee Product. Licensee shall not use the PC-BLE-DRIVER-JS for any purpose other than specifically authorized herein.
2. Title
As between the parties, Nordic retains full rights, title, and ownership of the PC-BLE-DRIVER-JS and any and all patents, copyrights, trade secrets, trade names, trademarks, and other intellectual property rights in and to the PC-BLE-DRIVER-JS.
3. No Modifications or Reverse Engineering
Licensee shall not, modify, reverse engineer, disassemble, decompile or otherwise attempt to discover the source code of any non-source code parts of the PC-BLE-DRIVER-JS including, but not limited to pre-compiled binaries and object code.
4. Distribution Restrictions
Except as set forward in Section 1 above, the Licensee may not disclose or distribute any or all parts of the PC-BLE-DRIVER-JS to any third party. Licensee agrees to provide reasonable security precautions to prevent unauthorized access to or use of the PC-BLE-DRIVER-JS as proscribed herein. Licensee also agrees that use of and access to the PC-BLE-DRIVER-JS will be strictly limited to the employees and subcontractors of the Licensee necessary for the performance of development, verification and production tasks under this Agreement. The Licensee is responsible for making such employees and subcontractors agree on complying with the obligations concerning use and non-disclosure of the PC-BLE-DRIVER-JS.
5. No Other Rights
Licensee shall use the PC-BLE-DRIVER-JS only in compliance with this Agreement and shall refrain from using the PC-BLE-DRIVER-JS in any way that may be contrary to this Agreement.
6. Fees
Nordic grants the License to the Licensee free of charge provided that the Licensee undertakes the obligations in the Agreement and warrants to comply with the Agreement.
7. DISCLAIMER OF WARRANTY
THE PC-BLE-DRIVER-JS IS PROVIDED “AS IS" WITHOUT WARRANTY OF ANY KIND EXPRESS OR IMPLIED AND NEITHER NORDIC, ITS LICENSORS OR AFFILIATES NOR THE COPYRIGHT HOLDERS MAKE ANY REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR THAT THE PC-BLE-DRIVER-JS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. THERE IS NO WARRANTY BY NORDIC OR BY ANY OTHER PARTY THAT THE FUNCTIONS CONTAINED IN THE PC-BLE-DRIVER-JS WILL MEET THE REQUIREMENTS OF LICENSEE OR THAT THE OPERATION OF THE PC-BLE-DRIVER-JS WILL BE UNINTERRUPTED OR ERROR-FREE. LICENSEE ASSUMES ALL RESPONSIBILITY AND RISK FOR THE SELECTION OF THE PC-BLE-DRIVER-JS TO ACHIEVE LICENSEE’S INTENDED RESULTS AND FOR THE INSTALLATION, USE AND RESULTS OBTAINED FROM IT.
8. No Support
Nordic is not obligated to furnish or make available to Licensee any further information, software, technical information, know-how, show-how, bug-fixes or support. Nordic reserves the right to make changes to the PC-BLE-DRIVER-JS without further notice.
9. Limitation of Liability
In no event shall Nordic, its employees or suppliers or affiliates be liable for any lost profits, revenue, sales, data or costs of procurement of substitute goods or services, property damage, personal injury, interruption of business, loss of business information or for any special, direct, indirect, incidental, economic, punitive, special or consequential damages, however caused and whether arising under contract, tort, negligence, or other theory of liability arising out of the use of or inability to use the PC-BLE-DRIVER-JS, even if Nordic or its employees or suppliers or affiliates are advised of the possibility of such damages. Because some countries/states/ jurisdictions do not allow the exclusion or limitation of liability, but may allow liability to be limited, in such cases, Nordic, its employees or licensors or affiliates’ liability shall be limited to USD 50.
10. Breach of Contract
Upon a breach of contract by the Licensee, Nordic is entitled to damages in respect of any direct loss which can be reasonably attributed to the breach by the Licensee. If the Licensee has acted with gross negligence or willful misconduct, the Licensee shall cover both direct and indirect costs for Nordic.
11. Indemnity
Licensee undertakes to indemnify, hold harmless and defend Nordic and its directors, officers, affiliates, shareholders, employees and agents from and against any claims or lawsuits, including attorney's fees, that arise or result of the Licensee’s execution of the License and which is not due to causes for which Nordic is responsible.
12. Governing Law
This Agreement shall be construed according to the laws of Norway, and hereby submits to the exclusive jurisdiction of the Oslo tingrett.
13. Assignment
Licensee shall not assign this Agreement or any rights or obligations hereunder without the prior written consent of Nordic.
14. Termination
Without prejudice to any other rights, Nordic may cancel this Agreement if Licensee does not abide by the terms and conditions of this Agreement. Upon termination Licensee must promptly cease the use of the License and destroy all copies of the Licensed Technology and any other material provided by Nordic or its affiliate, or produced by the Licensee in connection with the Agreement or the Licensed Technology.
# nRF51 Bluetooth Smart GATT/GAP Driver
# Introduction
pc-lib-ble-driver is a serialization library over serial port required by the following repos:
## Introduction
The nRF51 Bluetooth Smart GATT/GAP Driver (from now on called the Driver) consists of a standard C dynamic library that lets a PC application set up and interact with an nRF51 SoftDevice through API function calls. The library mirrors the nRF51 S130 SoftDevice API and makes it available to the PC application.
* [pc-ble-driver library](https://github.com/NordicSemiconductor/pc-ble-driver)
* [pc-ble-driver-js library](https://github.com/NordicSemiconductor/pc-ble-driver-js)
Commands sent from the library are encoded and sent over UART to the nRF51 chip. The connectivity application running on the nRF51 chip decodes the commands and feeds them to the SoftDevice. Command responses and events are encoded and sent from the nRF51 chip to the PC library where they are decoded.
The library makes it possible to create applications on a PC that, in code, can be similar to applications that are running on the nRF51 chip.
Having this kind of API gives the following benefits:
* Setting up a peer device for a Device Under Test (DUT) using a test script.
* Coherent BLE APIs on a PC and an nRF51 chip.
* Creating prototype and test applications for an nRF51 chip on a PC.
* Migrating code between an nRF51 chip and a PC.
## Disclaimer
No guarantees are given regarding stability or backward compatibility. Interfaces are subject to change.
# Building from source
## Dependencies
The following dependencies are required for building the Driver:
* [Boost](http://www.boost.org/users/download) (=1.56.0)
* [cmake](http://www.cmake.org/cmake/resources/software.html) (>=2.8.X)
* [Python](http://www.python.org/download/) (>=2.7.6, <3.0.0)
* [Swig](http://www.swig.org/download.html) (=2.0.12)
* git client
## Get the source code
The source code is available from GitHub at the following URL:
<https://github.com/NordicSemiconductor/pc-ble-driver.git>
## Setup of the build environment
### Windows
- Download the [MinGW] (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.8.2/threads-posix/dwarf/) Compiler Suite.
- Install MinGW Compiler Suite according to the [instructions](http://www.mingw.org/wiki/InstallationHOWTOforMinGW).
- Verify that gnu patch utility is available in PATH. (e.g. c:\program files(x86)\git\bin)
- Install cmake according to the [installation instructions for Windows](http://www.cmake.org/install/).
- Install [Microsoft Visual C++ Compiler for Python](http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266).
- Extract, compile and install Boost. We assume Boost is extracted into c:\Boost\boost_1_56_0. Issue the following commands in the directory:
bootstrap
b2 toolset=gcc link=static runtime-link=shared threading=multi
### Ubuntu Linux
Run the following command to install compiler, dependencies and tools:
curl -L https://raw.githubusercontent.com/NordicSemiconductor/pc-ble-driver/master/scripts/setup-ubuntu-linux.sh | sh
You will be asked for root password during this process.
### OS X
Run the following command to install compiler, dependencies and tools:
curl -L https://raw.githubusercontent.com/NordicSemiconductor/pc-ble-driver/master/scripts/setup-osx.sh | sh
You will be asked for root password during this process.
## Compilation and packaging of the Driver
- Create a build directory outside the source directory.
- Create a directory to store Nordic Semiconductor software that the Driver depends on.
- Download the necessary Nordic Semiconductor dependencies and compile the Driver and Python binding with the command below.
mkdir build
mkdir deps
cd build
python ..\pc-ble-driver\scripts\build.py -srp \absolute_path\my_deps_directory -d -b (for Unix systems, replace \ with /)
- To package the release into a zip file, run the following command:
python ..\pc-ble-driver\scripts\build.py -srp \absolute_path\my_deps_directory -p (for Unix systems, replace \ with /)
- If you later want to run the Behave tests you will need to compile all the examples, to do this run this command:
python ..\pc-ble-driver\scripts\build.py -srp \absolute_path\my_deps_directory -e (for Unix systems, replace \ with /)
## Running of tests
We have different types of tests:
- BDD tests
- Packaging tests
- Integration/unit tests (without hardware)
- Integration tests (with hardware)
### Packaging and BDD tests
Setup:
- Set the environment variable PYTHONUNBUFFERED to something or else Python will buffer stdout, which will make the BDD tests fail.
- Set the environment variable NORDICSEMI_NRF51_BLE_DRIVER_BUILD_PATH to the build directory of the Driver
- Set the environment variable NORDICSEMI_TARGET_SETUP to the file name of the test targets configuration.
The test targets configuration contains information about nRF5X DK UART port and the drive letter it has been assigned to. Below is an example of a test_targets.json file:
{
"targets":
[
{
"id": 1,
"drive": "E:\\",
"serial_port": "COM8",
"pca": "PCA10028",
"segger_sn": "680595231"
},
{
"id": 2,
"drive": "D:\\",
"serial_port": "COM7",
"pca": "PCA10028",
"segger_sn": "681768567"
}
]
}
First, build and package the driver.
Then, issue the following command to run the packaging tests:
cd <ROOT>\driver\tests
python setup.py test
There is a bug in Behave that prevents us from running the Behave tests from setup.py. A workaround is to run BDD tests from the bdd directory:
cd <ROOT>\driver\tests\bdd
behave
The BDD tests require nRF51 hardware connected to the computer. A combination of two devices of the following is required, two of one kind or one of each:
- nRF51 Development Kit (pca10028), or
- nRF51 Development Dongle (pca10031)
### Integration/unit tests
First, build the driver.
Then, issue the following command to run the integration/unit tests:
python ..\pc-ble-driver\scripts\build.py -srp <ROOT>\my_deps_directory -t (for Unix systems, replace \ with /)
#### uart_cpp_test
For the unit test uart_cpp_test, a set of loopback serial ports is required. You can achieve this by using:
- a pair of usb-to-serial adapters interconnected with a null-modem cable
- a pair of virtual serial ports (emulated serial ports) configured to be interconnected
uart_cpp_test also requires the environment variables TESTSERIALPORT1 and TESTSERIALPORT2 to be set to the serial port names:
Example values:
TESTSERIALPORT1=COM20
TESTSERIALPORT2=COM21
If you want to **disable uart_cpp_test**, comment out the test in the file *driver/tests/CMakeLists.txt*:
#add_test(NAME uart_cpp_test COMMAND "uart_cpp_test" ${test_params})
## Platform specific notes
- Linux:
- udev rules for tty symlink and usb mount points are found in folder tests/config/linux/. These rules must be put in /etc/udev/rules.d/
- Remember to set the environment variable LD_LIBRARY_PATH to directories containing the libs*_nrf51_ble_driver.so so that the tests find the libs*_nrf51_ble_driver.so
- OSX:
- We have not discovered yet how to force the mount point for JLink devices on MacOSX, because of which the tty/mount point location will come out of sync
- Remember to set the environment variable DYLD_LIBRARY_PATH to directories containing the libs*_nrf51_ble_driver.dylib so that the tests find the libs*_nrf51_ble_driver.dylib
The library is included as a submodule by the 2 repositories above, see the documentation on those for
details on how to build and use the library.
# 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.
project(ble_driver CXX)
# Boost specific settings (link statically (on MinGW) with the multithreaded libraries)
if(MINGW OR APPLE)
set(Boost_USE_STATIC_LIBS ON)
endif()
if(APPLE)
message(STATUS "Remember to build boost with the following command line when using brew:")
message(STATUS "CFLAGS=-fPIC brew install --verbose --env=std --build-from-source boost")
endif(APPLE)
set(Boost_USE_MULTITHREADED ON)
# Find the necessary boost components on system
find_package ( Boost 1.54.0 REQUIRED COMPONENTS thread system regex date_time chrono )
# Filename for .def for S130
set(s130_target_def_file s130_nrf51_ble_driver.def)
# Add WIN32 specific settings
if(WIN32)
# Values used when generating version.rc
string(REPLACE "." "," SERIALIZATION_VERSION_WIN32 ${SERIALIZATION_VERSION})
enable_language(RC) # Enable compilation of WIN32 resource files
add_definitions(
-D_WIN32_WINNT=0x0502
)
# Generate dll information for win32 build.
# Values specified above are used in the version.rc.in file
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@ONLY
)
# Generate batch file for creating .lib file
get_filename_component(VS_DIR [HKEY_CURRENT_USER\\Software\\Microsoft\\DevDiv\\VCForPython\\9.0;InstallDir] REALPATH CACHE)
string(REPLACE "/" "\\" VS_DIR ${VS_DIR})
set(VS_DIR "${VS_DIR}\\VC\\bin")
set(VS_LIB_PATH "${VS_DIR}\\lib")
string(REPLACE ".def" ".lib" s130_target_lib_file ${s130_target_def_file})
configure_file(
${CMAKE_SOURCE_DIR}/scripts/msvc_def_to_lib.bat.in
${CMAKE_CURRENT_BINARY_DIR}/msvc_def_to_lib.bat
@ONLY)
endif()
# Include boost as a system include so that the compiler do not nag about issues in boost header files
include_directories (
${s130_includes}
SYSTEM ${Boost_INCLUDE_DIRS}
)
set (s130_src
${nrf51_sdk_codecs_s130}/middleware/app_mw_ble.c
${nrf51_sdk_codecs_s130}/middleware/app_mw_ble_gap.c
${nrf51_sdk_codecs_s130}/middleware/app_mw_ble_gap.c
${nrf51_sdk_codecs_s130}/middleware/app_mw_ble_gattc.c
${nrf51_sdk_codecs_s130}/middleware/app_mw_ble_l2cap.c
${nrf51_sdk_codecs_s130}/middleware/app_mw_ble_gatts.c
${nrf51_sdk_codecs_s130}/serializers/app_ble_gap_sec_keys.c
${nrf51_sdk_codecs_s130}/serializers/app_ble_user_mem.c
${nrf51_sdk_codecs_s130}/serializers/ble_enable.c
${nrf51_sdk_codecs_s130}/serializers/ble_event.c
${nrf51_sdk_codecs_s130}/serializers/ble_evt_tx_complete.c
${nrf51_sdk_codecs_s130}/serializers/ble_evt_user_mem_release.c
${nrf51_sdk_codecs_s130}/serializers/ble_evt_user_mem_request.c
${nrf51_sdk_codecs_s130}/serializers/ble_opt_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_opt_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_tx_buffer_count_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_user_mem_reply.c
${nrf51_sdk_codecs_s130}/serializers/ble_uuid_decode.c
${nrf51_sdk_codecs_s130}/serializers/ble_uuid_encode.c
${nrf51_sdk_codecs_s130}/serializers/ble_uuid_vs_add.c
${nrf51_sdk_codecs_s130}/serializers/ble_version_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_address_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_address_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_adv_data_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_adv_start.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_adv_stop.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_appearance_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_appearance_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_auth_key_reply.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_authenticate.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_conn_param_update.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_conn_sec_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_connect.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_connect_cancel.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_device_name_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_device_name_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_disconnect.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_encrypt.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_adv_report.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_auth_key_request.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_auth_status.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_conn_param_update.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_conn_param_update_request.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_conn_sec_update.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_connected.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_disconnected.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_passkey_display.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_rssi_changed.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_scan_req_report.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_sec_info_request.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_sec_params_request.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_sec_request.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_evt_timeout.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_ppcp_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_ppcp_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_rssi_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_rssi_start.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_rssi_stop.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_scan_start.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_scan_stop.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_sec_info_reply.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_sec_params_reply.c
${nrf51_sdk_codecs_s130}/serializers/ble_gap_tx_power_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_char_value_by_uuid_read.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_char_values_read.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_characteristics_discover.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_descriptors_discover.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_char_disc_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_char_val_by_uuid_read_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_char_vals_read_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_desc_disc_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_hvx.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_prim_srvc_disc_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_read_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_rel_disc_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_timeout.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_evt_write_rsp.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_hv_confirm.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_primary_services_discover.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_read.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_relationships_discover.c
${nrf51_sdk_codecs_s130}/serializers/ble_gattc_write.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_characteristic_add.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_descriptor_add.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_evt_hvc.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_evt_rw_authorize_request.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_evt_sc_confirm.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_evt_sys_attr_missing.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_evt_timeout.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_evt_write.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_hvx.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_include_add.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_rw_authorize_reply.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_service_add.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_service_changed.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_sys_attr_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_sys_attr_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_value_get.c
${nrf51_sdk_codecs_s130}/serializers/ble_gatts_value_set.c
${nrf51_sdk_codecs_s130}/serializers/ble_l2cap_cid_register.c
${nrf51_sdk_codecs_s130}/serializers/ble_l2cap_cid_unregister.c
${nrf51_sdk_codecs_s130}/serializers/ble_l2cap_evt_rx.c
${nrf51_sdk_codecs_s130}/serializers/ble_l2cap_tx.c
${nrf51_sdk_codecs_s130}/serializers/power_system_off.c
${nrf51_sdk_components}/serialization/common/struct_ser/s130/ble_struct_serialization.c
${nrf51_sdk_components}/serialization/common/struct_ser/s130/ble_gattc_struct_serialization.c
${nrf51_sdk_components}/serialization/common/struct_ser/s130/ble_gatts_struct_serialization.c
${nrf51_sdk_components}/serialization/common/struct_ser/s130/ble_gap_struct_serialization.c
)
set (common_src
src/sd_rpc.c
src/app_log.c
src/app_log_utility.c
src/uart.cpp
src/uart_boost.cpp
src/uart_settings.cpp
src/uart_settings_boost.cpp
src/timer.cpp
src/timer_boost.cpp
src/app_timer_pc.c
src/app_uart_pc.c