cancel
Showing results for 
Search instead for 
Did you mean: 

How can LPN Unprovision without NVIC_SystemReset in Mesh Network?

Deepak.Aagri
Associate III

Hello ST,

Below function need for Unprovising from network ::

void Appli_Unprovision(void)

{

 if(!ProxyFlag)

 {

  /* No GATT connection */

  BLEMesh_StopAdvScan();

    

  PalNvmErase(NVM_BASE, 0);    

  PalNvmErase(NVM_BASE, 0x1000);

  PalNvmErase(APP_NVM_BASE, 0);

  PalNvmErase(PRVN_NVM_BASE_OFFSET, 0);

  TRACE_M(TF_PROVISION,"NVM erased\r\n");    

  BLEMesh_Unprovision();

  AppliNvm_ClearModelState();   

  TRACE_M(TF_PROVISION,"Device is unprovisioned by application \r\n");    

  BLEMesh_Process();

  NVIC_SystemReset();

 }

}

We don't want to reset the system but without NVIC_SystemReset(); system behave will change and Transport layer become busy.

Please provide the solution for this. We have already spent too much time in STM32WB Mesh network development and our project dead line coming closer. Request to you response back as soon as possible for this issue..

Best Regards

Deepak

28 REPLIES 28
SJAIN.2
Associate

After unprovisioning, we have to initialize several part especially the GATT Database to advertise the correct MESH UUID service and characteristics. NVIC_SystemReset() is an "easy" way to be sure that the Node will start with the correct configuration.

But when the LP Node enter in Low Power mode with friend Node the only one way to communicate with this LP Node is with the friend Node. I do not really understand how you can unprovision LP Node without Friend Node?

Can you please share more details?

To start the correct configuration of node, what makes node to advertise the correct MESH UUID service and characteristics?

Can we reinitialize the all require function again..

Why we have two core CPU when it require complete reset. Can we reset the CPU2 (Ratio) then

 /**

//   * Select HSI as system clock source after Wake Up from Stop mode

//   */

//  LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI);

//

//  /* Initialize low power manager */

//  UTIL_LPM_Init( );

//  /* Initialize the CPU2 reset value before starting CPU2 with C2BOOT */

//  LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);

// //appe_Tl_Init(); /* Initialize all transport layers */

//  TL_MM_Config_t tl_mm_config;

//   SHCI_TL_HciInitConf_t SHci_Tl_Init_Conf;

//   /**< Reference table initialization */

//   TL_Init();

//

//   /**< System channel initialization */

//   UTIL_SEQ_RegTask( 1<< CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, UTIL_SEQ_RFU, shci_user_evt_proc );

//   SHci_Tl_Init_Conf.p_cmdbuffer = (uint8_t*)&SystemCmdBuffer;

//   SHci_Tl_Init_Conf.StatusNotCallBack = APPE_SysStatusNot;

//   shci_init(APPE_SysUserEvtRx, (void*) &SHci_Tl_Init_Conf);

//

//   /**< Memory Manager channel initialization */

//   tl_mm_config.p_BleSpareEvtBuffer = BleSpareEvtBuffer;

//   tl_mm_config.p_SystemSpareEvtBuffer = SystemSpareEvtBuffer;

//   tl_mm_config.p_AsynchEvtPool = EvtPool;

//   tl_mm_config.AsynchEvtPoolSize = POOL_SIZE;

//   TL_MM_Init( &tl_mm_config );

//

//   TL_Enable();

//   BLEMesh_InitUnprovisionedNode(); /* Initalizes Unprovisioned node */

reinitialize Mesh network again.........

-----------------------------------------------------------------------------------------------------

Q-- I do not really understand how you can unprovision LP Node without Friend Node?

Ans- I think to process Unprovisioning a node, before that node must be Provision by Provisioner and Provisioner node itself has characteristics of Friend Node.

Best Regards

Deepak

EMECH
ST Employee

Hi Deepak,

At the Provisioner side, if you want to unprovision some Node, previously provisioned by the Provisioner, you have to use the following ATEP command:

ATEP UNPV xxxx

where xxxx is the Node address set previously by the Provisioner (xxxx >= 0002)

Unfortunately with the current version of the Provisioner software you can only unprovision the last Node you have provisioned.

To have the possibility to unprovision the provisioned Node of your choice, you have to modify the following function in the Firmware\Middlewares\ST\STM32_WPAN\ble\mesh\MeshModel\Srcconfig_client.c file:

