-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Service Builder: Descriptor discovery working
Aggregate work: * Add free_lists to service_builder * Loosen up ble::gatt:attrbute types to deal with discovered properties. * gatt::characteristic, gatt::descriptor, gatt::service all get default ctors and are no longer const only data members. This way their uuids, types and associations can be changed as services are discovered. Add attribute_type::undefined for creating objects which do not yet know their attribute type. * Add service_container::find_service_handle_assoc() * Issue #21: overloaded non-const member functions should call const members * Add service_builder::discovery_iterator * nordic_ble_gattc_operations.cc add debug log messages to each call * Add external directory for 3rd party source and libraries. Has its own Makefile Executes download of Nordic SDK, googletest. Unzips/de-archive the compressed file format. For Nordic's SDK, execute nordic/sdk-modifiled/replace_sdk_files. * Implement unit tests within googletest Issue #6 * Add unit tests for service and characteristics classes Issue #5 * Add version info for BLE central, peripheral Version information consists of a version string built from a git tag (TBD) and the 4 left-hand bytes of the git sha1 (implemented). The version info struct is located at the top of FLASH in the section .version_info. * Device Information Service (DIS) Updated. Uses Nordic NRF_FICR->DEVICEADDR to create a unique 8-byte serial number. * Segger RTT buffer allocations provided by application Issue #30 Previously #define nonsense inside the header segger/segger_rtt_conf.h Now the application allocates the buffer and passes it in to the Segger RTT module. * Change namespace write_data -> io * Add io::output_stream* logger::get_output_stream() * Move discovery_iterator into service_container * Fix broken unit tests test_vwritef, test_write_data
- Loading branch information
Showing
131 changed files
with
9,287 additions
and
8,179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
_build | ||
.segger_sn | ||
external/downloads | ||
external/nRF5_SDK_15.2.0_9412b96 | ||
external/googletest* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* @file ble/gatt_declaration.cc | ||
* @copyright (c) 2018, natersoz. Distributed under the Apache 2.0 license. | ||
*/ | ||
|
||
#include "gatt_declaration.h" | ||
#include "int_to_string.h" | ||
#include "std_error.h" | ||
|
||
namespace ble | ||
{ | ||
namespace gatt | ||
{ | ||
|
||
std::to_chars_result properties::to_chars(char *begin, char *end) const | ||
{ | ||
if (end - begin < 6) | ||
{ | ||
return std::to_chars_result{begin, std::errc::value_too_large}; | ||
} | ||
|
||
*begin++ = '0'; | ||
*begin++ = 'x'; | ||
|
||
uint16_t const props = this->get(); | ||
std::size_t const count = int_to_hex(begin, end - begin, props, 4u); | ||
begin += count; | ||
|
||
if (end - begin < 10) // We need 10 more characters to complete | ||
{ // the conversion. | ||
return std::to_chars_result {begin, std::errc::value_too_large}; | ||
} | ||
|
||
*begin++ = ' '; | ||
|
||
uint16_t const all_write_types = | ||
ble::gatt::properties::write_without_response | | ||
ble::gatt::properties::write | | ||
ble::gatt::properties::write_with_signature | | ||
ble::gatt::properties::write_reliable | | ||
ble::gatt::properties::write_aux ; | ||
|
||
*begin++ = ((props & ble::gatt::properties::broadcast)? 'b' : '-'); | ||
*begin++ = ((props & ble::gatt::properties::read)? 'r' : '-'); | ||
*begin++ = ((props & all_write_types)? 'w' : '-'); | ||
*begin++ = ((props & ble::gatt::properties::notify)? 'n' : '-'); | ||
*begin++ = ((props & ble::gatt::properties::indicate)? 'i' : '-'); | ||
|
||
if (props & ble::gatt::properties::write_without_response) { *begin++ = 'N'; } | ||
if (props & ble::gatt::properties::write_with_signature) { *begin++ = 'S'; } | ||
if (props & ble::gatt::properties::write_reliable) { *begin++ = 'R'; } | ||
if (props & ble::gatt::properties::write_aux) { *begin++ = 'A'; } | ||
|
||
// If there is room, write the null terminator. | ||
if (end - begin > 1) { *begin++ = 0; } | ||
|
||
return std::to_chars_result {begin, errc_success}; | ||
} | ||
|
||
std::to_chars_result declaration::to_chars(char *begin, char *end) const | ||
{ | ||
using signed_size_t = std::make_signed<std::size_t>::type; | ||
if (end - begin < static_cast<signed_size_t>(conversion_length)) | ||
{ | ||
return std::to_chars_result{begin, std::errc::value_too_large}; | ||
} | ||
|
||
char const type_prefix[] = "type: 0x"; | ||
memcpy(begin, type_prefix, sizeof(type_prefix)); | ||
begin += std::size(type_prefix) - 1u; // Overwrite null terminator. | ||
|
||
uint16_t const attr_type = static_cast<uint16_t>(this->attribute_type); | ||
std::size_t const count = int_to_hex(begin, end - begin, attr_type, 4u); | ||
begin += count; | ||
|
||
char const properties_prefix[] = " props: "; | ||
memcpy(begin, properties_prefix, sizeof(properties_prefix)); | ||
begin += std::size(properties_prefix) - 1u; // Overwrite null terminator. | ||
return this->properties.to_chars(begin, end); | ||
} | ||
|
||
} // namespace gatt | ||
} // namespace ble | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.