Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ after_success:

before_install:
- sudo apt-get update -qq
- wget https://cmake.org/files/v3.11/cmake-3.11.4-Linux-x86_64.sh
- wget https://cmake.org/files/v3.14/cmake-3.14.2-Linux-x86_64.sh
- mkdir /opt/cmake
- sh cmake-3.11.4-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
- sh cmake-3.14.2-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
- wget https://launchpad.net/%7Eboost-latest/+archive/ubuntu/ppa/+files/libboost1.55-dev_1.55.0-1ppa1%7Esaucy1_amd64.deb
- sudo dpkg --install libboost1.55-dev_1.55.0-1ppa1~saucy1_amd64.deb
# - openssl aes-256-cbc -K $encrypted_eb6359394db6_key -iv $encrypted_eb6359394db6_iv -in config/travisci_rsa.enc -out config/travisci_rsa -d
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.14)
# Prevent in source build, add this options before project keyword
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
Expand All @@ -7,15 +7,21 @@ project(lib_bluetoe CXX)
add_library(bluetoe_iface INTERFACE)
add_library(bluetoe::iface ALIAS bluetoe_iface)
target_include_directories(bluetoe_iface INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(bluetoe_iface INTERFACE cxx_std_11)


add_subdirectory(bluetoe/link_layer)
add_subdirectory(bluetoe/scheduled_radio)
add_subdirectory(bluetoe/hci)
add_subdirectory(bluetoe/utility)
add_subdirectory(bluetoe/sm)
add_subdirectory(bluetoe/services)

if (CMAKE_CROSSCOMPILING)
add_subdirectory(bluetoe/bindings/nrf51)
endif ()
endif()

add_subdirectory(bluetoe/bindings/hci)

if (NOT CMAKE_CROSSCOMPILING)
enable_testing()
Expand Down
13 changes: 13 additions & 0 deletions bluetoe/bindings/hci/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_library(bluetoe_bindings_hci_libusb STATIC libusb.cpp)
add_library(bluetoe::bindings::hci_libusb ALIAS bluetoe_bindings_hci_libusb)

target_include_directories(bluetoe_bindings_hci_libusb
INTERFACE
include_libusb)

target_link_libraries(bluetoe_bindings_hci_libusb
PUBLIC
bluetoe::hci
bluetoe::utility
bluetoe::linklayer
)
14 changes: 14 additions & 0 deletions bluetoe/bindings/hci/include_libusb/bluetoe/device.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef BLUETOE_BINDINGS_HCI_DEVICE_HPP
#define BLUETOE_BINDINGS_HCI_DEVICE_HPP

#include <bluetoe/link_layer.hpp>
#include <bluetoe/libsub.hpp>

namespace bluetoe
{
template < class Server, typename ... Options >
using device = bluetoe::hci::link_layer< Server, hci_details::libsub_transport, Options... >;
}

#endif

14 changes: 14 additions & 0 deletions bluetoe/bindings/hci/include_libusb/bluetoe/libsub.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef BLUETOE_BINDINGS_HCI_LIBUSB_HPP
#define BLUETOE_BINDINGS_HCI_LIBUSB_HPP

namespace bluetoe {

namespace hci_details {
template < typename LinkLayer >
class libsub_transport {

};
}
}

#endif
Empty file added bluetoe/bindings/hci/libusb.cpp
Empty file.
15 changes: 14 additions & 1 deletion bluetoe/bindings/nrf51/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ add_library(bluetoe_bindings_nrf51 STATIC
nrf51.cpp)
add_library(bluetoe::bindings::nrf51 ALIAS bluetoe_bindings_nrf51)

# Currently nrf52 is equal to nrf51, which is wrong if one looks at the details
add_library(bluetoe::bindings::nrf52 ALIAS bluetoe_bindings_nrf51)

target_include_directories(bluetoe_bindings_nrf51 PUBLIC include)

target_link_libraries(bluetoe_bindings_nrf51 PUBLIC bluetoe::utility bluetoe::sm bluetoe::iface bluetoe::linklayer PRIVATE toolchain::${BINDING})
target_link_libraries(bluetoe_bindings_nrf51
PUBLIC
bluetoe::utility
bluetoe::sm
bluetoe::iface
bluetoe::linklayer
bluetoe::scheduled_radio
PRIVATE
toolchain::${BINDING}
)

target_compile_features(bluetoe_bindings_nrf51 PRIVATE cxx_std_11)
target_compile_options(bluetoe_bindings_nrf51 PRIVATE -Wall -pedantic -Wextra -Wfatal-errors -Wno-parentheses)
7 changes: 7 additions & 0 deletions bluetoe/hci/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_policy(SET CMP0079 NEW)

add_library(bluetoe_hci INTERFACE)
add_library(bluetoe::hci ALIAS bluetoe_hci)

target_include_directories(bluetoe_hci INTERFACE include)
target_link_libraries(bluetoe_hci INTERFACE bluetoe::sm bluetoe::iface)
64 changes: 64 additions & 0 deletions bluetoe/hci/include/bluetoe/link_layer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef BLUETOE_HCI_LINK_LAYER_HPP
#define BLUETOE_HCI_LINK_LAYER_HPP

#include <bluetoe/address.hpp>

namespace bluetoe {
namespace hci {

/**
* @brief link layer implementation based on HCI
*/
template <
class Server,
template < typename >
class Transport,
typename ... Options
>
class link_layer : Transport< link_layer< Server, Transport, Options... > >
{
public:
/**
* @brief this function passes the CPU to the link layer implementation
*
* This function should return on certain events to alow user code to do
* usefull things. Details depend on the ScheduleRadio implemention.
*/
void run( Server& );

/**
* @brief initiating the change of communication parameters of an established connection
*
* If it was not possible to initiate the connection parameter update, the function returns false.
* @todo Add parameter that identifies the connection.
*/
bool connection_parameter_update_request( std::uint16_t interval_min, std::uint16_t interval_max, std::uint16_t latency, std::uint16_t timeout );

/**
* @brief terminates the give connection
*
* @todo Add parameter that identifies the connection.
*/
void disconnect();

/**
* @brief fills the given buffer with l2cap advertising payload
*/
std::size_t fill_l2cap_advertising_data( std::uint8_t* buffer, std::size_t buffer_size ) const;

/**
* @brief returns the own local device address
*/
const bluetoe::link_layer::device_address& local_address() const;
private:
};

// implementation
template < class Server, template < typename > class Transport, typename ... Options >
void link_layer< Server, Transport, Options... >::run( Server& )
{
}
}
}

#endif
1 change: 0 additions & 1 deletion bluetoe/link_layer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ add_library(bluetoe_linklayer STATIC
add_library(bluetoe::linklayer ALIAS bluetoe_linklayer)

target_include_directories(bluetoe_linklayer PUBLIC include)
target_link_libraries(bluetoe_linklayer PRIVATE bluetoe::sm bluetoe::iface)
target_compile_features(bluetoe_linklayer PRIVATE cxx_std_11)
target_compile_options(bluetoe_linklayer PRIVATE -Wall -pedantic -Wextra -Wfatal-errors)
5 changes: 5 additions & 0 deletions bluetoe/scheduled_radio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_library(bluetoe_scheduled_radio INTERFACE)
add_library(bluetoe::scheduled_radio ALIAS bluetoe_scheduled_radio)

target_include_directories(bluetoe_scheduled_radio INTERFACE include)
target_compile_features(bluetoe_linklayer PRIVATE cxx_std_11)
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#define BLUETOE_LINK_LAYER_ADVERTISING_HPP

#include <bluetoe/meta_tools.hpp>
#include "address.hpp"
#include "buffer.hpp"
#include "delta_time.hpp"
#include "ll_meta_types.hpp"
#include <bluetoe/address.hpp>
#include <bluetoe/buffer.hpp>
#include <bluetoe/delta_time.hpp>
#include <bluetoe/ll_meta_types.hpp>

/**
* @file bluetoe/link_layer/advertising.hpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef BLUETOE_LINK_LAYER_LINK_LAYER_HPP
#define BLUETOE_LINK_LAYER_LINK_LAYER_HPP

#include "buffer.hpp"
#include "delta_time.hpp"
#include "ll_options.hpp"
#include "address.hpp"
#include "channel_map.hpp"
#include "notification_queue.hpp"
#include "connection_callbacks.hpp"
#include "connection_event_callback.hpp"
#include "l2cap_signaling_channel.hpp"
#include "white_list.hpp"
#include "advertising.hpp"
#include <bluetoe/buffer.hpp>
#include <bluetoe/delta_time.hpp>
#include <bluetoe/ll_options.hpp>
#include <bluetoe/address.hpp>
#include <bluetoe/channel_map.hpp>
#include <bluetoe/notification_queue.hpp>
#include <bluetoe/connection_callbacks.hpp>
#include <bluetoe/connection_event_callback.hpp>
#include <bluetoe/l2cap_signaling_channel.hpp>
#include <bluetoe/white_list.hpp>
#include <bluetoe/advertising.hpp>
#include <bluetoe/meta_types.hpp>
#include <bluetoe/attribute.hpp>
#include <bluetoe/meta_tools.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <cassert>
#include <cstdlib>

#include "buffer.hpp"
#include <bluetoe/buffer.hpp>

namespace bluetoe {
namespace link_layer {
Expand Down
113 changes: 77 additions & 36 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,96 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.14)

# Prevent in source build, add this options before project keyword
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

project(bluetoe_examples CXX C)

if (NOT CMAKE_CROSSCOMPILING)
message(ERROR " examples can only be cross compiled to arm cortex-m, missing -Dtoolchain_file on cmake invocation?")
return()
endif()
if (NOT BINDING)
message(ERROR " A binding must be defined. Use -DBINDING=nrf51. Current available bindings are nrf51, nrf52")
return()
message(FATAL_ERROR " A binding must be defined. Use -DBINDING=nrf51. Current available bindings are nrf51, nrf52")
endif()

set(supported_bindings nrf51 nrf52 hci_libusb)
set(cross_compile_bindings nrf51 nrf52)

list(FIND supported_bindings "${BINDING}" binding_pos)

if (${binding_pos} EQUAL -1)
message(FATAL_ERROR " not supported binding: ${BINDING}. Please choose one out of ${supported_bindings}")
endif()

if (NOT CMAKE_CROSSCOMPILING)
list(FIND cross_compile_bindings "${BINDING}" cross_binding_pos)

if (NOT ${cross_binding_pos} EQUAL -1)
message(FATAL_ERROR " examples can only be cross compiled to arm cortex-m, missing -Dtoolchain_file on cmake invocation?")
endif()
endif()

# include hardware specific compile options and definitions that must be apllied to the whole project
include(${BINDING}_toolchain_support/platform.cmake)
#set global compile options that are hardware independent, these will be used to build the applications (examples)
#and will also be used to build bluetoe library
# add global compile options
add_compile_options(-ffunction-sections -fdata-sections)
#toolchain support targets, these are C and asm only, dont add cpp flags yet
add_subdirectory(${BINDING}_toolchain_support)

if (CMAKE_CROSSCOMPILING)
# include hardware specific compile options and definitions that must be apllied to the whole project
include(${BINDING}_toolchain_support/platform.cmake)

#toolchain support targets, these are C and asm only, dont add cpp flags yet
add_subdirectory(${BINDING}_toolchain_support)
endif()

#add global options to cpp targets
add_compile_options(-ftemplate-backtrace-limit=0 -fvisibility-inlines-hidden -fno-rtti -fno-exceptions)

#bluetoe library
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/bluetoe)
function(add_bluetoe_example target_name)
add_executable(${target_name} ${target_name}.cpp runtime.cpp)
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${target_name}.elf)
add_dependencies(${target_name} linker_script)
target_compile_options(${target_name} PRIVATE )
target_link_libraries(${target_name} PRIVATE bluetoe::iface
bluetoe::bindings::nrf51
startup::${BINDING}
toolchain::${BINDING}
-lm -lstdc++ -lsupc++
-T${CMAKE_CURRENT_BINARY_DIR}/${BINDING}_toolchain_support/linker_script.ld
-Wl,--gc-sections -Wl,--warn-common
-Wl,-Map,${CMAKE_CURRENT_BINARY_DIR}/${target_name}.map -nostdlib
)
add_custom_target(${target_name}.artifacts ALL
COMMAND ${CMAKE_OBJCOPY} -S -O ihex ${target_name}.elf ${target_name}.hex
COMMAND ${CMAKE_OBJCOPY} -S -O binary --only-section=.text ${target_name}.elf ${target_name}.bin
COMMAND ${CMAKE_OBJDUMP} -hS ${target_name}.elf > ${target_name}.lss
COMMAND ${CMAKE_SIZE} ${target_name}.elf
)
add_dependencies(${target_name}.artifacts ${target_name})
add_custom_target(${target_name}.flash
COMMAND nrfjprog --chiperase --program ${target_name}.hex)
add_dependencies(${target_name}.flash ${target_name}.artifacts)
endfunction()

# Some hardware abstractions, required by the examples
add_subdirectory(hal)

if (CMAKE_CROSSCOMPILING)
function(add_bluetoe_example target_name)
add_executable(${target_name} ${target_name}.cpp runtime.cpp)
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${target_name}.elf)
add_dependencies(${target_name} linker_script)
target_compile_options(${target_name} PRIVATE )
target_link_libraries(${target_name} PRIVATE bluetoe::iface
bluetoe::bindings::${BINDING}
startup::${BINDING}
toolchain::${BINDING}
example_hal
-lm -lstdc++ -lsupc++
-T${CMAKE_CURRENT_BINARY_DIR}/${BINDING}_toolchain_support/linker_script.ld
-Wl,--gc-sections -Wl,--warn-common
-Wl,-Map,${CMAKE_CURRENT_BINARY_DIR}/${target_name}.map -nostdlib
)
add_custom_target(${target_name}.artifacts ALL
COMMAND ${CMAKE_OBJCOPY} -S -O ihex ${target_name}.elf ${target_name}.hex
COMMAND ${CMAKE_OBJCOPY} -S -O binary --only-section=.text ${target_name}.elf ${target_name}.bin
COMMAND ${CMAKE_OBJDUMP} -hS ${target_name}.elf > ${target_name}.lss
COMMAND ${CMAKE_SIZE} ${target_name}.elf
)
add_dependencies(${target_name}.artifacts ${target_name})
add_custom_target(${target_name}.flash
COMMAND nrfjprog --chiperase --program ${target_name}.hex)
add_dependencies(${target_name}.flash ${target_name}.artifacts)
endfunction()
else()

# When not building for embedded hardware, things become more simple
function(add_bluetoe_example target_name)
add_executable(${target_name} ${target_name}.cpp)

target_link_libraries(${target_name}
PRIVATE
bluetoe::bindings::${BINDING}
example_hal
)
endfunction()

endif()

add_bluetoe_example(blinky)
add_bluetoe_example(thermometer)
add_bluetoe_example(cycling_speed_and_cadence)
Expand Down
Loading