@@ -1220,6 +1220,22 @@ int32_t mdm_hl7800_polte_locate(void)
12201220
12211221#endif /* CONFIG_MODEM_HL7800_POLTE */
12221222
1223+ /**
1224+ * @brief Perform a site survey.
1225+ *
1226+ */
1227+ int32_t mdm_hl7800_perform_site_survey (void )
1228+ {
1229+ int ret ;
1230+
1231+ hl7800_lock ();
1232+ wakeup_hl7800 ();
1233+ ret = send_at_cmd (NULL , "at%meas=\"97\"" , MDM_CMD_SEND_TIMEOUT , 0 , false);
1234+ allow_sleep (true);
1235+ hl7800_unlock ();
1236+ return ret ;
1237+ }
1238+
12231239void mdm_hl7800_generate_status_events (void )
12241240{
12251241 hl7800_lock ();
@@ -3045,6 +3061,74 @@ static bool on_cmd_modem_functionality(struct net_buf **buf, uint16_t len)
30453061 return true;
30463062}
30473063
3064+ /* There can be multiple responses from a single command.
3065+ * %MEAS: EARFCN=5826, CellID=420, RSRP=-99, RSRQ=-15
3066+ * %MEAS: EARFCN=6400, CellID=201, RSRP=-93, RSRQ=-21
3067+ */
3068+ static bool on_cmd_survey_status (struct net_buf * * buf , uint16_t len )
3069+ {
3070+ struct net_buf * frag = NULL ;
3071+ char response [sizeof ("EARFCN=XXXXXXXXXXX, CellID=XXXXXXXXXXX, RSRP=-XXX, RSRQ=-XXX" )];
3072+ char * key ;
3073+ size_t out_len ;
3074+ char * value ;
3075+ struct mdm_hl7800_site_survey site_survey ;
3076+
3077+ wait_for_modem_data_and_newline (buf , net_buf_frags_len (* buf ),
3078+ sizeof (response ));
3079+
3080+ frag = NULL ;
3081+ len = net_buf_findcrlf (* buf , & frag );
3082+ if (!frag ) {
3083+ LOG_ERR ("Unable to find end" );
3084+ goto done ;
3085+ }
3086+
3087+ out_len = net_buf_linearize (response , sizeof (response ), * buf , 0 , len );
3088+ LOG_HEXDUMP_DBG (response , out_len , "Site Survey" );
3089+
3090+ key = "EARFCN=" ;
3091+ value = strstr (response , key );
3092+ if (value == NULL ) {
3093+ goto done ;
3094+ } else {
3095+ value += strlen (key );
3096+ site_survey .earfcn = strtoul (value , NULL , 10 );
3097+ }
3098+
3099+ key = "CellID=" ;
3100+ value = strstr (response , key );
3101+ if (value == NULL ) {
3102+ goto done ;
3103+ } else {
3104+ value += strlen (key );
3105+ site_survey .cell_id = strtoul (value , NULL , 10 );
3106+ }
3107+
3108+ key = "RSRP=" ;
3109+ value = strstr (response , key );
3110+ if (value == NULL ) {
3111+ goto done ;
3112+ } else {
3113+ value += strlen (key );
3114+ site_survey .rsrp = strtol (value , NULL , 10 );
3115+ }
3116+
3117+ key = "RSRQ=" ;
3118+ value = strstr (response , key );
3119+ if (value == NULL ) {
3120+ goto done ;
3121+ } else {
3122+ value += strlen (key );
3123+ site_survey .rsrq = strtol (value , NULL , 10 );
3124+ }
3125+
3126+ event_handler (HL7800_EVENT_SITE_SURVEY , & site_survey );
3127+
3128+ done :
3129+ return true;
3130+ }
3131+
30483132#ifdef CONFIG_NEWLIB_LIBC
30493133/* Handler: +CCLK: "yy/MM/dd,hh:mm:ss±zz" */
30503134static bool on_cmd_rtc_query (struct net_buf * * buf , uint16_t len )
@@ -4012,6 +4096,7 @@ static void hl7800_rx(void)
40124096 CMD_HANDLER ("+KCARRIERCFG: " , operator_index_query ),
40134097 CMD_HANDLER ("AT+CIMI" , atcmdinfo_imsi ),
40144098 CMD_HANDLER ("+CFUN: " , modem_functionality ),
4099+ CMD_HANDLER ("%MEAS: " , survey_status ),
40154100#ifdef CONFIG_NEWLIB_LIBC
40164101 CMD_HANDLER ("+CCLK: " , rtc_query ),
40174102#endif
0 commit comments