本文整理汇总了C++中sd_ble_gatts_sys_attr_set函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_ble_gatts_sys_attr_set函数的具体用法?C++ sd_ble_gatts_sys_attr_set怎么用?C++ sd_ble_gatts_sys_attr_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sd_ble_gatts_sys_attr_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
APPL_LOG("BLE_GAP_EVT_CONNECTED : %u\n", p_ble_evt->header.evt_id);
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
//err_code = app_timer_start(m_app_timer_id, APP_TIMER_ADC_INTERVAL, NULL);
//APP_ERROR_CHECK(err_code);
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_DISCONNECTED:
APPL_LOG("BLE_GAP_EVT_DISCONNECTED : %u\n", p_ble_evt->header.evt_id);
m_conn_handle = BLE_CONN_HANDLE_INVALID;
//nrf_adc_stop();
//app_timer_stop(m_app_timer_id);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:hirokuma,项目名称:nrf51822_adctest,代码行数:34,代码来源:main.c
示例2: on_ble_peripheral_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_peripheral_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
LEDS_OFF(PERIPHERAL_ADVERTISING_LED);
LEDS_ON(PERIPHERAL_CONNECTED_LED);
m_conn_handle_peripheral = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
LEDS_OFF(PERIPHERAL_CONNECTED_LED);
m_conn_handle_peripheral = BLE_CONN_HANDLE_INVALID;
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
// Pairing not supported
err_code = sd_ble_gap_sec_params_reply(m_conn_handle_peripheral, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle_peripheral, NULL, 0, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
APP_ERROR_CHECK(err_code);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:451506709,项目名称:automated_machine,代码行数:37,代码来源:main.c
示例3: conn_mw_ble_gatts_sys_attr_set
uint32_t conn_mw_ble_gatts_sys_attr_set(uint8_t const * const p_rx_buf,
uint32_t rx_buf_len,
uint8_t * const p_tx_buf,
uint32_t * const p_tx_buf_len)
{
SER_ASSERT_NOT_NULL(p_rx_buf);
SER_ASSERT_NOT_NULL(p_tx_buf);
SER_ASSERT_NOT_NULL(p_tx_buf_len);
uint16_t conn_handle;
uint8_t sys_attr[BLE_GATTS_VAR_ATTR_LEN_MAX];
uint8_t * p_sys_attr = sys_attr;
uint16_t sys_attr_len = sizeof (sys_attr);
uint32_t flags;
uint32_t err_code = NRF_SUCCESS;
uint32_t sd_err_code;
err_code = ble_gatts_sys_attr_set_req_dec(p_rx_buf, rx_buf_len, &conn_handle, &p_sys_attr,
&sys_attr_len, &flags);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
sd_err_code = sd_ble_gatts_sys_attr_set(conn_handle, p_sys_attr, sys_attr_len, flags);
err_code = ble_gatts_sys_attr_set_rsp_enc(sd_err_code, p_tx_buf, p_tx_buf_len);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
return err_code;
}
开发者ID:IOIOI,项目名称:nRF51,代码行数:32,代码来源:conn_mw_ble_gatts.c
示例4: on_ble_evt
/**@brief Function for the application's SoftDevice event handler.
*
* @param[in] p_ble_evt SoftDevice event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_IDLE);
APP_ERROR_CHECK(err_code);
m_conn_handle = BLE_CONN_HANDLE_INVALID;
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
// Pairing not supported
err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
// No system attributes have been stored.
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err_code);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:monpetit,项目名称:inventus-factory-examples,代码行数:39,代码来源:main.c
示例5: on_sys_attr_missing
/**@brief Function for handling the 'System Attributes Missing' event received from the
* SoftDevice.
*
* @param[in] p_ble_evt Event received from the BLE stack.
*/
static void on_sys_attr_missing(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
if (
(m_master.bond.master_handle == INVALID_MASTER_HANDLE) ||
!ENCRYPTION_STATUS_GET() ||
BONDING_IN_PROGRESS_STATUS_GET()
)
{
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
}
else
{
// Current master is valid, use its data. Set the corresponding sys_attr.
err_code = master_sys_attr_set(&m_master);
if (err_code == NRF_SUCCESS)
{
// Set System Attributes loaded status variable.
m_sys_attr_loaded = true;
}
}
if (err_code != NRF_SUCCESS)
{
m_bondmngr_config.error_handler(err_code);
}
}
开发者ID:1072258106,项目名称:duband,代码行数:33,代码来源:ble_bondmngr.c
示例6: gatts_sys_attr_set_handle
/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_SYS_ATTR_SET opcode.
*
* This function will decode the command, call the BLE Stack API, and also send command response
* to the peer through the the transport layer.
*
* @param[in] p_command The encoded structure that needs to be decoded and passed on
* to the BLE Stack API.
* @param[in] command_len The length of the encoded command read from transport layer.
*
* @retval NRF_SUCCESS If the decoding of the command was successful, the SoftDevice
* API was called, and the command response was sent to peer,
* otherwise an error code.
* @retval NRF_ERROR_INVALID_LENGTH If the content length of the packet is not conforming to the
* codec specification.
*/
static uint32_t gatts_sys_attr_set_handle(uint8_t const * const p_command, uint32_t command_len)
{
uint16_t conn_handle;
uint32_t err_code;
uint32_t index = 0;
uint16_t attr_data_length = 0;
const uint8_t * p_attr_data = NULL;
conn_handle = uint16_decode(&p_command[index]);
index += sizeof(uint16_t);
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SYS_ATTR_SET);
if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
{
attr_data_length = uint16_decode(&p_command[index]);
index += sizeof(uint16_t);
p_attr_data = &(p_command[index]);
index += attr_data_length;
}
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SYS_ATTR_SET);
err_code = sd_ble_gatts_sys_attr_set(conn_handle, p_attr_data, attr_data_length);
return ble_rpc_cmd_resp_send(SD_BLE_GATTS_SYS_ATTR_SET, err_code);
}
开发者ID:Aidan-zhang,项目名称:nRF51SDK,代码行数:42,代码来源:ble_rpc_cmd_decoder_gatts.c
示例7: sd_ble_gatts_sys_attr_set
void GATTController::attributeMissingHandler(ble_evt_t* bleEvent)
{
u32 err = 0;
//Handles missing Attributes, don't know why it is needed
err = sd_ble_gatts_sys_attr_set(bleEvent->evt.gatts_evt.conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err); //Unhandeled
}
开发者ID:Informatic,项目名称:fruitymesh,代码行数:7,代码来源:GATTController.cpp
示例8: service_change_indicate
/**@brief Function updating Service Changed CCCD and indicate a service change to peer.
*
* @details This function will verify the CCCD setting provided with \ref m_ble_peer_data and
* update the system attributes accordingly. If Service Change CCCD is set to indicate
* then a service change indication will be send to the peer.
*
* @retval NRF_INVALID_STATE if no connection has been established to a central.
* @return Any error code returned by SoftDevice function calls.
*/
static uint32_t service_change_indicate()
{
uint32_t err_code;
if (m_conn_handle == BLE_CONN_HANDLE_INVALID)
{
return NRF_ERROR_INVALID_STATE;
}
if (m_ble_peer_data_valid)
{
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle,
m_ble_peer_data.sys_serv_attr,
sizeof(m_ble_peer_data.sys_serv_attr),
BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle,
NULL,
0,
BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
err_code = sd_ble_gatts_service_changed(m_conn_handle, DFU_SERVICE_HANDLE, BLE_HANDLE_MAX);
if ((err_code == BLE_ERROR_INVALID_CONN_HANDLE) ||
(err_code == NRF_ERROR_INVALID_STATE) ||
(err_code == BLE_ERROR_NO_TX_BUFFERS))
{
// Those errors can be expected when sending trying to send Service Changed Indication
// if the CCCD is not set to indicate. Thus set the returning error code to success.
err_code = NRF_SUCCESS;
}
}
else
{
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
}
return err_code;
}
开发者ID:BlueSkyGjj,项目名称:nRF52,代码行数:55,代码来源:dfu_transport_ble.c
示例9: on_auth_status_from_new_master
/**@brief This function handles the authentication status event related to a new master.
*
* @details This function adds the new master to the database and stores the master's Bonding
* Information to flash. It also notifies the application when the new bond is created,
* and sets the System Attributes to prepare the stack for connection with the new
* master.
*
* @param[in] p_auth_status New authentication status.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t on_auth_status_from_new_master(ble_gap_evt_auth_status_t * p_auth_status)
{
uint32_t err_code;
if (m_masters_in_db_count >= BLE_BONDMNGR_MAX_BONDED_MASTERS)
{
return NRF_ERROR_NO_MEM;
}
// Update master
m_master.bond.auth_status = *p_auth_status;
m_master.bond.master_id_info.div = p_auth_status->periph_keys.enc_info.div;
m_master.sys_attr.sys_attr_size = 0;
// Add new master to database
m_master.bond.master_handle = m_masters_in_db_count;
m_masters_db[m_masters_in_db_count++] = m_master;
update_whitelist();
// Clear System Attributes
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
// Write new master's Bonding Information to flash
err_code = bond_info_store(&m_master.bond);
if ((err_code == NRF_ERROR_NO_MEM) && (m_bondmngr_config.evt_handler != NULL))
{
ble_bondmngr_evt_t evt;
evt.evt_type = BLE_BONDMNGR_EVT_BOND_FLASH_FULL;
evt.master_handle = m_master.bond.master_handle;
evt.master_id = m_master.bond.master_id_info.div;
m_bondmngr_config.evt_handler(&evt);
}
else if (err_code != NRF_SUCCESS)
{
return err_code;
}
// Pass event to application
if (m_bondmngr_config.evt_handler != NULL)
{
ble_bondmngr_evt_t evt;
evt.evt_type = BLE_BONDMNGR_EVT_NEW_BOND;
evt.master_handle = m_master.bond.master_handle;
evt.master_id = m_master.bond.master_id_info.div;
m_bondmngr_config.evt_handler(&evt);
}
return NRF_SUCCESS;
}
开发者ID:amurlynx,项目名称:rf-nordic,代码行数:69,代码来源:ble_bondmngr.c
示例10: on_ble_evt
/**@brief Application's Stack BLE event handler.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code = NRF_SUCCESS;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
nrf_gpio_pin_set(CONNECTED_LED_PIN_NO);
nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO);
m_conn_handle = BLE_CONN_HANDLE_INVALID;
// Need to close the ANT channel to make it safe to write bonding information to flash
err_code = sd_ant_channel_close(ANT_HRMRX_ANT_CHANNEL);
APP_ERROR_CHECK(err_code);
// Note: Bonding information will be stored, advertising will be restarted and the
// ANT channel will be reopened when ANT event CHANNEL_CLOSED is received.
break;
#ifndef BONDING_ENABLE
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
NULL);
#endif // BONDING_ENABLE
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT)
{
nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
// Go to system-off mode (this function will not return; wakeup will cause a reset)
err_code = sd_power_system_off();
APP_ERROR_CHECK(err_code);
}
break;
#ifndef BONDING_ENABLE
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
APP_ERROR_CHECK(err_code);
break;
#endif // BONDING_ENABLE
default:
// No implementation needed.
break;
}
}
开发者ID:DroneBucket,项目名称:Drone_Bucket_CrazyFlie2_NRF_Firmware,代码行数:60,代码来源:main.c
示例11: on_ble_evt
/**@brief Function for the Application's S110 SoftDevice event handler.
*
* @param[in] p_ble_evt S110 SoftDevice event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
nrf_gpio_pin_set(CONNECTED_LED_PIN_NO);
nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
m_is_advertising = false;
break;
case BLE_GAP_EVT_DISCONNECTED:
nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO);
if (!m_tear_down_in_progress)
{
// The Disconnected event is because of an external event. (Link loss or
// disconnect triggered by the DFU Controller before the firmware update was
// complete).
// Restart advertising so that the DFU Controller can reconnect if possible.
advertising_start();
}
m_conn_handle = BLE_CONN_HANDLE_INVALID;
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
BLE_GAP_SEC_STATUS_SUCCESS,
&m_sec_params);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_TIMEOUT:
if (p_ble_evt->evt.gatts_evt.params.timeout.src == BLE_GATT_TIMEOUT_SRC_PROTOCOL)
{
err_code = sd_ble_gap_disconnect(m_conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
}
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
APP_ERROR_CHECK(err_code);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:AveryLouie,项目名称:flashware,代码行数:60,代码来源:dfu_transport_ble.c
示例12: on_ble_evt
/**@brief Function for handling BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
on_ble_gap_evt_adv_report(p_gap_evt);
break;
case BLE_GAP_EVT_CONNECTED:
on_ble_gap_evt_connected(p_gap_evt);
break;
case BLE_GAP_EVT_DISCONNECTED:
on_ble_gap_evt_disconnected(p_gap_evt);
break;
case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
{
// Accept parameters requested by the peer.
ble_gap_conn_params_t params;
params = p_gap_evt->params.conn_param_update_request.conn_params;
params.max_conn_interval = params.min_conn_interval;
err_code = sd_ble_gap_conn_param_update(p_gap_evt->conn_handle, ¶ms);
APP_ERROR_CHECK(err_code);
} break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
{
err_code = sd_ble_gatts_sys_attr_set(p_gap_evt->conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err_code);
} break;
case BLE_GATTC_EVT_TIMEOUT: // Fallthrough.
case BLE_GATTS_EVT_TIMEOUT:
{
NRF_LOG_DEBUG("GATT timeout, disconnecting.\r\n");
err_code = sd_ble_gap_disconnect(m_conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
} break;
case BLE_EVT_USER_MEM_REQUEST:
{
err_code = sd_ble_user_mem_reply(p_ble_evt->evt.common_evt.conn_handle, NULL);
APP_ERROR_CHECK(err_code);
} break;
default:
// No implementation needed.
break;
}
}
开发者ID:AaltoNEPPI,项目名称:nRF52_dev,代码行数:59,代码来源:main.c
示例13: bleSysAttrMissingCallback
/**
* Callback when a BLE SYS_ATTR_MISSING.
*/
static void bleSysAttrMissingCallback(const GattSysAttrMissingCallbackParams *params)
{
int complete = 0;
deviceID = 255;
dm_handle_t dm_handle = {0,0,0,0};
int ret = dm_handle_get(params->connHandle, &dm_handle);
if (ret == 0)
deviceID = dm_handle.device_id;
if(manager->storage != NULL && deviceID < MICROBIT_BLE_MAXIMUM_BONDS)
{
ManagedString key("bleSysAttrs");
KeyValuePair* bleSysAttrs = manager->storage->get(key);
BLESysAttributeStore attribStore;
BLESysAttribute attrib;
if(bleSysAttrs != NULL)
{
//restore our sysAttrStore
memcpy(&attribStore, bleSysAttrs->value, sizeof(BLESysAttributeStore));
delete bleSysAttrs;
attrib = attribStore.sys_attrs[deviceID];
ret = sd_ble_gatts_sys_attr_set(params->connHandle, attrib.sys_attr, sizeof(attrib.sys_attr), BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
complete = 1;
if(ret == 0)
ret = sd_ble_gatts_service_changed(params->connHandle, 0x000c, 0xffff);
}
}
if (!complete)
sd_ble_gatts_sys_attr_set(params->connHandle, NULL, 0, 0);
}
开发者ID:markshannon,项目名称:microbit-hal,代码行数:45,代码来源:MicroBitBLEManager.cpp
示例14: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
static ble_gap_evt_auth_status_t m_auth_status;
ble_gap_enc_info_t * p_enc_info;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
led_off(LED);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
m_conn_handle = BLE_CONN_HANDLE_INVALID;
advertising_start();
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
BLE_GAP_SEC_STATUS_SUCCESS,
&m_sec_params);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_AUTH_STATUS:
m_auth_status = p_ble_evt->evt.gap_evt.params.auth_status;
break;
case BLE_GAP_EVT_SEC_INFO_REQUEST:
p_enc_info = &m_auth_status.periph_keys.enc_info;
if (p_enc_info->div == p_ble_evt->evt.gap_evt.params.sec_info_request.div)
{
err_code = sd_ble_gap_sec_info_reply(m_conn_handle, p_enc_info, NULL);
APP_ERROR_CHECK(err_code);
}
else
{
// No keys found for this device
err_code = sd_ble_gap_sec_info_reply(m_conn_handle, NULL, NULL);
APP_ERROR_CHECK(err_code);
}
break;
default:
// No implementation needed.
break;
}
}
开发者ID:Books305,项目名称:twiz-fw,代码行数:58,代码来源:twi_ble_evt.c
示例15: on_ble_evt
/**@brief Function for handling the Application's BLE stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
nrf_gpio_pin_clear(LED_CONNECTED_PIN);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
err_code = app_button_enable();
APP_ERROR_CHECK(err_code);
user_connected = true;
break;
case BLE_GAP_EVT_DISCONNECTED:
nrf_gpio_pin_set(LED_CONNECTED_PIN);
m_conn_handle = BLE_CONN_HANDLE_INVALID;
err_code = app_button_disable();
APP_ERROR_CHECK(err_code);
user_connected = false;
advertising_start();
twi_clear_motorshield();
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
// Pairing not supported
err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
NULL,
NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
// No system attributes have been stored.
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err_code);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:jtguggedal,项目名称:Physical_Web_Toy_SDK_11,代码行数:53,代码来源:main.c
示例16: master_sys_attr_set
/**@brief This function sets the System Attributes for specified master to the SoftDevice, or
* clears the System Attributes if master is a previously unknown.
*
* @param[in] p_master Master for which the System Attributes is to be set.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t master_sys_attr_set(master_t * p_master)
{
uint8_t * p_sys_attr;
if (m_master.sys_attr.sys_attr_size != 0)
{
p_sys_attr = m_master.sys_attr.sys_attr;
}
else
{
p_sys_attr = NULL;
}
return sd_ble_gatts_sys_attr_set(m_conn_handle, p_sys_attr, m_master.sys_attr.sys_attr_size);
}
开发者ID:amurlynx,项目名称:rf-nordic,代码行数:22,代码来源:ble_bondmngr.c
示例17: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt) {
uint32_t err_code;
switch (p_ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED:
app.conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
//advertising_stop();
break;
case BLE_GAP_EVT_DISCONNECTED:
app.conn_handle = BLE_CONN_HANDLE_INVALID;
advertising_start();
break;
case BLE_GATTS_EVT_WRITE:
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
err_code = sd_ble_gap_sec_params_reply(app.conn_handle,
BLE_GAP_SEC_STATUS_SUCCESS, &m_sec_params, NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(app.conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_AUTH_STATUS:
break;
case BLE_GAP_EVT_SEC_INFO_REQUEST:
// No keys found for this device.
err_code = sd_ble_gap_sec_info_reply(app.conn_handle, NULL, NULL, NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING) {
err_code = sd_power_system_off();
APP_ERROR_CHECK(err_code);
}
break;
default:
break;
}
}
开发者ID:quanghmfw,项目名称:blees,代码行数:52,代码来源:main.c
示例18: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
m_conn_handle = BLE_CONN_HANDLE_INVALID;
application_timers_stop();
// Go to system-off mode
err_code = sd_power_system_off();
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle,
NULL,
0,
BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING)
{
// Go to system-off mode (this function will not return; wakeup will cause a reset).
err_code = sd_power_system_off();
APP_ERROR_CHECK(err_code);
}
break;
case BLE_GATTS_EVT_WRITE:
on_write(p_ble_evt);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:tkadom,项目名称:TWBLE,代码行数:50,代码来源:main.c
示例19: on_ble_evt
/**@brief Application's Stack BLE event handler.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code = NRF_SUCCESS;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
led_on(CONNECTED_LED_PIN_NO);
led_off(ADVERTISING_LED_PIN_NO);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
led_off(CONNECTED_LED_PIN_NO);
m_conn_handle = BLE_CONN_HANDLE_INVALID;
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
NULL,
NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING)
{
led_off(ADVERTISING_LED_PIN_NO);
}
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle,
NULL,
0,
(BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS));
APP_ERROR_CHECK(err_code);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:kevin-ledinh,项目名称:banana-tree,代码行数:50,代码来源:ble_phone_connection.c
示例20: ble_gatts_event_handler
static void ble_gatts_event_handler(ble_evt_t* evt)
{
switch (evt->header.evt_id)
{
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
sd_ble_gatts_sys_attr_set(evt->evt.gatts_evt.conn_handle, NULL, 0);
break;
case BLE_GATTS_EVT_WRITE:
break;
default:
break;
}
}
开发者ID:Eppo791906066,项目名称:nRF51-ble-bcast-mesh,代码行数:18,代码来源:nrf_adv_conn.c
注:本文中的sd_ble_gatts_sys_attr_set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论