Merge branch 'gatt'
This commit is contained in:
+19
-2
@@ -90,8 +90,7 @@ extern "C"
|
||||
#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4
|
||||
// Include the Service Changed characteristic in the Attribute Table.
|
||||
#define NRF_SDH_BLE_SERVICE_CHANGED 0
|
||||
// Static maximum MTU size.
|
||||
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
|
||||
|
||||
// This setting configures how Stack events are dispatched to the application.
|
||||
#define NRF_SDH_DISPATCH_MODEL 2 /* SoftDevice events are to be fetched manually. */
|
||||
|
||||
@@ -149,6 +148,24 @@ extern "C"
|
||||
MAJOR_PRODUCT_NUMBER, MINOR_PRODUCT_NUMBER, MAJOR_VERSION_NUMBER, MINOR_VERSION_NUMBER \
|
||||
}
|
||||
|
||||
// Maximum number of peripheral links.
|
||||
#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1
|
||||
// Maximum number of central links.
|
||||
#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0
|
||||
// Total link count.
|
||||
#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1
|
||||
|
||||
// Enable GATT module.
|
||||
#define NRF_BLE_GATT_ENABLED 1
|
||||
// Priority with which BLE events are dispatched to the GATT module.
|
||||
#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1
|
||||
// Requested BLE GAP data length to be negotiated.
|
||||
#define NRF_SDH_BLE_GAP_DATA_LENGTH 27
|
||||
// GAP event length. The time set aside for this connection on every connection interval in 1.25 ms units.
|
||||
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6
|
||||
// Static maximum MTU size.
|
||||
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\bmd380_sdk\components\ble\nrf_ble_gatt\nrf_ble_gatt.c" />
|
||||
<ClCompile Include="..\bmd380_sdk\components\libraries\atomic\nrf_atomic.c" />
|
||||
<ClCompile Include="..\bmd380_sdk\components\libraries\atomic_flags\nrf_atflags.c" />
|
||||
<ClCompile Include="..\bmd380_sdk\components\libraries\balloc\nrf_balloc.c" />
|
||||
@@ -162,6 +163,7 @@
|
||||
<ClCompile Include="le_adv.c" />
|
||||
<ClCompile Include="le_bas.c" />
|
||||
<ClCompile Include="le_gap.c" />
|
||||
<ClCompile Include="le_gatt.c" />
|
||||
<ClCompile Include="main.c" />
|
||||
<None Include="nRF52811_XXAA_s140.lds" />
|
||||
<None Include="nRF52840_XXAA_S140_reserve.lds" />
|
||||
@@ -222,6 +224,7 @@
|
||||
<ClCompile Include="$(BSP_ROOT)\nRF5x\modules\nrfx\hal\nrf_ecb.c" />
|
||||
<ClCompile Include="$(BSP_ROOT)\nRF5x\modules\nrfx\hal\nrf_nvmc.c" />
|
||||
<ClCompile Include="$(BSP_ROOT)\nRF5x\modules\nrfx\soc\nrfx_atomic.c" />
|
||||
<ClInclude Include="..\bmd380_sdk\components\ble\nrf_ble_gatt\nrf_ble_gatt.h" />
|
||||
<ClInclude Include="..\bmd380_sdk\components\libraries\atomic\nrf_atomic.h" />
|
||||
<ClInclude Include="..\bmd380_sdk\components\libraries\atomic\nrf_atomic_internal.h" />
|
||||
<ClInclude Include="..\bmd380_sdk\components\libraries\atomic\nrf_atomic_sanity_check.h" />
|
||||
|
||||
@@ -232,6 +232,12 @@
|
||||
<Filter Include="Header files\ble\common">
|
||||
<UniqueIdentifier>{defffc43-551c-4791-967b-7d0aee507516}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source files\ble\nrf_ble_gatt">
|
||||
<UniqueIdentifier>{345707cc-7a27-4c28-94b4-19df7d90e78d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header files\ble\nrf_ble_gatt">
|
||||
<UniqueIdentifier>{b6e27cec-5179-4ec4-8f4d-e7e9fbaabae8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c">
|
||||
@@ -1326,6 +1332,12 @@
|
||||
<ClCompile Include="le_bas.c">
|
||||
<Filter>Source files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="le_gatt.c">
|
||||
<Filter>Source files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\bmd380_sdk\components\ble\nrf_ble_gatt\nrf_ble_gatt.c">
|
||||
<Filter>Source files\ble\nrf_ble_gatt</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="nRF52840_XXAA_S140_reserve.lds">
|
||||
@@ -1579,6 +1591,9 @@
|
||||
<ClInclude Include="..\bmd380_sdk\components\libraries\atomic_flags\nrf_atflags.h">
|
||||
<Filter>Header files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\bmd380_sdk\components\ble\nrf_ble_gatt\nrf_ble_gatt.h">
|
||||
<Filter>Header files\ble\nrf_ble_gatt</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\bmd380_sdk\external\segger_rtt\license\license.txt">
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "app_config.h"
|
||||
#include "apply_old_config.h"
|
||||
#include "sdk_config.h"
|
||||
|
||||
#include "nrf_log.h"
|
||||
#include "nrf_log_ctrl.h"
|
||||
#include "nrf_log_default_backends.h"
|
||||
|
||||
#include "nrf_delay.h"
|
||||
#include "nrf_gpio.h"
|
||||
|
||||
#include "nrf_sdh.h"
|
||||
#include "nrf_sdh_ble.h"
|
||||
#include "nrf_sdh_freertos.h"
|
||||
|
||||
#include "ble_gatt.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */
|
||||
void le_gatt_init(void) {
|
||||
ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
@@ -33,7 +33,22 @@ extern "C"
|
||||
|
||||
static void le_evt_handler(ble_evt_t const *p_ble_evt, void *p_context)
|
||||
{
|
||||
// TODO...
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
{
|
||||
ret_code_t err_code;
|
||||
case BLE_GAP_EVT_PHY_UPDATE_REQUEST: {
|
||||
NRF_LOG_DEBUG("PHY update request.");
|
||||
ble_gap_phys_t const phys = {
|
||||
.rx_phys = BLE_GAP_PHY_AUTO,
|
||||
.tx_phys = BLE_GAP_PHY_AUTO,
|
||||
};
|
||||
err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void le_stack_Init(void)
|
||||
@@ -107,6 +122,9 @@ int main(void)
|
||||
extern void le_gap_init(const char *device_name, uint16_t usAppearance);
|
||||
le_gap_init(ELITE_DEVICE_NAME, BLE_APPEARANCE_UNKNOWN);
|
||||
|
||||
extern void le_gatt_init(void);
|
||||
le_gatt_init();
|
||||
|
||||
extern void le_adv_init(uint8_t ble_conn_cfg_tag);
|
||||
le_adv_init(APP_BLE_CONN_CFG_TAG);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user