Phase 4 — Wireless Protocol Integration
Integrate Nordic's wireless protocols (BLE, Thread/Zigbee, WiFi, LTE-M/NB-IoT) and implement application logic.
Nordic provides production-ready protocol stacks in the nRF Connect SDK. The Bluetooth stack is based on Zephyr's implementation with Nordic optimizations. Thread, Zigbee, and Matter support enable smart home applications, while cellular IoT is supported on the nRF9160.
Steps
Configure Bluetooth Low Energy
Set up BLE with Zephyr's Bluetooth stack for advertising, connections, and GATT services.
# prj.conf
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="MyDevice"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=2Initialization flow:
bt_enable(NULL)to initialize the stack- Define advertising data with
BT_DATAmacros - Register connection callbacks with
BT_CONN_CB_DEFINE - Start advertising with
bt_le_adv_start()
- Use
BT_CONN_CB_DEFINEfor static callback registration - Configure connection parameters for your power/latency needs
- Enable
CONFIG_BT_SETTINGSto persist bonding information - Use the nRF Connect mobile app for testing and debugging
See the Zephyr Bluetooth Guide.
Implement GATT services
Create custom BLE services and characteristics for your application.
GATT service pattern:
1. Define custom 128-bit UUIDs with BT_UUID_DECLARE_128
2. Create read/write handlers for characteristics
3. Use BT_GATT_SERVICE_DEFINE to declare the service
4. Include BT_GATT_CCC for notification support
5. Use bt_gatt_notify() to send notifications- Use 128-bit UUIDs for custom services
- Include CCC (Client Characteristic Configuration) for notifications
- Test with the nRF Connect mobile app's GATT viewer
- Consider using Nordic's GATT Service samples as templates
Add Thread / Zigbee support
Enable mesh networking protocols for smart home and industrial IoT applications.
# prj.conf — Thread
CONFIG_NETWORKING=y
CONFIG_NET_L2_OPENTHREAD=y
CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD=y
CONFIG_OPENTHREAD_CHANNEL=11
CONFIG_OPENTHREAD_PANID=4660Use the OpenThread API via openthread_get_default_context().
- Thread requires an IEEE 802.15.4 radio (nRF52840, nRF5340)
- Use the OpenThread CLI sample for initial testing
- Configure network credentials via CLI or programmatically
- Consider Matter for cross-ecosystem compatibility
See the Thread Development Guide.
Configure WiFi for nRF7002
Set up WiFi connectivity using the nRF7002 companion IC.
# prj.conf — WiFi
CONFIG_WIFI=y
CONFIG_WIFI_NRF700X=y
CONFIG_WPA_SUPP=y
CONFIG_NET_L2_WIFI_MGMT=y
CONFIG_NET_DHCPV4=yUse net_mgmt(NET_REQUEST_WIFI_CONNECT, ...) to connect.
- nRF7002 requires nRF5340 or nRF52840 as host
- Enable WPA3 for enhanced security
- Use low-power modes (TWT) for battery-powered devices
- Test with different access points for compatibility
See the nRF7002 Documentation.
Implement LTE-M / NB-IoT for nRF9160
Set up cellular connectivity for wide-area IoT applications.
# prj.conf — LTE
CONFIG_LTE_LINK_CONTROL=y
CONFIG_NRF_MODEM_LIB=y
CONFIG_MODEM_INFO=yInitialization:
nrf_modem_lib_init()to start the modemlte_lc_register_handler()for eventslte_lc_connect_async()to connect to the network
- Use LTE-M for mobility, NB-IoT for stationary sensors
- Configure PSM (Power Saving Mode) and eDRX for power optimization
- Test with nRF Cloud for easy connectivity verification
- Handle network registration and connection loss gracefully
See the nRF9160 Guide.
Develop application state machines
Implement application logic using state machines for reliable operation.
State machine pattern:
1. Define states as enum (INIT, IDLE, ADVERTISING, CONNECTED, ...)
2. Create state handler functions for each state
3. Use a function pointer array for state dispatch
4. Implement transition_to() for state changes
5. Consider Zephyr's SMF for complex state machines- Use state machines for complex control flow
- Document state transitions with diagrams
- Handle all edge cases and error states
- Use Zephyr's SMF (State Machine Framework) for complex state machines
Next
Continue to Phase 5 — Testing & Validation.