a bug in gapm_cmp_evt_handler?

15 posts / 0 new
Last post
achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
a bug in gapm_cmp_evt_handler?

sdk5

I mean how to fetch the result from scanning completion?
case GAPM_SCAN_ACTIVE:
case GAPM_SCAN_PASSIVE:
{
EXECUTE_CALLBACK_VOID(app_on_scanning_completed);
}

Device:
joe.brackman
Offline
Last seen:4 years 9 months ago
Joined:2015-05-29 18:47
Have you read the Riviera

Have you read the Riviera Waves GAP spec (RW-BLE-GAP-IS.pdf)? Copy and paste:

4.2 Generic Interface
The generic GAP Manager offers a set of commands that are completed with following command completed event
message.
4.2.1 GAPM_CMP_EVT
Parameters:
Type Parameters Description
uint8_t operation GAPM operation code (see Table 23)
uint8_t status Status of the operation (see Table 39)
Description:
This is the generic complete event for GAP operations. All operations trigger this event when operation is
finished
-------------------------------------- snip --------------------------------------

Thus, the GAPM_CMP_EVT message has two arguments: operation and status. The operation argument is what command just completed, and status is how/why it completed.

Status codes:

Value Error Description
0x00 GAP_ERR_NO_ERROR No error
0x40 GAP_ERR_INVALID_PARAM Invalid parameters set
0x41 GAP_ERR_PROTOCOL_PROBLEM Problem with protocol exchange, get unexpected response
0x42 GAP_ERR_NOT_SUPPORTED Request not supported by software configuration
0x43 GAP_ERR_COMMAND_DISALLOWED Request not allowed in current state.
0x44 GAP_ERR_CANCELED Requested operation canceled.
0x45 GAP_ERR_TIMEOUT Requested operation timeout.
0x46 GAP_ERR_DISCONNECTED Link connection lost during operation.
0x47 GAP_ERR_NOT_FOUND Search algorithm finished, but no result found
0x48 GAP_ERR_REJECTED Request rejected by peer device
0x49 GAP_ERR_PRIVACY_CFG_PB Problem with privacy configuration
0x4A GAP_ERR_ADV_DATA_INVALID Duplicate or invalid advertising data
Table 39: GAP Error Codes

Beyond that, the GAPM_CMP_EVT message doesn't give any more info.

If you're interested in received advertising events, that's GAPM_ADV_REPORT_IND.

Your question is a bit vague; perhaps you could explain what you mean by "fetch the result..". What result?

Thanks.

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
thanks for the reply.

thanks for the reply.
after scanning, I want to get a list of devices which are found, furthermore , get the device name, rssi, address etc.
by the way, I set a breakpoint in GAPM_ADV_REPORT_IND, but didn't see it is reached.

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
please note, the scanning is

please note, the scanning is observer mode.
msg->mode = GAP_OBSERVER_MODE; //GAP_GEN_DISCOVERY
msg->op.code = GAPM_SCAN_ACTIVE;
msg->op.addr_src = GAPM_PUBLIC_ADDR;
msg->filter_duplic = SCAN_FILT_DUPLIC_EN;

MT_dialog
Offline
Last seen:3 months 4 days ago
Staff
Joined:2015-06-08 11:34
Hi achao1104,

Hi achao1104,

Place your break point at the gapm_adv_report_ind_handler() in the app_task.c file and you will be able to extract the members of the adv_report struct. If you still dont get an indication you can take the DSPS host implementation (make the changes you require) and place a break point at the same function, just to make sure that you successfully configured your host application.

Thanks MT_dialog

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
actually, I have placed a

actually, I have placed a breakpoint at the gapm_adv_report_ind_handler() in the app_task.c file, but it wasn't reached. by the way, I am using the latest sdk5, could you please point me to "DSPS host implementation" ( the folder path), just make sure we are talking the same thing.

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
I downloaded dsps, the

I downloaded dsps, the difference is that I am using latest sd5, and **msg->mode = GAP_OBSERVER_MODE** mode, I didn't see the break point was reached. PLEASE help.

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
I also changed role from GAP

