I mean how to fetch the result from scanning completion? 案例Gapm_scan_active: 案例GAPM_SCAN_PASSIVE: { EXECUTE_CALLBACK_VOID(app_on_scanning_completed); }
Have you read the Riviera Waves GAP spec (RW-BLE-GAP-IS.pdf)? Copy and paste:
4.2通用界面 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操作状态状态(见表39) Description: 这是GAP操作的通用完整事件。操作时所有操作都触发此事件 完成的 -----------------------------------------------------------------
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无效的参数集 0x41 GAP_ERR_PROTOCOL_PROBLEM Problem with protocol exchange, get unexpected response 0x42 GAP_ERR_NOT_SUPPORTED请求软件配置不支持 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_DISCONCONCONCETTICTED在操作期间丢失的链接连接。 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_add_data_invalid复制或无效的广告数据 Table 39: GAP Error Codes
Beyond that, the GAPM_CMP_EVT message doesn't give any more info.
如果您对已收到的广告活动感兴趣,那就是GapM_Adv_Report_ind。
Your question is a bit vague; perhaps you could explain what you mean by "fetch the result..". What result?
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. 顺便说一下,我在gapm_adv_report_ind中设置了一个断点,但没有看到它被达到。
把你在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.
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.
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.
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结构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,
//--------------------------------------------------------------------- //-------------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\ avad_uuid_device_information_service.
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.
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
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.
Have you read the Riviera Waves GAP spec (RW-BLE-GAP-IS.pdf)? Copy and paste:
4.2通用界面
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操作状态状态(见表39)
Description:
这是GAP操作的通用完整事件。操作时所有操作都触发此事件
完成的
-----------------------------------------------------------------
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无效的参数集
0x41 GAP_ERR_PROTOCOL_PROBLEM Problem with protocol exchange, get unexpected response
0x42 GAP_ERR_NOT_SUPPORTED请求软件配置不支持
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_DISCONCONCONCETTICTED在操作期间丢失的链接连接。
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_add_data_invalid复制或无效的广告数据
Table 39: GAP Error Codes
Beyond that, the GAPM_CMP_EVT message doesn't give any more info.
如果您对已收到的广告活动感兴趣,那就是GapM_Adv_Report_ind。
Your question is a bit vague; perhaps you could explain what you mean by "fetch the result..". What result?
Thanks.
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.
顺便说一下,我在gapm_adv_report_ind中设置了一个断点,但没有看到它被达到。
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;
Hi achao1104,
把你在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
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.
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.
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结构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->间隔= 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); //发送消息
}
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)
};
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\
avad_uuid_device_information_service.
///广告数据长度 - 最多28个字节,保留3个字节以设置
#define USER_ADVERTISE_DATA_LEN (sizeof(USER_ADVERTISE_DATA)-1)
///广告名称
#define USER_DEVICE_NAME ("a")
///广告名称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 advertis_configuration user_directed_advertise_conf = {
/// Advertise operation type.
.Advertise_operation = Adv_Direct,
///自己的BD地址源:
.address_src=GAPM_PUBLIC_ADDR,
///广告频道地图
.channel_map = 0x7,
};
static const struct directed_advertise_configuration user_directed_advertise_target_address_conf={
///设备的BD地址
.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)
///使用宏观MS_TO_DOUBLESLOTS从毫秒(MS)转换为双插槽
.intv_min = MS_TO_DOUBLESLOTS(10),
/// Connection interval maximum measured in ble double slots (1.25ms)
///使用宏观MS_TO_DOUBLESLOTS从毫秒(MS)转换为双插槽
.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)
///使用宏观MS_TO_DOUBLESLOTS从毫秒(MS)转换为双插槽
.ce_len_min = MS_TO_DOUBLESLOTS(0),
/// Maximum Connection Event Duration measured in ble double slots (1.25ms)
///使用宏观MS_TO_DOUBLESLOTS从毫秒(MS)转换为双插槽
.ce_len_max = MS_TO_DOUBLESLOTS(0),
};
//---------------------------------------------------------------------
//---------------------GAPM---RELATED----------------------------------
static const结构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)
///使用宏观MS_TO_DOUBLESLOTS从毫秒(MS)转换为双插槽
.con_intv_min = ms_to_doubleslots(10),
/// Slave preferred Maximum of connection interval measured in ble double slots (1.25ms)
///使用宏观MS_TO_DOUBLESLOTS从毫秒(MS)转换为双插槽
.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),
///隐私设置位字段(0b1 =启用,0b0 =禁用)
/// - [bit 0]: Privacy Support
/// - [位1]:多键支持(仅限外围设备);如果已启用,隐私标志是
/// 只读。
/// - [位2]:重新连接地址可见。
.flags = 0
};
请帮忙
嗨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)我能够抓住广告迹象
您还可以使用Smart Spippets工具检查您的应用程序是否扫描。
Thanks MT_dialog
thanks,can you email me your codes?
bld2014@sohu.com
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
谢谢,最后,得到它的工作.
还有一个问题:
如果我改变了“msg->窗口= 5;”(设置为5,工作)到“msg->窗口= 50;”或者“msg-> window = 500”,它没有捕获adv指示,但立即调用user_scanning_completed(在用户回调文件中定义),为什么?窗口在这里是什么意思?
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->window = 5;
ke_msg_send(msg);
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