From 210a55c1f7e633e795d22da4bc2bc4f6fa5b6c65 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Mon, 29 Mar 2021 14:35:09 +0800 Subject: [PATCH 1/3] Update cellular library to MIT license --- LICENSE | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/LICENSE b/LICENSE index 1bb4f21e..9cf10627 100644 --- a/LICENSE +++ b/LICENSE @@ -1,15 +1,19 @@ -Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +MIT License -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 42cb694a9460804729027ff2cc280b61a4767690 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Thu, 17 Mar 2022 15:16:21 +0800 Subject: [PATCH 2/3] Update HL7802 Cellular_GetSignalInfo * Add RSSI signal value and parsing function * Fix ber signal value --- modules/hl7802/cellular_hl7802_api.c | 51 ++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/modules/hl7802/cellular_hl7802_api.c b/modules/hl7802/cellular_hl7802_api.c index e467f6e6..550a2dff 100644 --- a/modules/hl7802/cellular_hl7802_api.c +++ b/modules/hl7802/cellular_hl7802_api.c @@ -162,6 +162,7 @@ static CellularPktStatus_t _Cellular_RecvFuncGetRatPriority( CellularContext_t * const CellularATCommandResponse_t * pAtResp, void * pData, uint16_t dataLen ); +static int16_t convertCesqSignalRxlev( int32_t rxlevValue ); static int16_t convertCesqSignalRsrq( int32_t rsrqValue ); static int16_t convertCesqSignalRsrp( int32_t rsrpValue ); static bool _parseSignalQuality( char * pQcsqPayload, @@ -998,6 +999,33 @@ static CellularPktStatus_t _Cellular_RecvFuncGetRatPriority( CellularContext_t * /*-----------------------------------------------------------*/ +/* Received signal strength level (see 3GPP TS 45.008 [20] subclause 8.1.4) + * 0 rssi < -110 dBm : assume -111 dBm to indicate the signal is detectable but fairly week. + * 1 -110 dBm <= rssi < -109 dBm + * 2 -109 dBm <= rssi < -108 dBm + * ... + * 61 -50 dBm <= rssi < -49 dBm + * 62 -49 dBm <= rssi < -48 dBm + * 63 -48 dBm <= rssi + * 99 not known or not detectable */ +static int16_t convertCesqSignalRxlev( int32_t rxlevValue ) +{ + int16_t rssidBm = 0; + + if( ( rxlevValue > 0 ) && ( rxlevValue <= 63 ) ) + { + rssidBm = ( int16_t ) ( ( -111 ) + ( rxlevValue ) ); + } + else + { + rssidBm = CELLULAR_INVALID_SIGNAL_VALUE; + } + + return rssidBm; +} + +/*-----------------------------------------------------------*/ + /* 0 rsrq < -19.5 dB * 1 -19.5 dB <= rsrq < -19 dB * 2 -19 dB <= rsrq < -18.5 dB @@ -1062,9 +1090,24 @@ static bool _parseSignalQuality( char * pQcsqPayload, /* The cesq payload format is ,,,,,. */ - /* Skip rxlev. */ + /* rxlev. */ atCoreStatus = Cellular_ATGetNextTok( &pTmpQcsqPayload, &pToken ); + if( atCoreStatus == CELLULAR_AT_SUCCESS ) + { + atCoreStatus = Cellular_ATStrtoi( pToken, 10, &tempValue ); + + if( atCoreStatus == CELLULAR_AT_SUCCESS ) + { + pSignalInfo->rssi = convertCesqSignalRxlev( tempValue ); + } + else + { + LogError( ( "_parseSignalQuality: Error in processing RXLEV. Token %s", pToken ) ); + parseStatus = false; + } + } + /* ber. */ if( atCoreStatus == CELLULAR_AT_SUCCESS ) { @@ -1077,7 +1120,9 @@ static bool _parseSignalQuality( char * pQcsqPayload, if( ( atCoreStatus == CELLULAR_AT_SUCCESS ) && ( tempValue <= INT16_MAX ) && ( tempValue >= INT16_MIN ) ) { - cellularStatus = _Cellular_ConvertCsqSignalRssi( ( int16_t ) tempValue, &berValue ); + /* As RXQUAL values in the table in 3GPP TS 45.008 [20] subclause 8.2.4. + * The CESQ ber signal value has the same scale with the AT+CSQ ber signal value. */ + cellularStatus = _Cellular_ConvertCsqSignalBer( ( int16_t ) tempValue, &berValue ); if( cellularStatus == CELLULAR_SUCCESS ) { @@ -1123,7 +1168,7 @@ static bool _parseSignalQuality( char * pQcsqPayload, } else { - LogError( ( "_parseSignalQuality: Error in processing RSRP. Token %s", pToken ) ); + LogError( ( "_parseSignalQuality: Error in processing RSRQ. Token %s", pToken ) ); parseStatus = false; } } From 887eedd20975b4f08533ded76e6bf541e71cbb49 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Fri, 18 Mar 2022 11:06:11 +0800 Subject: [PATCH 3/3] Fix rxlev value range --- modules/hl7802/cellular_hl7802_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hl7802/cellular_hl7802_api.c b/modules/hl7802/cellular_hl7802_api.c index 550a2dff..632b0319 100644 --- a/modules/hl7802/cellular_hl7802_api.c +++ b/modules/hl7802/cellular_hl7802_api.c @@ -1012,7 +1012,7 @@ static int16_t convertCesqSignalRxlev( int32_t rxlevValue ) { int16_t rssidBm = 0; - if( ( rxlevValue > 0 ) && ( rxlevValue <= 63 ) ) + if( ( rxlevValue >= 0 ) && ( rxlevValue <= 63 ) ) { rssidBm = ( int16_t ) ( ( -111 ) + ( rxlevValue ) ); }