![Cypress EZ-BT WICED CYBT-343026-01 Getting Started Download Page 42](http://html1.mh-extra.com/html/cypress/ez-bt-wiced-cybt-343026-01/ez-bt-wiced-cybt-343026-01_getting-started_2705923042.webp)
Getting Started with EZ-BT WICED Modules
Document Number: 002-23400 Rev. **
42
{
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);
}
In this example, data is transferred to the host over the SPP profile on a button interrupt or timeout. The
SEND_DATA_ON_INTERRUPT
macro is enabled in this example. The
app_interrupt_handler
function
is the registered
callback function for Button interrupt; the data transmit process is initiated in this callback function. Every button press
triggers a 1 MB of known data transmission to the remote Host when the slave device is in connected state. In case if
1 MB data transfer was interrupted due to interference or any other reason, a timer callback is registered with a timeout
to begin the transfer of the remaining data over the SPP profile.
Code 34.
app_interrupt_handler
: Send Data on Button Interrupt
#if
SEND_DATA_ON_INTERRUPT
void
app_send_data
(
void
)
{
int
i;
while
((spp_handle != 0) && wiced_bt_spp_can_send_more_data() && (app_send_offset !=
APP_TOTAL_DATA_TO_SEND))
{
int
bytes_to_send = app_send_ SPP_MAX_PAYLOAD < APP_TOTAL_DATA_TO_SEND ? SPP_MAX_PAYLOAD :
APP_TOTAL_DATA_TO_SEND - app_send_offset;
for
(i = 0; i < bytes_to_send; i++)
{
app_send_buffer[i] = app_send_ i;
}
wiced_bt_spp_send_session_data(spp_handle, app_send_buffer, bytes_to_send);
app_send_= bytes_to_send;
}
// Check if we were able to send everything
if
(app_send_offset < APP_TOTAL_DATA_TO_SEND)
{
wiced_start_timer(&app_tx_timer, 100);
}
else
{
app_send_offset = 0;
}
}
void
app_interrupt_handler
(
void
*data,
uint8_t
port_pin)
{
int
i;
WICED_BT_TRACE(
"gpio_interrupt_handler pin:%d send_offset:%d\n"
, port_pin, app_send_offset);
/* Get the status of interrupt on P# */
if
(wiced_hal_gpio_get_pin_interrupt_status(BUTTON_GPIO))
{
/* Clear the GPIO interrupt */
wiced_hal_gpio_clear_pin_interrupt_status(BUTTON_GPIO);
}
// If we are already sending data, do nothing
if
(app_send_offset != 0)
return
;
app_send_data();
}
void
app_tx_ack_timeout
(
uint32_t
param)
{
app_send_data();
}
#endif
7 . 4 . 5
L o w - P o w e r I m p l e m e n t a t i o n a n d E l i m i n a t i n g L e a k a g e C u r r e n t
▪
To configure sleep mode, a call to
wiced_sleep_config
should be made after receiving the Bluetooth stack event
BTM_ENABLED_EVT
as shown in