advertisement configuration at runtime using FRDMKW36

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

advertisement configuration at runtime using FRDMKW36

Jump to solution
1,897 Views
thailivenkatesh
Contributor III

 trying to update the advertisement scanning at runtime it is working fine but when i try to update multiple time it is updating only few times not consistently updated . Can anyone please help me to solve this issue. Below is the code return in serial manager.c file. sending command as #ccdas_123 from iot tool box. This value i am storing in hardware parameters  and when i reset updated value is stores in advertisement structure.   But hardware structure is not updating sometimes.

 

serial_t *pSer = &mSerials[0];
uint16_t idx;
idx = pSer->txCurrent;
(void)NV_ReadHWParameters(&gHardwareParameters);//venk

//initially default value loaded if eeprom write new updated else condition
if (!gHardwareParameters.devidset)//default nonzero
advScanStruct[2].aData = (uint8_t*) "cdas-123";//default

else{
advScanStruct[2].aData=gHardwareParameters.device_id;}
//idx points to current txQueue buffer
if(idx==0)
idx=5;

else
idx = pSer->txCurrent;

//current buffer loaded to temp value
temp_id=pSer->txQueue[idx-1].pData;//venk
temp_id2=temp_id+9;
temp_id3=temp_id+9;

if(((*temp_id2==' ')&&(*++temp_id2=='#'))||((*temp_id3=='#')&&(*++temp_id3=='c')))
{
gHardwareParameters.temp_id1=temp_id2;
if(*gHardwareParameters.temp_id1=='c')
{
gHardwareParameters.temp_id1=gHardwareParameters.temp_id1+1;
}

else
{
gHardwareParameters.temp_id1=gHardwareParameters.temp_id1+2;
}

gHardwareParameters.device_id=(uint8_t*) (gHardwareParameters.temp_id1);//venk
advScanStruct[2].aData=gHardwareParameters.device_id;
gHardwareParameters.devidset =1;
(void)NV_WriteHWParameters(&gHardwareParameters);//venk

}

0 Kudos
1 Solution
1,797 Views
nxf56274
NXP Employee
NXP Employee

Hi,

There are too many points you need to notice. So I wrote this program. Input '#' and after this char, it is your device name. For example, '#asdf', the adv name will become 'asdf'. Pay attention that the device name should smaller than 6 byte. This is due the limit of adv packet length.

I do not write adv name into memory. You can add it by yourself. The code is added at 'BleApp_ReceivedUartStream'.

nxf56274_1-1636428058441.png

nxf56274_0-1636428053842.png

nxf56274_2-1636428066842.png

 

 

View solution in original post

8 Replies
1,865 Views
nxf56274
NXP Employee
NXP Employee

Hi,

When you try to update the scanning data, please firstly stop the scanning. After the data is written, start scanning. Don't modify the scanning data when your mcu is scanning.

Have a great day,

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,852 Views
thailivenkatesh
Contributor III

Hi,
      Thanks for your support and I followed your solution but still facing same problem.  

0 Kudos
1,843 Views
nxf56274
NXP Employee
NXP Employee

Hi,

You want to use iot toolbox to send the new device name for mcu to scan? Am I correct? Where do you put the stop scanning function?

1,837 Views
thailivenkatesh
Contributor III

Hi ,

     Yes I am sending device name from IOT tool box to update the advertisement structure and did not use any stop scanning functions. but i searched for Gap_StopAdvertising()   only declaration  is available in gap_interface.h file but no definition for it .Please suggest me any solution for it.

0 Kudos
1,832 Views
nxf56274
NXP Employee
NXP Employee

Hi,

When you send the new device name to mcu, you firstly write it into memory. And then make mcu disconnect from the phone using 'Gap_Disconnect'. Read the adv structure from the memory. Use 'Gap_SetAdvertisingData' to set the adv data. Use 'App_StartAdvertising' to start the adv again.

1,822 Views
thailivenkatesh
Contributor III

HI,

      I followed your procedure it is working better than previous code but when I try to change device name it is updating ok for 4 times when  I update 5th time it is not updating or even when I reset the mcu it is updating 2 times again showing previous updated value and I am not understanding why there is inconsistent in updating the value or problem with proper reading or writing to ghardware structure.

0 Kudos
1,798 Views
nxf56274
NXP Employee
NXP Employee

Hi,

There are too many points you need to notice. So I wrote this program. Input '#' and after this char, it is your device name. For example, '#asdf', the adv name will become 'asdf'. Pay attention that the device name should smaller than 6 byte. This is due the limit of adv packet length.

I do not write adv name into memory. You can add it by yourself. The code is added at 'BleApp_ReceivedUartStream'.

nxf56274_1-1636428058441.png

nxf56274_0-1636428053842.png

nxf56274_2-1636428066842.png

 

 

1,790 Views
thailivenkatesh
Contributor III

Hi,    

     Thank you very much for your support  now it is working fine and it is updating multiple times consistently.

Tags (1)
0 Kudos