Extended Advertisements
silabs.com | Smart. Connected. Energy-friendly Rev. 6.0 | 14
4. However, this section of code has an intentional error built into it. The task here is to find out what’s wrong and
fix it. (hint : each of the BGAPI functions returns an error code, you can output the error code using printf(). Re-
fer to the BGAPI reference manual for the meaning of the error codes and for information about acceptable ad-
vertising configurations). Hint: you may want to turn off scan request reporting here to limit the number of mes-
sages being sent to the console, comment out the code added in section 1.4.
5. Once you’ve fixed the bug, you can move on to the client. Here you can add code to test the packet type to
check if the advertisement was of the extended type and print the PHY used for the primary and secondary ad-
vertisements. This information is used to determine which PHYs are actually being used by the advertiser. Paste
in the following at the very beginning of the extended scan response event handler
6. As a bonus exercise, you can also add code here to print out information about the address type and the bond
handle. This is left to the user to do.
7. Once the code in step 5 (and optionally step 6) has been added, build the project and flash it to client board.
8. Temporarily power down the server WSTK to prevent the client from connecting to it automatically.
9. Build the application and download to the target as before
10. Press PB0. You’ll see a message on the console indicating that we are now scanning on the LE Coded PHY.
11. Power up the server WSTK.
12. The client’s console will now connect when it finds the desired service UUID being advertised.
13. Press PB1 to switch the PHY, any of the supported PHYs can be selected by pressing PB1 to cycle through the
list. The server and client consoles each display the PHY currently in use. Note that the 500k PHY is not sup-
ported in this example.
3.2 Long Advertising Packet and the 2Mbps PHY
Another feature of extended advertising is the ability to set the PHY for the primary and secondary advertisements independently. This
gives the user the ability to use the 2Mbps PHY to save energy.
1. Go to the Visual GATT Editor and change the device name to “Extended Advertising Test Device” and change the
length parameter to 40.
2. In main-server.c find the comment /*section 3.1 LE Coded PHY*/ and make the following changes (the call to
gecko_cmd_le_gap_set_advertise_phy() in this section replaces the previous one)
if(0x80 & evt->data.evt_le_gap_extended_scan_re-
sponse.packet_type){
printf("extended advertising packet primary advertisement
on %s PHY and secondary advertisment on %s PHY\r\n",
getPhyName(evt-
>data.evt_le_gap_extended_scan_response.primary_phy).string,
getPhyName(evt-
>data.evt_le_gap_extended_scan_response.secondary_phy).string);
/*LAB Section 3.2 Step 3*/
}
gecko_cmd_le_gap_set_advertise_phy(3,le_gap_phy_coded, le_gap_phy_2m);
gecko_cmd_le_gap_clear_advertise_configuration(3,0x01);
gecko_cmd_le_gap_set_advertise_configuration(3,0x08);
gecko_cmd_le_gap_set_advertise_tx_power(3,100);