20 #include "app_util_platform.h"
24 #include "app_timer.h"
25 #include "softdevice_handler.h"
34 #define CENTRAL_LINK_COUNT 7
35 #define PERIPHERAL_LINK_COUNT 1
38 #define DEAD_BEEF 0xDEADBEEF
40 #define NO_DEV_CONNECTED_LED_PATTERN 0x03
41 #define POWER_TRANSFER_LED_PATTERN 0x02
42 #define FAULT_LED_PATTERN 0x01
44 #define NO_DEV_CONNECTED_LED_PATTERN 0x00
45 #define POWER_TRANSFER_LED_PATTERN 0x01
46 #define FAULT_LED_PATTERN 0x02
49 #define BEACON_UUID 0xff, 0xfe, 0x2d, 0x12, 0x1e, 0x4b, 0x0f, 0xa4,\
50 0x99, 0x4e, 0xce, 0xb5, 0x31, 0xf4, 0x05, 0x45
51 #define BEACON_ADV_INTERVAL 400
52 #define BEACON_MAJOR 0x1234
53 #define BEACON_MINOR 0x5678
54 #define BEACON_RSSI 0xC3
56 #define APP_COMPANY_IDENTIFIER 0x0059
58 static ble_beacon_init_t beacon_init;
62 static void beacon_adv_init(void)
74 APP_ERROR_CHECK(err_code);
101 ble_conn_bw_counts_t count = {{0,0,8},{0,0,8}};
104 nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
105 SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
108 ble_enable_params_t ble_enable_params = {0};
113 ble_enable_params.gatts_enable_params.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
114 ble_enable_params.common_enable_params.p_conn_bw_counts = &count;
117 opt.common_opt.conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_LOW;
118 opt.common_opt.conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_LOW;
119 opt.common_opt.conn_bw.role = BLE_GAP_ROLE_CENTRAL;
124 err_code = softdevice_enable(&ble_enable_params);
125 APP_ERROR_CHECK(err_code);
127 err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &opt);
128 APP_ERROR_CHECK(err_code);
131 APP_ERROR_CHECK(err_code);
134 APP_ERROR_CHECK(err_code);
137 APP_ERROR_CHECK(err_code);
141 err_code = sd_nvic_SetPriority(SD_EVT_IRQn, APP_IRQ_PRIORITY_LOW);
142 APP_ERROR_CHECK(err_code);
149 #ifndef INIT_APP_TIMERS_EXTERNALLY
173 #ifdef DEBUG_OUT_ENABLE
uint16_t major
Major identifier to use for 'beacon'.
static void m_sys_evt_dispatch(uint32_t sys_evt)
Dispatch system event, triggered by softdevice.
static void m_ble_evt_dispatch(ble_evt_t *p_evt)
Dispatch BLE event, triggered by softdevice.
void app_beacon_init(ble_beacon_init_t *p_init)
Function for initializing the advertiser module.
int main()
Application main function.
#define PTU_BUTTON_PRESS_LENGTH_DFU_MS
uint16_t manuf_id
Manufacturer ID.
ble_gap_addr_t beacon_addr
BLEe address to be used by the beacon.
#define APP_TIMER_OP_QUEUE_SIZE
static ble_beacon_init_t beacon_init
#define BEACON_ADV_INTERVAL
static void beacon_adv_init(void)
Function for initializing Beacon advertiser.
void ptu_start(void)
Start ptu profile. Here "start" means that profile can start generating events through ptu_evt_handle...
uint8_t rssi
Measured RSSI at 1 meter distance in dBm.
Advertiser module. This module shows an example of using periodic timeslots on the radio when the Sof...
#define PTU_OUTPUT_TX_POWER
uint32_t adv_interval
Advertising interval in milliseconds to be used for 'beacon' advertisements.
void ptu_on_ble_evt(ble_evt_t *p_ble_evt)
Dispatches a BLE stack event to PTU.
#define APP_TIMER_PRESCALER
void app_beacon_start(void)
Function for starting the advertisement.
#define CENTRAL_LINK_COUNT
#define PERIPHERAL_LINK_COUNT
ble_uuid128_t uuid
128 bit proprietary service UUID to include in advertisement packets
static void m_ble_stack_init(void)
Initialize the BLE sofdevice and IRQ handler.
uint16_t minor
Minor identifier to use for 'beacon'.
#define APP_COMPANY_IDENTIFIER
void debug(void)
Process debug commands.
void ptu_init(app_sm_evt_handler_t sm_evt_handler)
Initialize PTU. This function must be called before any other PTU function can be called...