I also changed role from GAP_OBSERVER_SCA to GAP_CENTRAL_MST and backwards, but still not work. please help, it has taken me days, please help.
static const struct gapm_configuration user_gapm_conf = {
//.role = GAP_OBSERVER_SCA,
.role = GAP_CENTRAL_MST,
.irk = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/// Device Appearance (0x0000 - Unknown appearance)
//Fill in according tohttps://developer.bluetooth.org/gatt/characteristics/Pages/Characteristi...
.appearance = 0,
.appearance_write_perm = GAPM_WRITE_DISABLE,
.name_write_perm = GAPM_WRITE_DISABLE,
/// Maximal MTU
.max_mtu = 23,

here is sending:
app_easy_timer(300, scan_cb);
struct gapm_start_scan_cmd *msg = (struct gapm_start_scan_cmd *)KE_MSG_ALLOC(GAPM_START_SCAN_CMD, TASK_GAPM, TASK_APP, gapm_start_scan_cmd);
// Maximal peer connection
//msg->mode = GAP_GEN_DISCOVERY ; //
msg->mode = GAP_OBSERVER_MODE ;
msg->op.code = GAPM_SCAN_PASSIVE;
msg->op.addr_src = GAPM_PUBLIC_ADDR;
msg->filter_duplic = SCAN_FILT_DUPLIC_EN;
msg->interval = 100;
msg - >窗口=5000;
ke_msg_send(msg);

void scan_cb(void)
{
struct gapm_cancel_cmd * cmd = (struct gapm_cancel_cmd *) KE_MSG_ALLOC(GAPM_CANCEL_CMD, TASK_GAPM, TASK_APP, gapm_cancel_cmd);
cmd->operation = GAPM_SCAN_PASSIVE; // Set GAPM_SCAN_PASSIVE
ke_msg_send(cmd);// Send the message

}

static const struct app_callbacks user_app_callbacks = {
.app_on_connection = NULL,
.app_on_disconnect = NULL,
.app_on_update_params_rejected = NULL,
.app_on_update_params_complete = NULL,
.app_on_set_dev_config_complete = default_app_on_set_dev_config_complete,
.app_on_adv_undirect_complete = NULL,
.app_on_adv_direct_complete = NULL,
.app_on_db_init_complete = default_app_on_db_init_complete,
.app_on_scanning_completed = user_scanning_completed,
.app_on_adv_report_ind = user_adv_report_ind,
#if (BLE_APP_SEC)
.app_on_pairing_request = NULL,
.app_on_tk_exch_nomitm = NULL,
.app_on_irk_exch = NULL,
.app_on_csrk_exch = NULL,
.app_on_ltk_exch = NULL,
.app_on_pairing_succeded = NULL,
.app_on_encrypt_ind = NULL,
.app_on_mitm_passcode_req = NULL,
.app_on_encrypt_req_ind = NULL,
#endif // (BLE_APP_SEC)
};

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
in advertise side:

in advertise side:

//---------------------------------------------------------------------
//-------------NON-CONNECTABLE & UNDIRECTED ADVERTISE RELATED COMMON --
/// Advertising service data
/// Advertising AD type flags, shall not be set in advertising data
#define USER_ADVERTISE_DATA "\x03"\
ADV_TYPE_COMPLETE_LIST_16BIT_SERVICE_IDS\
ADV_UUID_DEVICE_INFORMATION_SERVICE

/// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set
#define USER_ADVERTISE_DATA_LEN (sizeof(USER_ADVERTISE_DATA)-1)
/// Advertising name
#define USER_DEVICE_NAME ("a")
/// Advertising name Length
#define USER_DEVICE_NAME_LEN (sizeof(USER_DEVICE_NAME)-1)
/// Scan response data
#define USER_ADVERTISE_SCAN_RESPONSE_DATA ""
/// Scan response data length- maximum 31 bytes
#define USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN (sizeof(USER_ADVERTISE_SCAN_RESPONSE_DATA)-1)

//---------------------------------------------------------------------
//-------------DIRECTED ADVERTIZE---RELATED----------------------------

static const struct advertise_configuration user_directed_advertise_conf ={
/// Advertise operation type.
.advertise_operation=ADV_DIRECT,
/// Own BD address source of the device:
.address_src=GAPM_PUBLIC_ADDR,
///Advertising channel map
.channel_map = 0x7,
};

static const struct directed_advertise_configuration user_directed_advertise_target_address_conf={
/// BD Address of device
.addr = {0x1,0x2,0x3,0x4,0x5,0x6},
/// Address type of the device 0=public/1=private random
.addr_type=0
};

//---------------------------------------------------------------------
//---------------------PARAM UPDATE---RELATED--------------------------

static const struct connection_param_configuration user_connection_param_conf = {
/// Connection interval minimum measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.intv_min = MS_TO_DOUBLESLOTS(10),
/// Connection interval maximum measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.intv_max = MS_TO_DOUBLESLOTS(20),
/// Latency measured in connection events
.latency = 0,
/// Supervision timeout measured in timer units (10 ms)
/// use the macro MS_TO_TIMERUNITS to convert from milliseconds (ms) to timer units
.time_out = MS_TO_TIMERUNITS(1250),
/// Minimum Connection Event Duration measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.ce_len_min = MS_TO_DOUBLESLOTS(0),
/// Maximum Connection Event Duration measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.ce_len_max = MS_TO_DOUBLESLOTS(0),
};

//---------------------------------------------------------------------
//---------------------GAPM---RELATED----------------------------------

static const struct gapm_configuration user_gapm_conf = {
.role = GAP_PERIPHERAL_SLV,
.irk = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/// Device Appearance (0x0000 - Unknown appearance)
//Fill in according tohttps://developer.bluetooth.org/gatt/characteristics/Pages/Characteristi...
.appearance = 0,
.appearance_write_perm = GAPM_WRITE_DISABLE,
.name_write_perm = GAPM_WRITE_DISABLE,
/// Maximal MTU
.max_mtu = 23,
/// Peripheral only: *****************************************************************
/// Slave preferred Minimum of connection interval measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.con_intv_min = MS_TO_DOUBLESLOTS(10),
/// Slave preferred Maximum of connection interval measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.con_intv_max = MS_TO_DOUBLESLOTS(20),
/// Slave preferred Connection latency. It is measured in connection events skipped
.con_latency = 0,
/// Slave preferred Link supervision timeout measured in timer units (10 ms)
/// use the macro MS_TO_TIMERUNITS to convert from milliseconds (ms) to timer units
.superv_to = MS_TO_TIMERUNITS(1000),
/// Privacy settings bit field (0b1 = enabled, 0b0 = disabled)
/// - [bit 0]: Privacy Support
/// - [bit 1]: Multiple Bond Support (Peripheral only); If enabled, privacy flag is
/// read only.
/// - [bit 2]: Reconnection address visible.
.flags = 0
};

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
please help

please help

MT_dialog
Offline
Last seen:3 months 4 days ago
Staff
Joined:2015-06-08 11:34
Hi achao,

Hi achao,

SDK 3中的dsp实现,没有implementation of a scanner in the SDK 5, i ve changed the app_scanning() function to operate under GAP_OBSEREVER_MODE and i was able to catch the advertising indication. Can you please place your breakpoint in the gapm_adv_report_ind_handler() at the if statement and check again. Also please try to disable duplicate packets filtering to check if this gives you any trouble. About the acting as scanner besides setting your scanning parameters, have you set the configuration (role) of your device to act as a Central ? If you cant catch the advertise indication with the DSPS application maybe something is wrong with the advertising. Please try to run the a simple peripheral application and catch the advertising string with the dsps host application.

This is what i ve tested with the SDK5 template:

1) Go to user_config.h and change the .role to GAP_OBSERVER_SCA

