In kw41z bluetooth beacon demo code, I modify it to do a scanning first, right after Initialization,
bleResult_t result = App_StartScanning(&gScanParams, BleApp_ScanningCallback);
however, the result is always 4 (gBleFeatureNotSupported_c). Scan cannot be started. How do I fix this?
Later I try modified the hid_host code, where the scan function works, and add advertise functions,
bleResult_t result = Gap_SetAdvertisingParameters((gapAdvertisingParameters_t*)&gAppAdvParams);
And the result is also 4 (gBleFeatureNotSupported_c). Advertise cannot be started. What a bummer!
I think there's some place specify the role of device, and then central can only scan, and peripheral can only advertise.
But I cannot find the place where such role is specified in these project codes.
I want my device be capable of both scan and advertise, it seems Observer and Broadcaster are capable both rx & tx.
From BLE Application Developer's Guide:
o Scans for advertisers, but does not initiate connections; Transmit is optional
o Advertises, but does not accept connection requests from Centrals; Receive is optional
I found the cause of the problem.
It's the library.
All the APIs referenced in this document are available in the Central and Peripheral libraries. For example, ble_host_lib.a is a full-featured library with complete support for both Central and Peripheral APIs, at GAP level, as well as Client and Server APIs, at GATT level.
However, some applications may be targeted to memory-constrained devices and do not need the full support. In the interest of reducing code size and RAM utilization, two more libraries are provided:
o Supports only APIs for the GAP Peripheral and GAP Broadcaster roles
o Supports only APIs for the GATT Server role
o Supports only APIs for the GAP Central and GAP Observer roles
o Supports only APIs for the GATT Client role
If one attempts to use an API that is not supported (for instance, calling Gap_Connect with the ble_host_peripheral_lib.a), then the API returns the gBleFeatureNotSupported_c error code.
After I linked the correct library, the problem is solved.