QN902x cannot broadcast.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

QN902x cannot broadcast.

1,019 Views
leaflee
Contributor III

I use QN902x to develop a BLE peripheral device on IAR ARM 8.11.  I change many source files in NXP SDK.

The HW is OK, if using NXP project in QN902x HW, my phone can get QN902x broadcast package.


But if using my project with modified source file, my phone can not get QN902x broadcast package. See below:

I use this function to initialize a broadcast,

app_gap_adv_start_req(GAP_GEN_DISCOVERABLE|GAP_UND_CONNECTABLE, //store_ble_dev_mode_flag(mode);
app_env.adv_data, 17, app_env.scanrsp_data, 20, GAP_ADV_FAST_INTV1, GAP_ADV_FAST_INTV2);

Is the BLE IP stack isn't initialized well?


What is wrong?

7 Replies

807 Views
leaflee
Contributor III

Here are my adv/scan rsp data:

app_env.adv_data[0]=2;
app_env.adv_data[1]=1;
app_env.adv_data[2]=6;
app_env.adv_data[3]=3;
app_env.adv_data[4]=12;
app_env.adv_data[5]=8;
app_env.adv_data[6]=0x51;
app_env.adv_data[7]=0x75;
app_env.adv_data[8]=0x69;
app_env.adv_data[9]=0x6e;
app_env.adv_data[10]=0x74;
app_env.adv_data[11]=0x69;
app_env.adv_data[12]=0x63;
app_env.adv_data[13]=0x20;
app_env.adv_data[14]=0x42;
app_env.adv_data[15]=0x4c;
app_env.adv_data[16]=0x45;

app_env.scanrsp_data[0]=3;
app_env.scanrsp_data[1]=2;
app_env.scanrsp_data[2]=0xd0;
app_env.scanrsp_data[3]=0xcc;
app_env.scanrsp_data[4]=5;
app_env.scanrsp_data[5]=0x12;
app_env.scanrsp_data[6]=6;
app_env.scanrsp_data[7]=0;
app_env.scanrsp_data[8]=0x80;
app_env.scanrsp_data[9]=0x0c;
app_env.scanrsp_data[10]=9;
app_env.scanrsp_data[11]=0x5d;
app_env.scanrsp_data[12]=0x2e;
app_env.scanrsp_data[13]=0xb2;
app_env.scanrsp_data[14]=0xb9;
app_env.scanrsp_data[15]=0;
app_env.scanrsp_data[16]=0;
app_env.scanrsp_data[17]=0;
app_env.scanrsp_data[18]=0;
app_env.scanrsp_data[19]=1;
app_gap_adv_start_req(GAP_GEN_DISCOVERABLE|GAP_UND_CONNECTABLE, app_env.adv_data, 17, app_env.scanrsp_data, 20, GAP_ADV_FAST_INTV1, GAP_ADV_FAST_INTV2);

0 Kudos

807 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Leaf Lee,

The adv data is wrong, I am assuming that you want to write Quintic BLE.

As you know, you have to follow the structure for the adv packet, First 

0x02 Length, 0x01 Data Type Name Flags and the values that you want.

In this case 0x06 

/// General discovery flag - AD Flag
#define GAP_LE_GEN_DISCOVERABLE_FLG 0x02
/// Legacy BT not supported - AD Flag
#define GAP_BR_EDR_NOT_SUPPORTED 0x04

But the next value is wrong, you are setting a length with 3, in this byte should be 0x0c. After that the «Complete Local Name

https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile 

app_env.adv_data[0]=2;
app_env.adv_data[1]=1;
app_env.adv_data[2]=6;
app_env.adv_data[3]=3;
app_env.adv_data[4]=12;
app_env.adv_data[5]=8;

You can try with this different options.

uint8_t adv_data[] = 
{
  0x02,GAP_AD_TYPE_FLAGS,GAP_BR_EDR_NOT_SUPPORTED|GAP_LE_GEN_DISCOVERABLE_FLG,
  0x0c,GAP_AD_TYPE_SHORTENED_NAME,0x51,0x75,0x69,0x6e,0x74,0x69,0x63,0x20,0x42,0x4c,0x45
};‍‍‍
uint8_t adv_data[] = 
{
   0x02,GAP_AD_TYPE_FLAGS,GAP_BR_EDR_NOT_SUPPORTED|GAP_LE_GEN_DISCOVERABLE_FLG,
   0x0c,GAP_AD_TYPE_SHORTENED_NAME,'Q','u','i','n','t','i','c',' ',B','L','E'
};‍‍‍‍‍

hope it helps.

Regards,

Mario

807 Views
leaflee
Contributor III

After that, I encountered another question, my phone can connect the QN902x device, but cannot get the ATT service and ATT characteristics. (if using NXP demo project, PROXR, i.e.  My phone can get the ATT services and write/read ATT characteristics.)

Here is my ATT database setting, I defined a ATT service (UUID=0xccd0), 2 ATT characteristics(UUID=0xccd1/0xccd2).

#define LLF_MAIN_SVC 0xccd0
#define LLF_ATT_CHAR_REPORT 0xccd1
#define LLF_ATT_CHAR_COMMAND 0xccd2

const struct atts_desc llf_att_db[5] =
{
[0]={ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), sizeof(LLF_MAIN_SVC), sizeof(LLF_MAIN_SVC), (uint8_t *)&llf_main_svc},
[1]={ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), sizeof(llf_report_char), sizeof(llf_report_char), (uint8_t *)&llf_report_char},
[2]={LLF_ATT_CHAR_REPORT, PERM(RD, ENABLE), 10, 0, NULL},
[3]={ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), sizeof(llf_command_char), sizeof(llf_command_char), (uint8_t *)&llf_command_char},
[4]={LLF_ATT_CHAR_COMMAND, PERM(WR, ENABLE), 8, 0, NULL},
};

const uint16_t llf_main_svc = LLF_MAIN_SVC;
const struct atts_char_desc llf_report_char = ATTS_CHAR(ATT_CHAR_PROP_RD, 0, LLF_ATT_CHAR_REPORT);
const struct atts_char_desc llf_command_char = ATTS_CHAR(ATT_CHAR_PROP_WR_NO_RESP, 0, LLF_ATT_CHAR_COMMAND);

Note: The ATT service(UUID=0xccd0) has broadcasted.

 

0 Kudos

807 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Leaf Lee,

I am assuming that you are working or you want to work with a custom profile, aren't you?

Please look at the QPPS example. 

What is the version that you are working on? 1.3.9 or 1.4.0?

Regards,

Mario

0 Kudos

807 Views
leaflee
Contributor III

Yes.

The problem is solved, change the following statement:

[0]={ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), sizeof(LLF_MAIN_SVC), sizeof(LLF_MAIN_SVC), (uint8_t *)&llf_main_svc},

to:

[0]={ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), sizeof(llf_main_svc), sizeof(llf_main_svc), (uint8_t *)&llf_main_svc},

sizeof(LLF_MAIN_SVC) is 4, not 2.

Thanks for your valuable advice!

807 Views
leaflee
Contributor III

You are right! Now the broadcast works well.

0 Kudos

807 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Leaf Lee,

I am not sure what is your adv data, I tested with the broadcaster example and it works.

                    // start adv
                    app_gap_adv_start_req(GAP_GEN_DISCOVERABLE | GAP_UND_CONNECTABLE,
                                          adv_data, sizeof(adv_data), 
                                         scan_data, sizeof(scan_data),
                                          GAP_ADV_INTV1, GAP_ADV_INTV2);

What is the adv data that you are setting up? 

Regards,

Mario

0 Kudos