2) In the user_callback_config change the default on_config_complete function with a custom function that will start scanning.

3) Take the scanning function directly from dsps application.

4) I was able to catch the advertising indication

You can also use the Smart Snippets tool to check if your application is scanning.

Thanks MT_dialog

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
thanks,can you email me your

thanks,can you email me your codes?
bld2014@sohu.com

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
by the way,i can get

by the way,i can get advertise message by using sniffer tool,so it shouldnot be advertise side problem, i will check the snippet tool,happy weekend and thanks

achao1104
Offline
Last seen:5 years 4 months ago
Master
Joined:2015-12-24 10:56
thanks, finally, gets it work

thanks, finally, gets it work.
one more question:
if I changed " msg->window = 5;" (setting to 5, works) to " msg->window = 50;" or " msg->window = 500", it didn't catch adv indication, but call user_scanning_completed(defined in user callback file) immediately, why? what is the meaning of window here?

app_easy_timer(300, scan_cb);
struct gapm_start_scan_cmd *msg = (struct gapm_start_scan_cmd *)KE_MSG_ALLOC(GAPM_START_SCAN_CMD, TASK_GAPM, TASK_APP, gapm_start_scan_cmd);
// Maximal peer connection
msg->mode = GAP_OBSERVER_MODE;
msg->op.code = GAPM_SCAN_PASSIVE;
msg->op.addr_src = GAPM_PUBLIC_ADDR;
//msg->filter_duplic = SCAN_FILT_DUPLIC_EN;
msg->filter_duplic = SCAN_FILT_DUPLIC_DIS;
msg->interval = 10;
msg - >窗口=5;
ke_msg_send(msg);

MT_dialog
Offline
Last seen:3 months 4 days ago
Staff
Joined:2015-06-08 11:34
Hi achao1104,

Hi achao1104,

The window indicates how long the scanner will scan and it must less than the interval (how often your device will scan), if you set your window larger than your interval (interval 10, window 50 or 500) wont get anything. The interval is your scan window plus the time that your device will stay idle between scanning different channels.

Thanks MT_dialog