forked from arduino-libraries/ArduinoBLE
-
Notifications
You must be signed in to change notification settings - Fork 19
Added support for custom app_conf.h #35
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fa0a24b
added support for custom ble app conf
KMeldgaard 975ca4b
added Configuration section to README
KMeldgaard 22807d0
Added header guards
KMeldgaard 6e16c1a
Merge pull request #1 from KMeldgaard/feature/custom_app_conf
KMeldgaard d89cfda
Update src/utility/STM32Cube_FW/app_conf_default.h
KMeldgaard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,158 +1,20 @@ | ||
/** | ||
****************************************************************************** | ||
* File Name : app_conf.h | ||
* Description : Application configuration file for STM32WPAN Middleware. | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* <h2><center>© Copyright (c) 2020 STMicroelectronics. | ||
* All rights reserved.</center></h2> | ||
* | ||
* This software component is licensed by ST under Ultimate Liberty license | ||
* SLA0044, the "License"; You may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at: | ||
* www.st.com/SLA0044 | ||
* | ||
****************************************************************************** | ||
*/ | ||
//----------------------------- | ||
// @file app_conf.h | ||
// @author Kasper Meldgaard | ||
// @brief Wrapper for BLE app configuration based on comment by fpistm | ||
// (https://github.com/stm32duino/STM32duinoBLE/issues/34). | ||
// @date 15-11-2021 | ||
// @copyright Copyright (c) 2021 | ||
|
||
/* Define to prevent recursive inclusion -------------------------------------*/ | ||
#ifndef APP_CONF_H | ||
#define APP_CONF_H | ||
|
||
#include "hw.h" | ||
#include "ble_bufsize.h" | ||
#include "hw.h" | ||
|
||
|
||
/****************************************************************************** | ||
* Application Config | ||
******************************************************************************/ | ||
|
||
/**< generic parameters ******************************************************/ | ||
/* HCI related defines */ | ||
|
||
#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F | ||
#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C | ||
#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D | ||
#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) | ||
#define HCI_RESET 0x0C03 | ||
|
||
#ifndef BLE_SHARED_MEM_BYTE_ORDER | ||
#define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST | ||
#if __has_include("app_conf_custom.h") | ||
#include "app_conf_custom.h" | ||
#endif | ||
#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 | ||
|
||
/** | ||
* Define Tx Power | ||
*/ | ||
#define CFG_TX_POWER (0x18) /* -0.15dBm */ | ||
|
||
/****************************************************************************** | ||
* BLE Stack | ||
******************************************************************************/ | ||
/** | ||
* Maximum number of simultaneous connections that the device will support. | ||
* Valid values are from 1 to 8 | ||
*/ | ||
#define CFG_BLE_NUM_LINK 8 | ||
|
||
/** | ||
* Maximum number of Services that can be stored in the GATT database. | ||
* Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services | ||
*/ | ||
#define CFG_BLE_NUM_GATT_SERVICES 8 | ||
|
||
/** | ||
* Maximum number of Attributes | ||
* (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) | ||
* that can be stored in the GATT database. | ||
* Note that certain characteristics and relative descriptors are added automatically during device initialization | ||
* so this parameters should be 9 plus the number of user Attributes | ||
*/ | ||
#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 | ||
|
||
/** | ||
* Maximum supported ATT_MTU size | ||
*/ | ||
#define CFG_BLE_MAX_ATT_MTU (156) | ||
|
||
/** | ||
* Size of the storage area for Attribute values | ||
* This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: | ||
* - attribute value length | ||
* - 5, if UUID is 16 bit; 19, if UUID is 128 bit | ||
* - 2, if server configuration descriptor is used | ||
* - 2*DTM_NUM_LINK, if client configuration descriptor is used | ||
* - 2, if extended properties is used | ||
* The total amount of memory needed is the sum of the above quantities for each attribute. | ||
*/ | ||
#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) | ||
|
||
/** | ||
* Prepare Write List size in terms of number of packet | ||
*/ | ||
//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) | ||
#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) | ||
|
||
/** | ||
* Number of allocated memory blocks | ||
*/ | ||
//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) | ||
#define CFG_BLE_MBLOCK_COUNT (0x79) | ||
/** | ||
* Enable or disable the Extended Packet length feature. Valid values are 0 or 1. | ||
*/ | ||
#define CFG_BLE_DATA_LENGTH_EXTENSION 1 | ||
|
||
/** | ||
* Sleep clock accuracy in Slave mode (ppm value) | ||
*/ | ||
#define CFG_BLE_SLAVE_SCA 500 | ||
|
||
/** | ||
* Sleep clock accuracy in Master mode | ||
* 0 : 251 ppm to 500 ppm | ||
* 1 : 151 ppm to 250 ppm | ||
* 2 : 101 ppm to 150 ppm | ||
* 3 : 76 ppm to 100 ppm | ||
* 4 : 51 ppm to 75 ppm | ||
* 5 : 31 ppm to 50 ppm | ||
* 6 : 21 ppm to 30 ppm | ||
* 7 : 0 ppm to 20 ppm | ||
*/ | ||
#define CFG_BLE_MASTER_SCA 0 | ||
|
||
/** | ||
* Source for the 32 kHz slow speed clock | ||
* 1 : internal RO | ||
* 0 : external crystal ( no calibration ) | ||
*/ | ||
#define CFG_BLE_LSE_SOURCE 0 | ||
|
||
/** | ||
* Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) | ||
*/ | ||
#define CFG_BLE_HSE_STARTUP_TIME 0x148 | ||
|
||
/** | ||
* Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) | ||
*/ | ||
#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF ) | ||
|
||
/** | ||
* Viterbi Mode | ||
* 1 : enabled | ||
* 0 : disabled | ||
*/ | ||
#define CFG_BLE_VITERBI_MODE 1 | ||
|
||
/** | ||
* LL Only Mode | ||
* 1 : LL Only | ||
* 0 : LL + Host | ||
*/ | ||
#define CFG_BLE_LL_ONLY 1 | ||
|
||
#endif /* APP_CONF_H */ | ||
#include "app_conf_default.h" | ||
|
||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||
#endif /* APP_CONF_H */ |
This file contains hidden or 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,185 @@ | ||
/** | ||
****************************************************************************** | ||
* File Name : app_conf.h | ||
* Description : Application configuration file for STM32WPAN Middleware. | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* <h2><center>© Copyright (c) 2020 STMicroelectronics. | ||
* All rights reserved.</center></h2> | ||
* | ||
* This software component is licensed by ST under Ultimate Liberty license | ||
* SLA0044, the "License"; You may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at: | ||
* www.st.com/SLA0044 | ||
* | ||
****************************************************************************** | ||
*/ | ||
|
||
/* Define to prevent recursive inclusion -------------------------------------*/ | ||
#ifndef APP_CONF_DEFAULT_H | ||
#define APP_CONF_DEFAULT_H | ||
|
||
/****************************************************************************** | ||
* Application Config | ||
******************************************************************************/ | ||
|
||
/**< generic parameters ******************************************************/ | ||
/* HCI related defines */ | ||
|
||
#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F | ||
#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C | ||
#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D | ||
#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) | ||
#define HCI_RESET 0x0C03 | ||
|
||
#ifndef BLE_SHARED_MEM_BYTE_ORDER | ||
#define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST | ||
#endif | ||
#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 | ||
|
||
/** | ||
* Define Tx Power | ||
*/ | ||
#ifndef CFG_TX_POWER | ||
#define CFG_TX_POWER (0x18) /* -0.15dBm */ | ||
#endif | ||
|
||
/****************************************************************************** | ||
* BLE Stack | ||
******************************************************************************/ | ||
/** | ||
* Maximum number of simultaneous connections that the device will support. | ||
* Valid values are from 1 to 8 | ||
*/ | ||
#ifndef CFG_BLE_NUM_LINK | ||
#define CFG_BLE_NUM_LINK 8 | ||
#endif | ||
|
||
/** | ||
* Maximum number of Services that can be stored in the GATT database. | ||
* Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user | ||
* services | ||
*/ | ||
#ifndef CFG_BLE_NUM_GATT_SERVICES | ||
#define CFG_BLE_NUM_GATT_SERVICES 8 | ||
#endif | ||
|
||
/** | ||
* Maximum number of Attributes | ||
* (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the | ||
* services) that can be stored in the GATT database. Note that certain characteristics and relative descriptors are | ||
* added automatically during device initialization so this parameters should be 9 plus the number of user Attributes | ||
*/ | ||
#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES | ||
#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 | ||
#endif | ||
|
||
/** | ||
* Maximum supported ATT_MTU size | ||
*/ | ||
#ifndef CFG_BLE_MAX_ATT_MTU | ||
#define CFG_BLE_MAX_ATT_MTU (156) | ||
#endif | ||
|
||
/** | ||
* Size of the storage area for Attribute values | ||
* This value depends on the number of attributes used by application. In particular the sum of the following | ||
* quantities (in octets) should be made for each attribute: | ||
* - attribute value length | ||
* - 5, if UUID is 16 bit; 19, if UUID is 128 bit | ||
* - 2, if server configuration descriptor is used | ||
* - 2*DTM_NUM_LINK, if client configuration descriptor is used | ||
* - 2, if extended properties is used | ||
* The total amount of memory needed is the sum of the above quantities for each attribute. | ||
*/ | ||
#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE | ||
#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) | ||
#endif | ||
|
||
/** | ||
* Prepare Write List size in terms of number of packet | ||
*/ | ||
//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) | ||
#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE | ||
#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) | ||
#endif | ||
|
||
/** | ||
* Number of allocated memory blocks | ||
*/ | ||
//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, | ||
// CFG_BLE_NUM_LINK)) | ||
#ifndef CFG_BLE_MBLOCK_COUNT | ||
#define CFG_BLE_MBLOCK_COUNT (0x79) | ||
#endif | ||
|
||
/** | ||
* Enable or disable the Extended Packet length feature. Valid values are 0 or 1. | ||
*/ | ||
#ifndef CFG_BLE_DATA_LENGTH_EXTENSION | ||
#define CFG_BLE_DATA_LENGTH_EXTENSION 1 | ||
#endif | ||
|
||
/** | ||
* Sleep clock accuracy in Slave mode (ppm value) | ||
*/ | ||
#ifndef CFG_BLE_SLAVE_SCA | ||
#define CFG_BLE_SLAVE_SCA 500 | ||
#endif | ||
|
||
/** | ||
* Sleep clock accuracy in Master mode | ||
* 0 : 251 ppm to 500 ppm | ||
* 1 : 151 ppm to 250 ppm | ||
* 2 : 101 ppm to 150 ppm | ||
* 3 : 76 ppm to 100 ppm | ||
* 4 : 51 ppm to 75 ppm | ||
* 5 : 31 ppm to 50 ppm | ||
* 6 : 21 ppm to 30 ppm | ||
* 7 : 0 ppm to 20 ppm | ||
*/ | ||
#ifndef CFG_BLE_MASTER_SCA | ||
#define CFG_BLE_MASTER_SCA 0 | ||
#endif | ||
|
||
/** | ||
* Source for the 32 kHz slow speed clock | ||
* 1 : internal RO | ||
* 0 : external crystal ( no calibration ) | ||
*/ | ||
#ifndef CFG_BLE_LSE_SOURCE | ||
#define CFG_BLE_LSE_SOURCE 0 | ||
#endif | ||
|
||
/** | ||
* Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) | ||
*/ | ||
#ifndef CFG_BLE_HSE_STARTUP_TIME | ||
#define CFG_BLE_HSE_STARTUP_TIME 0x148 | ||
#endif | ||
|
||
/** | ||
* Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) | ||
*/ | ||
#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH | ||
#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) | ||
#endif | ||
|
||
/** | ||
* Viterbi Mode | ||
* 1 : enabled | ||
* 0 : disabled | ||
*/ | ||
#define CFG_BLE_VITERBI_MODE 1 | ||
|
||
/** | ||
* LL Only Mode | ||
* 1 : LL Only | ||
* 0 : LL + Host | ||
*/ | ||
#define CFG_BLE_LL_ONLY 1 | ||
|
||
#endif /* APP_CONF_DEFAULT_H */ | ||
|
||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.