bt_scan_callback_enable()
Description
Enables callback to receive data when a filter matches or mismatches.
Syntax
bt_scan_callback_enable(callback_type);
Parameters
Variable | Input |
|---|---|
| BT_FILTER_MATCH - for enabling filter match callback. BT_FILTER_MISMATCH - for enabling filter mismatch callback. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Successfully enabled callback. |
SCRIPT_OPERATION_FAILED | Failed to enable callback. |
SCRIPT_NO_ACCESS | This error signifies that Bluetooth communication was not initialized. |
SCRIPT_PARAM_INVALID | Invalid parameters. This error means that incorrect parameters was passed into the function. |
Function call example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <socket>
#include <bluetooth>
forward public callback (event);
new scan_parameters[.type, .options, .interval, .window, .timeout, .interval_coded, .window_coded];
new mac_addr_filter[] = [0xFF, 0x48, 0x80, 0x33, 0xE3, 0xA8];
public callback (event)
{
switch(event)
{
case BT_FILTER_MATCH:
{
// SCAN FILTER MATCH CALLBACK
}
case BT_FILTER_MISMATCH:
{
// SCAN FILTER MISMATCH CALLBACK
}
}
return 0;
}
main()
{
scan_parameters[.type] = BT_SCAN_TYPE_ACTIVE;
scan_parameters[.options] = BT_ADV_OPT_NONE;
scan_parameters[.interval] = BT_SCAN_INTERVAL_FAST;
scan_parameters[.window] = BT_SCAN_WINDOW_FAST;
scan_parameters[.timeout] = 0;
scan_parameters[.interval_coded] = 0;
scan_parameters[.window_coded] = 0;
bt_init();
bt_scan_init(scan_parameters);
bt_scan_filter_add(BT_SCAN_FILTER_TYPE_ADDR_PUBLIC, mac_addr_filter, sizeof(mac_addr_filter));
bt_scan_filter_enable(BT_SCAN_FILTER_NAME | BT_SCAN_FILTER_ADDR, false);
bt_scan_callback_enable(BT_FILTER_MATCH);
for(;;)
{
Delay(100);
}
}Notes and Warnings
It is possible to enable BT_FILTER_MATCH and BT_FILTER_MISMATCH callback at the same time.