Note: This KBA has been marked as deprecated. A more updated KBA can be found here:
This article discusses how a network co-processor (NCP) can handle stack events locally instead of sending every event to the host processor
Ordinarily, an NCP device sends and receives Bluetooth packets on behalf of a host processor but does not have any application layer intelligence: it receives commands from and sends events to the host, the host must tell the NCP what to do. However, in some cases it may be useful for the NCP to filter some of the events itself rather than sending every event to the host. One such use-case is where the system acts as a scanner in a high traffic environment. This could result in too many advertisements being received to be able to report them all to the host.
This section is a description of how to modify the NCP code and assumes that the reader is already familiar with the NCP, for instance by reading application note AN1042 “Using the Silicon Labs Bluetooth Stack in Network Co-processor Mode”. The simplest way to start is with an existing NCP project, if needed an NCP image can be created for the desired Soc/module from the Appbuilder (see ncp-empty-target). By default, the NCP passes all events to the host processor. However, this can be controlled by the implementation of local_handle_event() which is found in main.c. By default, this function performs no handling of events and returns false to indicate that the event passed to it has not been handled. If it is desired that a particular event be handled locally, this function can be customized. In this case, let’s assume that the desired behavior is to filter out any advertisements or scan responses that do not come from Silicon Labs devices. This can be accomplished by adding a case statement such as the following
This section of code simply checks to see if the first three bytes of the Bluetooth address, which come in reverse order, match the Silicon Labs range of addresses. If it does, then evt_handled is set false otherwise evt_handled is to true indicating that no further handling is required. This is a small change but it could dramatically reduce the amount of traffic between NCP and host as well as reducing the burden on the host itself.
In this way the handle_local_event() can be modified to perform any local event handling