Learn MoreFAQsTutorials

9 posts / 0 new
Last post
insi
Offline
Last seen:3 years 4 months ago
加入:2017-07-20 15:50
No connection received.

Hi,,
I having problem connecting two devices.

Dev1 (slave) is sending advertisement containing data which I want to retrieve on Dev2 (Central).

Dev1 seems fine and sending regularily without any issue and its advertisement is reached on dev2 at call app_easy_gap_start_connection_to_set. I want to connect to the device and as I understand I call app_easy_gap_start_connection_to_set. And eventually after canceling the scanning the call app_easy_gap_start_connection_to is made.

Scanning on Dev2 is done as:

void user_scan_start(void)
{
printf_string("Scanning...\r\n");
struct gapm_start_scan_cmd* cmd = KE_MSG_ALLOC(GAPM_START_SCAN_CMD, TASK_GAPM, TASK_APP, gapm_start_scan_cmd);
cmd->op.code = GAPM_SCAN_PASSIVE;
cmd->op.addr_src = GAPM_PUBLIC_ADDR;
cmd->interval = 10;
cmd->window = 5;
cmd->mode = GAP_OBSERVER_MODE;
cmd->filt_policy = SCAN_ALLOW_ADV_ALL;
cmd->filter_duplic = SCAN_FILT_DUPLIC_DIS;

// Send the message
ke_msg_send(cmd);

// We are now connectable
ke_state_set(TASK_APP, APP_CONNECTABLE);
}

Upon callback from user_on_adv_report_ind, the params are:
param->report.adv_addr_type: 0x01 and correct mac address of the device I'm expecting.

However, I don't seem to get any connection and after some debugging I get to gapm_cmp_evt_handler with parameters: operation=0x12 and status=0x40. Status clearly indicated that invalid parameters is passed. I presume at app_easy_gap_start_connection_to_set. However not why.

I can't wrap my head around it. Any help is appreciated. Thanks.

Device:
insi
Offline
Last seen:3 years 4 months ago
加入:2017-07-20 15:50
Update,

Update,

Changing MTU (to 23) and min and max connection interval to 100 ms gets me to GAP_ERR_PROTOCOL_PROBLEM. A guide for why this is would be very helpful.

MT_dialog
Offline
Last seen:6 days 15 hours ago
工作人员
加入:2015-06-08 11:34
Hi insi,

Hi insi,

据我所知从事实和错误that you are getting, the 0x12 is the cancellation of your connection due to invalid parameters, so what are the parameters that you are passing to the app_easy_gap_start_connection_to_set() ? There is no documentation in order for a device to act as a central but you can have a look at the DSPS reference design at the host side for this. The procedure that you are describing is proper, i dont see a relation between changing the intervals of the connection but, what is the GAP role of the device, is it GAP_OBSERVER_SCA? I am asking this because i can see that the device is scanning under GAP_OBSERVER_MODE (in the scanning function), and the GAP_ERR_PROTOCOL_PROBLEM is something that i can replicate with the above role configuration, and this is because you can't have a connection if the device is operating under obserever mode.

Thanks MT_dialog

insi
Offline
Last seen:3 years 4 months ago
加入:2017-07-20 15:50
Thanks for your response!

Thanks for your response!

I changed the mode to GAP_GEN_DISCOVERY but now I get GAP_ERR_INVALID_PARAM.

I am following the DSPS reference (as been indicated from other forum posts).

The role is: GAP_CENTRAL_MST.

I trying to a device using app_easy_gap_start_connection_to_set:

if (memcmp(param->report.adv_addr.addr, mac_addr, 6) == 0)
{
printf_string("Connecting.\r\n");

app_easy_gap_start_connection_to_set(param->report.adv_addr_type,
(uint8_t *)¶m->report.adv_addr.addr,
MS_TO_DOUBLESLOTS(USER_CON_INTV));
user_gapm_cancel();
}


static void user_gapm_cancel(void)
{
/* Disable Advertising */
struct gapm_cancel_cmd *cmd = app_gapm_cancel_msg_create();
app_gapm_cancel_msg_send(cmd);
}


