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
287 stars 82 forks source link

Automatic authentication failure for U260, U270, U280, among others #185

Closed GioTB closed 5 months ago

GioTB commented 5 months ago

I was implementing the library with a SARA-U260-00S-02 and when trying to connect to the network it didn´t worked, diging a bit more realise that the library attempts to set the authentication type to "automatic" but this is not supported by some modules (according to the AT manual https://content.u-blox.com/sites/default/files/u-blox-CEL_ATCommands_UBX-13002752.pdf, page 403 says: "SARA-U260-00S / SARA-U270-00S / SARA-U270-00X / SARA-U280-00S / LISA-U200-00S / LISA-U200-01S / LISA-U200-02S / LISA-U200-52S / LISA-U200-62S / LISA-U230 / LISA-U260 / LISA-U270 • If =6, =3 (automatic selection of authentication type) is not supported.")

So would it be posible to add these modules type? the only SARA-U in the "uCellModuleType_t" is the SARA_U201, so it would be nice to have the others one too that doesn´t support this automatic authentication. Another idea would be to force that segment of the code (on the activateContextUpsd function), that set the param 6 value of the UPSD command would be taken from the authenticationMode parameter of the uNetworkCfgCell_t struct, this way the user has the option to use that parameter for that configuration, independantly the module type.

RobMeades commented 5 months ago

Hi there, and thanks for posting. Which version of ubxlib is this with? Asking 'cos we changed the way it worked in commit https://github.com/u-blox/ubxlib/commit/f7d9d84804abdf207db20993adf42927a8420314. Don't know whether that makes things better or worse of course.

EDIT: interesting idea, passing authenticationMode from uNetworkCfgCell_t through to activateContextUpsd(). Lemme have a thing about whether there's a down-side to that. Slippery things these module versions :-).

GioTB commented 5 months ago

í´m using the master branch, it´s on the cell/src/u_cell_net.c file, on segment that start on line 1687 if (errorCode == 0) { // Automatic authentication protocol selection uAtClientLock(atHandle); uAtClientCommandStart(atHandle, "AT+UPSD="); uAtClientWriteInt(atHandle, profileId); uAtClientWriteInt(atHandle, 6); uAtClientWriteInt(atHandle, 3); uAtClientCommandStopReadResponse(atHandle); errorCode = uAtClientUnlock(atHandle); }

RobMeades commented 5 months ago

Understood, yes, it's hard coded for SARA-U201 but you are right that it needn't be. Will give it a try.

RobMeades commented 5 months ago

A quick look suggests that changing this line:

https://github.com/u-blox/ubxlib/blob/41349f324ed52de37ade97f8de638b4ab1549f9a/cell/src/u_cell_net.c#L1693

...to be:

        uAtClientWriteInt(atHandle, pInstance->authenticationMode);

...would be sufficient to meet your needs, i.e. it will then use the authenticationMode from uNetworkCfgCell_t. Can you try this and let me know if it works for you? If it does I can make the change.

GioTB commented 5 months ago

yes!, that actually works, i tryed first hardcoding it to "0" but then i changed it exactly like you leave it and works right away.

RobMeades commented 5 months ago

Great, will work up a change and let you know when it has landed back here.

RobMeades commented 5 months ago

Fixed in commit f95208fc55abaa3448b510ba3342802099aab38e.