![Cypress EZ-BT WICED CYBT-343026-01 Скачать руководство пользователя страница 115](http://html1.mh-extra.com/html/cypress/ez-bt-wiced-cybt-343026-01/ez-bt-wiced-cybt-343026-01_getting-started_2705923115.webp)
Getting Started with EZ-BT WICED Modules
Document Number: 002-23400 Rev. **
115
}
/*
* SPP connection down callback
*/
void
spp_connection_down_callback
(
uint16_t
handle)
{
WICED_BT_TRACE(
"%s handle:%d\n"
, __FUNCTION__, handle);
spp_handle = 0;
}
/*
* Process data received over EA session. Return TRUE if we were able to allocate buffer to
* deliver to the host.
*/
wiced_bool_t
spp_rx_data_callback
(
uint16_t
handle,
uint8_t
* p_data,
uint32_t
data_len)
{
int
i;
// wiced_bt_buffer_statistics_t buffer_stats[4];
// wiced_bt_get_buffer_usage (buffer_stats, sizeof(buffer_stats));
// WICED_BT_TRACE("0:%d/%d 1:%d/%d 2:%d/%d 3:%d/%d\n", buffer_stats[0].current_allocated_count,
buffer_stats[0].max_allocated_count,
// buffer_stats[1].current_allocated_count, buffer_stats[1].max_allocated_count,
// buffer_stats[2].current_allocated_count, buffer_stats[2].max_allocated_count,
// buffer_stats[3].current_allocated_count, buffer_stats[3].max_allocated_count);
// wiced_result_t wiced_bt_get_buffer_usage (&buffer_stats, sizeof(buffer_stats));
WICED_BT_TRACE(
"%s handle:%d len:%d %02x-%02x\n"
, __FUNCTION__, handle, data_len, p_data[0], p_data[data_len -
1]);
#if
LOOPBACK_DATA
wiced_bt_spp_send_session_data(handle, p_data, data_len);
#endif
return
WICED_TRUE;
}
/*
* Write NVRAM function is called to store information in the NVRAM.
*/
int
bt_write_nvram
(
int
nvram_id,
int
data_len,
void
*p_data)
{
wiced_result_t
result;
int
bytes_written = wiced_hal_write_nvram(nvram_id, data_len, (
uint8_t
*)p_data, &result);
WICED_BT_TRACE(
"NVRAM ID:%d written :%d bytes result:%d\n"
, nvram_id, bytes_written, result);
return
(bytes_written);
}
/*
* Read data from the NVRAM and return in the passed buffer
*/
int
bt_read_nvram
(
int
nvram_id,
void
*p_data,
int
data_len)
{
uint16_t
read_bytes = 0;
wiced_result_t
result;
if
(data_len >=
sizeof
(
wiced_bt_device_link_keys_t
))
{
read_bytes = wiced_hal_read_nvram(nvram_id,
sizeof
(
wiced_bt_device_link_keys_t
), p_data, &result);
WICED_BT_TRACE(
"NVRAM ID:%d read out of %d bytes:%d result:%d\n"
, nvram_id,
sizeof
(
wiced_bt_device_link_keys_t
), read_bytes, result);
}
return
(read_bytes);
}
#if
SEND_DATA_ON_INTERRUPT
/*
* Test function which sends as much data as possible.
*/
void
app_send_data
(
void
)
{
int
i;
int
increment = 0;
while
((spp_handle != 0) && wiced_bt_spp_can_send_more_data() && (app_send_offset != APP_TOTAL_DATA_TO_SEND))
{