If the MAC address is not valid, then the firmware is stuck in while(1) loop with LED blinking
continuously.
Step 3.
Initialize the hardware callback functions for the BLE hardware.
You do this by updating
MOBLE_USER_BLE_CB_MAP user_ble_cb =
{
Appli_BleStackInitCb,
Appli_BleSetTxPowerCb,
Appli_BleGattConnectionCompleteCb,
Appli_BleGattDisconnectionCompleteCb,
Appli_BleUnprovisionedIdentifyCb,
Appli_BleSetUUIDCb,
};
Step 4.
These APIs are useful to have an application interface for BLE radio initialization and TxPower
configuration.
–
Initialize GATT connection and disconnection callbacks for the application interface.
–
BluenrgMesh_BleHardwareInitCallBack(&user_ble_cb)
can be called to complete the
initialization of hardware callbacks.
Step 5.
Initialize the BlueNRG-Mesh library by calling
BluenrgMesh_Init(bdaddr)
.
In the event of an error, the demo firmware prints a message on the terminal window opened for the
VCOM port created by the USB connection available on the boards, and the
Appli_LedBlinkCb()
API causes the LED to blink continuously.
Step 6.
Check whether the device has been provisioned or not. A provisioned device has network keys and
other parameters configured in the internal flash memory.
Checks can be performed with
BluenrgMesh_IsUnprovisioned()
API.
If the Node is unprovisioned, BluenrgMesh_InitUnprovisionedNode() API initializes it.
If the device is already provisioned , then
BluenrgMesh_InitprovisionedNode()
API helps to
initialize the device.
Step 7.
Print the messages to the terminal window for the nodes that are being initialised.
The message also prints the MAC address assigned to the node.
Step 8.
Check the button state. To initialize the node to the unprovisioned state, hold down the user button.
When the unprovisioning button sequence is detected, the
BluenrgMesh_Unprovision()
API
erases all the network parameters configured in the internal memory of the device.
Once unprovisioning is complete, you need to reset the board.
Step 9.
Initialize the vendor model callback functions that are triggered by the events.
BluenrgMesh_SetVendorCbMap(&vendor_cb);
Step 10.
Process MoBLE and HCI events in while(1) loop.
The application must call
BluenrgMesh_Process()
in while(1) loop as frequently as possible.
This function calls
BLE_StackTick()
internally to process BLE communication.
Any application implementation shall be performed in the state-machine by non-blocking functions with
frequent calls to
BluenrgMesh_Process()
.
Step 11.
Check for user-inputs or buttons regularly for any action to take.
UM2295
Initialization and main application loop
UM2295
-
Rev 1
page 18/35