Skip to content

Commit 4e85c3c

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 aae984c commit 4e85c3c

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
@@ -299,7 +299,7 @@ int main(void)
299299
char serial_number[MDM_SERIAL_NUMBER_LENGTH] = {0};
300300
enum hl78xx_cell_rat_mode tech;
301301
enum cellular_registration_status status;
302-
int16_t rsrp;
302+
int16_t signal_strength = 0;
303303
const char *newapn = "";
304304
const char *sample_cmd = "AT";
305305

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

0 commit comments

Comments
 (0)