/**

* @brief  GenericModelServer_GetOpcodeTableCb: This function is call-back 

*     from the library to send Model Opcode Table info to library

* @param MODEL_OpcodeTableParam_t: Pointer to the Generic Model opcode array 

* @param length: Pointer to the Length of Generic Model opcode array

* @retval MOBLE_RESULT

*/ 

MOBLE_RESULT ConfigClientModel_SendMessage(MOBLE_ADDRESS dst_peer ,

                   MOBLEUINT16 opcode, 

                   MOBLEUINT8 *pData,

                   MOBLEUINT32 dataLength)

{

 MOBLE_ADDRESS peer_addr;  

 peer_addr = BLEMesh_GetAddress(); 

 MOBLEUINT8 *pTargetDevKey;

 MOBLE_RESULT result = MOBLE_RESULT_SUCCESS;  

  

  pTargetDevKey = GetNewProvNodeDevKey();

   

 result = ConfigModel_SendMessage(peer_addr, dst_peer, opcode, 

              pData, dataLength, pTargetDevKey); 

 return result;

}

As following:

/**

* @brief  GenericModelServer_GetOpcodeTableCb: This function is call-back 

*     from the library to send Model Opcode Table info to library

* @param MODEL_OpcodeTableParam_t: Pointer to the Generic Model opcode array 

* @param length: Pointer to the Length of Generic Model opcode array

* @retval MOBLE_RESULT

*/ 

MOBLE_RESULT ConfigClientModel_SendMessage(MOBLE_ADDRESS dst_peer ,

                   MOBLEUINT16 opcode, 

                   MOBLEUINT8 *pData,

                   MOBLEUINT32 dataLength)

{

 MOBLE_ADDRESS peer_addr;  

 peer_addr = BLEMesh_GetAddress(); 

 MOBLEUINT8 *pTargetDevKey;

 MOBLE_RESULT result = MOBLE_RESULT_SUCCESS;  

  

 pTargetDevKey = (MOBLEUINT8 *)AppliPrvnNvm_GetNodeDevKey(dst_peer);

  

 result = ConfigModel_SendMessage(peer_addr, dst_peer, opcode, 

              pData, dataLength, pTargetDevKey); 

 return result;

}

And add the following include at the beginning of this file:

#include "appli_nvm.h"

These modifications will be part of the next delivery (1.15.0)

To unprovision the Provisioner, the following ATUT command as to be used:

ATUT SET-02

I hope this will help you.

Best regards.

Hello EMECH,

The above changes respond back on terminal:

-------------------------------------------------------------------------------

ConfigClientNodeReset- Config Client Node Reset message

dst_peer= ,peer_add=...........................

------------------------------------------------------------------

if we do not reset the LPN board (Dongle) and change the Provisioner (another STM32WB Nucleo Board hardware. which create new network Appli_StartProvisionerMode(1);).

During Config Client Process it will get stuck below point..

0693W00000NsrhOQAR.pngOnce again if we reset the same LPN node (hard reset) (dongle) or NVIC_SystemReset();.

Scan again on terminal and restart the provisioning process. it is compiling the process. as shown below trace:

Appli_ConfigClient_ConfigureNode - **Node is configured**

my question is why LPN node require reset?

we don't want reset in security application...

I hope you have tested before releasing new version.

Best Regards

Deepak

EMECH
ST Employee

Hello Deepak,

Normally you do not have to reset any Node for unprovisioning (by hard reset or NVIC_SystemReset()).

What is the version of the STM32Cube_FW_WB used ?

Actually NVIC_SystemReset() is only called when you unprovision manually a node (RESET and SW1 button actions) and when you unprovision the Provisioner with the ATUT SET-02 command from Provisioner terminal.

In both case this NVIC_SystemReset() calls can be removed.

Best regards.

Hi EMECH,

Really Really thanks for your quick response..

Find the STM32Cube_FW_WB  details below:

BLE-Mesh Lighting Demo v1.13.002

BLE-Mesh Library v01.13.002

BLE Stack v1.13.0 Branch=0 Type=5

FUS v1.2.0

Best Regards

Deepak Aagri

EMECH
ST Employee

Deepak,

OK, let me check the differences you can have between your version and the last 1.14.0 not yet available on st.com.

I will get back to you with probably some files to update.

Best regards.

Deepak,

