RAK811 Write Partition to save parameters

Hello, im trying to use the function “write_partition” to write a node id with command line. I saw this definition:

typedef enum  {
    PARTITION_0 = 0,

Also, to save the parameters of the LoRa communication we have:

	  g_lora_config.lorap2p_param.Frequency = atoi(argv[1]);
	  g_lora_config.lorap2p_param.Spreadfact = atoi(argv[2]);
	  g_lora_config.lorap2p_param.Bandwidth = atoi(argv[3]);
	  write_partition(PARTITION_0, (char *)&g_lora_config, sizeof(g_lora_config));
	  e_printf("OK  \r\n");

So my question is, where (partition or table) i need use to save s “Node ID” number ?


Im trying to do something like this:

	  NodeID[0] = atoi(argv[1]);
	  NodeID[1] = atoi(argv[2]);
	  NodeID[2] = atoi(argv[3]);
	  write_partition(PARTITION_0, (char *)&NodeID, sizeof(NodeID));
	  e_printf("Node ID Saved in RAK811 \r\n");

But my main problem is WHERE save the information. PARTITION_1 and PARTITION_0 are used.

No one save some parameters in the non volatile memory ?

Hi @FraCaPr,

Which source code or SDK are you using?

Hi, thank you for you time. Im using the code : https://github.com/RAKWireless/RAK811_LoRaNode

So, can you help me ?

some new info about it ?

You should add your array NodeID[] to struct “lora_config_t” in “lora_config.h”.
Then save it as this:

  g_lora_config.NodeID[0] = atoi(argv[1]);
  g_lora_config.NodeID[1] = atoi(argv[2]);
  g_lora_config.NodeID[2] = atoi(argv[3]);
  write_partition(PARTITION_0, (char *)&g_lora_config, sizeof(g_lora_config));

After initialization,you could use it like this:g_lora_config.NodeID[1];

1 Like

Hi @leopold, thank you so much ! you can close the thread !