Skip to content

Commit 7fc4ac3

Browse files
committed
backup override to have a option to set TLS on socket
to be removed when PR sparkfun/SparkFun_u-blox_SARA-R5_Arduino_Library#43 is merged and released
1 parent c3b8552 commit 7fc4ac3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

software/LTE.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,19 @@ class LTE : public SARA_R5 {
442442
int32_t ntripGgaMs; //!< time tag (millis()) of next GGA to be sent
443443
int ntripSocket; //!< the socket handle
444444

445+
#if 1
446+
// override until this API is natively avialable in Sparkfun SARA-R5 library
447+
// https://github.com/sparkfun/SparkFun_u-blox_SARA-R5_Arduino_Library/pull/43
448+
SARA_R5_error_t socketSetSecure(int profile, bool secure, int secprofile = -1)
449+
{
450+
char command[64];
451+
sprintf(command, ((secprofile == -1) || !secure) ? "%s=%d,%d" : "%s=%d,%d,%d",
452+
SARA_R5_SECURE_SOCKET, profile, secure, secprofile);
453+
return sendCommandWithResponse(command, SARA_R5_RESPONSE_OK_OR_ERROR, nullptr,
454+
SARA_R5_STANDARD_RESPONSE_TIMEOUT);
455+
}
456+
#endif
457+
445458
/** Connect to a NTRIP server
446459
* \param ntrip the server:port/mountpoint to connect to
447460
* \return connection success
@@ -473,15 +486,13 @@ class LTE : public SARA_R5 {
473486
"User-Agent: " CONFIG_DEVICE_TITLE "\r\n"
474487
"%s\r\n", mntpnt.c_str(), authHead.c_str());
475488
LTE_CHECK_INIT;
476-
#if 0 // requires latest Sparkfun SARA-R5 socketSetSecure API
477489
LTE_CHECK(1) = LTE_IGNORE_LENA( resetSecurityProfile(LTE_SEC_PROFILE_NTRIP) );
478490
LTE_CHECK(2) = configSecurityProfile(LTE_SEC_PROFILE_NTRIP, SARA_R5_SEC_PROFILE_PARAM_CERT_VAL_LEVEL, SARA_R5_SEC_PROFILE_CERTVAL_OPCODE_NO); // no certificate and url/sni check
479491
LTE_CHECK(3) = configSecurityProfile(LTE_SEC_PROFILE_NTRIP, SARA_R5_SEC_PROFILE_PARAM_TLS_VER, SARA_R5_SEC_PROFILE_TLS_OPCODE_ANYVER);
480492
LTE_CHECK(4) = configSecurityProfile(LTE_SEC_PROFILE_NTRIP, SARA_R5_SEC_PROFILE_PARAM_CYPHER_SUITE, SARA_R5_SEC_PROFILE_SUITE_OPCODE_PROPOSEDDEFAULT);
481493
LTE_CHECK(5) = configSecurityProfileString(LTE_SEC_PROFILE_NTRIP, SARA_R5_SEC_PROFILE_PARAM_SNI, server.c_str());
482494
bool isSecure = server.equalsIgnoreCase("ppntrip.services.u-blox.com") && (2102 == port); // we try to autodetect the secure thingstream server
483495
LTE_CHECK(6) = socketSetSecure(ntripSocket, isSecure, LTE_SEC_PROFILE_NTRIP);
484-
#endif
485496
LTE_CHECK(7) = socketConnect(ntripSocket, server.c_str(), port);
486497
LTE_CHECK(8) = socketWrite(ntripSocket, buf, len);
487498
int avail = 0;

0 commit comments

Comments
 (0)