In addition of the previous modifications, you have to replace in the following files:
* C:\BLE\STM32Cube_FW_WB_V1.13.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE_MeshLightingProvisioner\STM32_WPAN\app\appli_nvm.c
The following defines:
#define FIRST_PRVND_NODE_ADDRSS 2U
#define LAST_PRVND_NODE_ADDRSS (unsigned int) PRVN_NVM_MAX_SUBPAGE+FIRST_PRVND_NODE_ADDRSS)
By the following ones:
#define FIRST_PRVND_NODE_ADDRESS 1U/*2U*/
#define LAST_PRVND_NODE_ADDRESS (unsigned int)(PRVN_NVM_MAX_SUBPAGE+FIRST_PRVND_NODE_ADDRESS)
The following function:
/**
* @brief Save Embedded provisioner data in nvm
* @param devkey: data buffer to be saved
* @param address: address of the Node to be saved
* @param pUUID: pointer to the UUID
* @param numElements: number of elements of the node
* @retval MOBLE_RESULT_SUCCESS on success
*/
MOBLE_RESULT AppliPrvnNvm_SaveData(uint8_t* devkey,
MOBLE_ADDRESS address,
uint8_t* pUUID,
uint8_t numElements)
{
MOBLE_RESULT result = MOBLE_RESULT_SUCCESS; /* if save model state not defined, return MOBLE_RESULT_FAIL */
uint8_t *pNodeInfo;
MOBLEUINT16 sizeTosave=0;
uint16_t numOfElements = 0;
pNodeInfo = PrvnNvm_Reqs.prvnData;
/* Copy the Address and Number of Elements */
memcpy(pNodeInfo, &address, 2);
pNodeInfo += 2;
numOfElements = numElements;
memcpy(pNodeInfo, &numOfElements, 2);
pNodeInfo += 2;
sizeTosave += 4;
/* Copy the Device Key of the Node Primary address */
memcpy(pNodeInfo, devkey, DEVICE_KEY_SIZE);
pNodeInfo += DEVICE_KEY_SIZE;
sizeTosave += DEVICE_KEY_SIZE;
#if ENABLE_SAVE_UUID_PER_NODE
/* Copy the UUID of the Node */
memcpy(pNodeInfo, pUUID, UUID_SIZE);
pNodeInfo += UUID_SIZE;
sizeTosave += UUID_SIZE;
#endif
/*
The 3-Element Node data saving will look like this ->
0-1 2B Primary address
2,3 2B Element count
4-19 DevKey for example 0x01, 0x02, ... 10
20-21 2B Primary address
22-23 2B Element count
24-39 16B DevKey for next address
Advantage: We identify the Primary Node address
*/
NodeUnderProvisionParam.newNodeAddress = address;
NodeUnderProvisionParam.newNodeElements = numElements;
PrvnNvm_Reqs.size = sizeTosave;
return result;
}
By this one:
/**
* @brief Save Embedded provisioner data in nvm
* @param devkey: data buffer to be saved
* @param address: address of the Node to be saved
* @param pUUID: pointer to the UUID
* @param numElements: number of elements of the node
* @retval MOBLE_RESULT_SUCCESS on success
*/
MOBLE_RESULT AppliPrvnNvm_SaveData(uint8_t* devkey,
MOBLE_ADDRESS address,
uint8_t* pUUID,
uint8_t numElements)
{
MOBLE_RESULT result = MOBLE_RESULT_SUCCESS; /* if save model state not defined, return MOBLE_RESULT_FAIL */
uint8_t *pNodeInfo;
// MOBLEUINT16 sizeTosave=0;
uint16_t numOfElements = 0;
pNodeInfo = PrvnNvm_Reqs.prvnData;
/* Copy the Address and Number of Elements */
memcpy(pNodeInfo, &address, 2);
pNodeInfo += 2;
numOfElements = numElements;
memcpy(pNodeInfo, &numOfElements, 2);
pNodeInfo += 2;
// sizeTosave += 4;
/* Copy the Device Key of the Node Primary address */
memcpy(pNodeInfo, devkey, DEVICE_KEY_SIZE);
pNodeInfo += DEVICE_KEY_SIZE;
// sizeTosave += DEVICE_KEY_SIZE;
#if ENABLE_SAVE_UUID_PER_NODE
/* Copy the UUID of the Node */
memcpy(pNodeInfo, pUUID, UUID_SIZE);
pNodeInfo += UUID_SIZE;
// sizeTosave += UUID_SIZE;
#endif
/*
The 3-Element Node data saving will look like this ->
0-1 2B Primary address
2,3 2B Element count
4-19 DevKey for example 0x01, 0x02, ... 10
20-21 2B Primary address
22-23 2B Element count
24-39 16B DevKey for next address
Advantage: We identify the Primary Node address
*/
NodeUnderProvisionParam.newNodeAddress = address;
NodeUnderProvisionParam.newNodeElements = numElements;
PrvnNvm_Reqs.size = PRVN_NVM_CHUNK_SIZE/*sizeTosave*/;
return result;
}
The other following function:
/**
* @brief Function to get the particular node device key with node address friom the
* provisioner flash.
* @param MOBLE_ADDRESS: node address
* @retval subPageAddrss: pointer to the sub page address
*/
MOBLEUINT32* AppliPrvnNvm_GetNodeDevKey(MOBLE_ADDRESS addrss)
{
MOBLEUINT16 subPageIndx;
MOBLEUINT32 *subPageAddress;
subPageIndx = addrss - FIRST_PRVND_NODE_ADDRSS;
if(subPageIndx >= PRVN_NVM_MAX_SUBPAGE)
{
TRACE_M(TF_PROVISION,"Invalid Address \r\n");
return 0;
}
else
{
subPageAddress = (MOBLEUINT32 *)(PRVN_NVM_BASE_OFFSET + PRVN_NVM_SUBPAGE_OFFSET(subPageIndx));
TRACE_M(TF_PROVISION,"Address Of SubPage = %p \r\n", (void *)subPageAddress);
}
return subPageAddress;
}
By this one:
/**
* @brief Function to get the particular node device key address with node address from the
* provisioner flash.
* @param MOBLE_ADDRESS: node address
* @retval subPageAddrss: pointer to the sub page address
*/
MOBLEUINT32* AppliPrvnNvm_GetNodeDevKey(MOBLE_ADDRESS address)
{
MOBLEUINT16 subPageIndx;
MOBLEUINT32 *subPageAddress;
subPageIndx = address - FIRST_PRVND_NODE_ADDRESS;
if(subPageIndx >= PRVN_NVM_MAX_SUBPAGE)
{
TRACE_M(TF_PROVISION,"Invalid Address \r\n");
return 0;
}
else
{
/* In the NVM: the Node device key is after the Unicast Address (2 bytes) and the Number of Elements (2 bytes) */
subPageAddress = (MOBLEUINT32 *)(PRVN_NVM_BASE_OFFSET + PRVN_NVM_SUBPAGE_OFFSET(subPageIndx) + 4);
// TRACE_M(TF_PROVISION,"Address Of SubPage = %p \r\n", (void *)subPageAddress);
}
return subPageAddress;
}
* C:\BLE\STM32Cube_FW_WB_V1.13.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE_MeshLightingProvisioner\STM32_WPAN\app\appli_nvm.h
Replace the following definition:
typedef struct
{
MOBLEUINT8 devKey[4+DEVICE_KEY_SIZE];
#if ENABLE_SAVE_UUID_PER_NODE
MOBLEUINT8 node_UUID[UUID_SIZE];
#endif
} NvmPerNode_t;
By this one:
typedef struct
{
MOBLEUINT8 devKey[4+DEVICE_KEY_SIZE];
#if ENABLE_SAVE_UUID_PER_NODE
MOBLEUINT8 node_UUID[UUID_SIZE];
#endif
MOBLEUINT8 dummy[4]; /* 4 bytes more for 3 or 5 words of 64 bits */
} NvmPerNode_t;
Normally with all these modifications, you will be able from Provisioner to unprovision all provisioned nodes with the following command:
ATEP UNPV xxxx
Where xxxx is the provisioned node address (>= 0002).
I have attached to this email the modified files.
Best regards.
ST Restricted

Hello EMECH,

After following above modification. Still we are facing same problem from second STM32WB Nucleo board.. 

0693W00000Nt7arQAB.png------------------------------------------------------------------------------------------------------

First STM32WB Nucleo Board Response:..

32293 ConfigClient_NodeReset - Config Client Node Reset message

 Request to Unprovision:2 

32329 ConfigClientModel_ProcessMessageCb - dst_peer = [0001] , peer_add = [0002], opcode= [804A] ,response= [00]

 32330 ConfigClient_NodeResetStatus - ConfigClient_NodeResetStatus Received

LPN Board Response this:

Device is unprovisioned by provisioner

------------------------------------------------------------------------------------------------------------

if we reset LPN (Dongle) Board then restart provisioning process from second STM32 Nucleo Board again it will config Client App Key Add properly..

Best Regards

Deepak Aagri