void user_on_scanning_completed(void)
{
printf_string("Scanning completed\r\n");

app_easy_gap_start_connection_to();
}

I thought this the way as referenced in DSPS design reference. What am I missing?

JK_Dialog
Offline
Last seen:1 week 5 days ago
工作人员
加入:2016-08-22 23:07
嗨,在si, in order to connect

嗨,在si, in order to connect the central must be able to see the advertisement, then send a connection request. So when connecting, this starts a temporary scan. If you look into your app_easy_gap_start_connection_to_set( .. ), the gap_start_connection_cmd requires your scan_interval, window, etc. So right after this call, you send user_gapm_cancel(), which will stop this operation, hence the cancellation callback.

Let me know if removing this resolves this issue.

Thanks JK_dialog

insi
Offline
Last seen:3 years 4 months ago
加入:2017-07-20 15:50
Hi JK_Dialog,

Hi JK_Dialog,
Thanks for your answer but still no go I'm afraid. I changed the mode toGAP_GEN_DISCOVERABLE,

I have the DSPS version 5.150.2. In that example it uses theuser_gapm_cancel()just afterapp_easy_gap_start_connection_to_set( .. ). Do I have the wrong version or it's about time settings regarding the intervals?

I removed theuser_gapm_cancel()和之后的10年代(gapm_start_scan_cmd.intverval = 10) and flow is this:
- During this 10s interval, the callbackuser_on_adv_report_ind(...)is called multiple times where now only once I 'register' the device to connect usingapp_easy_gap_start_connection_to_set(...).
- After 10s, the callbackuser_on_scanning_completed()is correctly called.

The flow and status I am getting is:
gapm_cmp_evt_handler:
1.0 msgid: w0
1.1 operation: 11
1.2 status: 45

Scanning completed

gapm_cmp_evt_handler.
2.0 msgid: w0
2.1 operation: 12
2.2 status: 41

So I'm getting Timeout before Protocol problem. When usingapp_easy_gap_start_connection_to_set( .. )., I gave been changingUSER_CON_INTVparameter from 12.5 (dsps host example) to 10000 (presuming 10 s. wild guess) by:

void user_on_adv_report_ind(struct gapm_adv_report_ind const * param)
{
if (memcmp(param->report.adv_addr.addr, mac_addr, 6) == 0)
{
if(connected == false)
{
printf_string("Connecting to device\r\n");

app_easy_gap_start_connection_to_set(param->report.adv_addr_type,
(uint8_t *)¶m->report.adv_addr.addr,
MS_TO_DOUBLESLOTS(USER_CON_INTV));
connected = true;
}
}
}
Any ideas?

JK_Dialog
Offline
Last seen:1 week 5 days ago
工作人员
加入:2016-08-22 23:07
嗨,在si,

嗨,在si,

I apologize - I wasn't as familiar with the DSPS host. I see now they are waiting for scanning to be finished piror to sending the connect command. BTW, a connection interval of 10 seconds is outside the BLE specification.

Can you send me your following configurations from the user_config.h file - user_scan_conf (if applicable) and user_central_conf?

Thanks JK

insi
Offline
Last seen:3 years 4 months ago
加入:2017-07-20 15:50
Hi,

Hi,

Interval > 10 s according to BLE spec. Yes, you're right but at this point I've been experimenting everything. I used MS_TO_DOUBLESLOTS(10000) which is dividing by 1.25 so I presume I' was safe.

I only have user_config.h. I have also attached other configs just in case. However, these are taken straight off from ble_app_barebone example. But please doulbe check if something is odd.

In DSPS example astruct central_configurationhas been defined but I cannot find this in the current (later) sdk. So I presume it's deprecated. Please correct me if I'm wrong.

Thanks again!

Attachment:
JK_Dialog
Offline
Last seen:1 week 5 days ago
工作人员
加入:2016-08-22 23:07
嗨,在si, can we try using the

嗨,在si, can we try using the DSPS central example and modify this file with your peripheral's address? Let's see if a connection is possible in this manner.