I follow the instructions in BLE Mesh User guide, however I cannot get it working.
I am able to send command ''light on" and "light on 1" with commissioner, ( verified on sniffer that it is indeed send out )
However, the receiving side (BD_ADDR_ID = 1) didn't receive it. ( Set a break point at MeshLightServerCallback, and never triggered.)
One weird thing is that in function MeshGenericCallback, pEvent->eventData.initComplete.deviceIsCommissioned is TRUE even for the very first time, so MeshNode_Commission(&gRawCommData); is never executed. So I force the function to execute MeshNode_Commission at first entrance, but nothing happens, mesh device still cannot receive.
static meshResult_t MeshGenericCallback
(
meshGenericEvent_t* pEvent
)
{
switch (pEvent->eventType)
{
case gMeshInitComplete_c:
{
if (!pEvent->eventData.initComplete.deviceIsCommissioned)
{
/* This will trigger this callback again, but "deviceIsCommissioned" will be TRUE. */
MeshNode_Commission(&gRawCommData);
}
else
{
LED_StopFlashingAllLeds();
Led1On();
#if gAppLightBulb_d
Mesh_SetRelayState(TRUE);
#else
Mesh_SetRelayState(FALSE);
#endif
}
}
break;default:
{
/* Ignore */
}
break;}
return gMeshSuccess_c;
}
Inspired by Nishith Goswami's BLE Mesh Demo Application Setup
I turned off NVM (Non-Volatile Memory, aka Flash) and solved the problem.
NVM macro is defined in ApplMain.h :
#ifndef gAppUseNvm_d
#define gAppUseNvm_d (FALSE) // Originally (TRUE)
#endif
If NVM is necessary, an alternative is to put App_NvmErase() right after NV_Init();
#if gAppUseNvm_d
/* Initialize NV module */
NV_Init();
App_NvmErase();
#endif