Skip to content

Commit 3b7437d

Browse files
committed
samples: modem: hello_hl78xx: select RSSI or RSRP based on RAT mode
The sample previously always queried RSRP, which is not valid when the HL78xx operates in GSM mode. Use RSSI when GSM RAT is active and RSRP for other RATs. Update the log output and rename the variable for clarity. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
1 parent 38d7f00 commit 3b7437d

File tree

1 file changed

+11
-3
lines changed
  • samples/drivers/modem/hello_hl78xx/src

1 file changed

+11
-3
lines changed

samples/drivers/modem/hello_hl78xx/src/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ int main(void)
298298
char serial_number[MDM_SERIAL_NUMBER_LENGTH] = {0};
299299
enum hl78xx_cell_rat_mode tech;
300300
enum cellular_registration_status status;
301-
int16_t rsrp;
301+
int16_t signal_strength = 0;
302302
const char *newapn = "";
303303
const char *sample_cmd = "AT";
304304

@@ -335,7 +335,11 @@ int main(void)
335335
/* Get the current registration status */
336336
cellular_get_registration_status(modem, hl78xx_rat_to_access_tech(tech), &status);
337337
/* Get the current signal strength */
338-
cellular_get_signal(modem, CELLULAR_SIGNAL_RSRP, &rsrp);
338+
#ifdef CONFIG_MODEM_HL78XX_RAT_GSM
339+
cellular_get_signal(modem, CELLULAR_SIGNAL_RSSI, &signal_strength);
340+
#else
341+
cellular_get_signal(modem, CELLULAR_SIGNAL_RSRP, &signal_strength);
342+
#endif
339343
/* Get the current network operator name */
340344
hl78xx_get_modem_info(modem, HL78XX_MODEM_INFO_NETWORK_OPERATOR, (char *)operator,
341345
sizeof(operator));
@@ -350,7 +354,11 @@ int main(void)
350354
LOG_INF("Imei: %s", imei);
351355
LOG_INF("RAT: %s", rat_get_in_string(tech));
352356
LOG_INF("Connection status: %s(%d)", reg_status_get_in_string(status), status);
353-
LOG_INF("RSRP : %d", rsrp);
357+
#ifdef CONFIG_MODEM_HL78XX_RAT_GSM
358+
LOG_INF("RSSI : %d", signal_strength);
359+
#else
360+
LOG_INF("RSRP : %d", signal_strength);
361+
#endif
354362
LOG_INF("Operator: %s", (strlen(operator) > 0) ? operator : "\"\"");
355363
LOG_RAW("**********************************************************\n\n");
356364

0 commit comments

Comments
 (0)