u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
308 stars 93 forks source link

Antenna Tuner Control #282

Open jamal-mouline opened 2 weeks ago

jamal-mouline commented 2 weeks ago

Hi @hkro @ZillKhan @steve.brown

As discussed on the CD / uBlox call from last Wed Sep 9/25 Opening this ticket as a placeholder to provide a method to configure the "Antenna Tuning" feature via ubxlib Either a new API using the device handle obtained from uDeviceOpen() API or an alternative way to directly setup the required AT command

Thank you

hkro commented 2 weeks ago

Hi @jamal-mouline, while we could provide a generic ubxlib API for this, any factory/production oriented operation, which is likely time-sensitive and product/module specific, you would be better off with an AT command crafted specifically to your needs using the ubxlib AT Client directly. Since you are using ubxlib, just obtain the AT handle with uCellAtClientHandleGet() and write only the code you need for your specific production case.

jamal-mouline commented 2 weeks ago

Hi @hkro Thank you for the feedback. We can certainly make direct use of the AT Client to configure the antenna tuner

To that end, I wanted to double check the correct sequence of commands to accomplish that Below is a copy paste from the AT Manual for the SARA-R5 / LEXI-R5 series On page 285, section 15.5.5, I found this example Could you please confirm these are the proper steps?

Enabling antenna tuner control AT+CFUN=0 OK Disable the protocol stack. AT+UTEST=1 OK Enter the test mode. AT+UTEST=4,1 OK The module enables the antenna dynamic tuner feature. AT+UTEST=0 OK Enter the normal mode. AT+CFUN=1 OK Restore full module functionality.

Also, according to the documentation for +UTEST=4, section 15.5 " The antenna dynamic tuner control setting is stored in the NVM, and its configuration is effective after exiting the test mode. " I wanted to confirm that this has to be done only one time --likely at the very first modem power up, since the setting is stored in non volatile memory.

Thank you

jamal-mouline commented 2 weeks ago

Hello @ZillKhan

Assuming the "antenna tuner control" enabling is performed through the 5 steps documented in my earlier note --pending your confirmation, I have couple additional questions:

1-Please confirm that AT+CFUN=0 and AT+CFUN=1 have already support APIs in place I was able to find: void uCellPrivateCFunMode(uCellPrivateInstance_t pInstance, int32_t mode); int32_t uCellPrivateCFunOne(uCellPrivateInstance_t pInstance); to support them respectively

However they both use an "instance pointer" instead of an AT handler

2-Would it make sense to make use of uCellPrivateInstance_t *pUCellPrivateGetInstance(uDeviceHandle_t cellHandle); to retrieve the "instance pointer" from the cell handler obtained from uDeviceOpen()

Thank you

ZillKhan commented 2 weeks ago

Hi @hkro Thank you for the feedback. We can certainly make direct use of the AT Client to configure the antenna tuner

To that end, I wanted to double check the correct sequence of commands to accomplish that Below is a copy paste from the AT Manual for the SARA-R5 / LEXI-R5 series On page 285, section 15.5.5, I found this example Could you please confirm these are the proper steps?

Enabling antenna tuner control AT+CFUN=0 OK Disable the protocol stack. AT+UTEST=1 OK Enter the test mode. AT+UTEST=4,1 OK The module enables the antenna dynamic tuner feature. AT+UTEST=0 OK Enter the normal mode. AT+CFUN=1 OK Restore full module functionality.

Also, according to the documentation for +UTEST=4, section 15.5 " The antenna dynamic tuner control setting is stored in the NVM, and its configuration is effective after exiting the test mode. " I wanted to confirm that this has to be done only one time --likely at the very first modem power up, since the setting is stored in non volatile memory.

Thank you

Hello @jamal-mouline Yes, these are the correct steps for enabling Antenna Tuner control as mentioned in the AT manual. The Antenna Tunning setting is stored in NVM, You only need to set the Antenna Tuning once, likely at the first power up of the modem.

ZillKhan commented 2 weeks ago

Hello @ZillKhan

Assuming the "antenna tuner control" enabling is performed through the 5 steps documented in my earlier note --pending your confirmation, I have couple additional questions:

1-Please confirm that AT+CFUN=0 and AT+CFUN=1 have already support APIs in place I was able to find: void uCellPrivateCFunMode(uCellPrivateInstance_t pInstance, int32_t mode); int32_t uCellPrivateCFunOne(uCellPrivateInstance_t pInstance); to support them respectively

However they both use an "instance pointer" instead of an AT handler

2-Would it make sense to make use of uCellPrivateInstance_t *pUCellPrivateGetInstance(uDeviceHandle_t cellHandle); to retrieve the "instance pointer" from the cell handler obtained from uDeviceOpen()

Thank you

@jamal-mouline

  1. Yes, ubxlib already support +CFUN=0,1 API and the mentioned APIs are correct.
  2. It make sense to use pUCellPrivateGetInstance to get instance pointer. You will also require AT client handler for this purpose for that you can use this API uCellAtClientHandleGet.

For reference we have a AT handler use case in fota_https application here: https://github.com/u-blox/cell_ucpu_app/blob/main/apps/fota_https/fota_https.c#L197

jamal-mouline commented 2 weeks ago

@ZillKhan OK, thank you for the confirmations and additional data points Will give it a try and let you know if any questions...

jamal-mouline commented 2 weeks ago

@ZillKhan I put together a tentative API to support this feature --see attached Would appreciate any review comments Thank you

AntennaTuner.c.txt

ZillKhan commented 1 week ago

@ZillKhan I put together a tentative API to support this feature --see attached Would appreciate any review comments Thank you

AntennaTuner.c.txt

Hello @jamal-mouline, I had a discussion with the ubxlib and uCPU teams. We cannot use pUCellPrivateGetInstance() directly, as this API is private to the ubxlib scope. This means we also can't use uCellPrivateCFunMode() and uCellPrivateCFunOne, as both rely on uCellPrivateInstance_t, which is only accessible within the ubxlib scope.

Considering this in mind, I have updated CellModemAntennaTunner() that includes +CFUN=0 and +CFUN=1 AT commands directly using AT handler.

I have tested this chunk in uCPU framework and its working as expected. Attaching the updated code. AntennaTunerUpdated.c.txt

Let me know if you require any further support is this regards.

Thanks.

jamal-mouline commented 1 week ago

@ZillKhan Your comments make sense to me as well --not making use of the "private" APIs. I will work with the updated framework, and test it against the hardware target when it becomes available No further questions at this time Thank you