@@ -514,6 +514,7 @@ struct hl7800_iface_ctx {
514514 bool mdm_startup_reporting_on ;
515515 int device_services_ind ;
516516 bool new_rat_cmd_support ;
517+ uint8_t operator_index ;
517518
518519 /* modem state */
519520 bool allow_sleep ;
@@ -1051,6 +1052,24 @@ int32_t mdm_hl7800_get_local_time(struct tm *tm, int32_t *offset)
10511052}
10521053#endif
10531054
1055+ int32_t mdm_hl7800_get_operator_index (void )
1056+ {
1057+ int ret ;
1058+
1059+ hl7800_lock ();
1060+ wakeup_hl7800 ();
1061+ ictx .last_socket_id = 0 ;
1062+ ret = send_at_cmd (NULL , "AT+KCARRIERCFG?" , MDM_CMD_SEND_TIMEOUT , 0 ,
1063+ false);
1064+ allow_sleep (true);
1065+ hl7800_unlock ();
1066+ if (ret < 0 ) {
1067+ return ret ;
1068+ } else {
1069+ return ictx .operator_index ;
1070+ }
1071+ }
1072+
10541073void mdm_hl7800_generate_status_events (void )
10551074{
10561075 hl7800_lock ();
@@ -2371,6 +2390,32 @@ static bool on_cmd_network_report_query(struct net_buf **buf, uint16_t len)
23712390 return true;
23722391}
23732392
2393+ static bool on_cmd_operator_index_query (struct net_buf * * buf , uint16_t len )
2394+ {
2395+ struct net_buf * frag = NULL ;
2396+ char carrier [MDM_HL7800_OPERATOR_INDEX_SIZE ];
2397+ size_t out_len ;
2398+
2399+ wait_for_modem_data_and_newline (buf , net_buf_frags_len (* buf ),
2400+ MDM_HL7800_OPERATOR_INDEX_SIZE );
2401+
2402+ frag = NULL ;
2403+ len = net_buf_findcrlf (* buf , & frag );
2404+ if (!frag ) {
2405+ LOG_ERR ("Unable to find end of operator index response" );
2406+ goto done ;
2407+ }
2408+
2409+ out_len = net_buf_linearize (carrier , MDM_HL7800_OPERATOR_INDEX_STRLEN ,
2410+ * buf , 0 , len );
2411+ carrier [out_len ] = 0 ;
2412+ ictx .operator_index = (uint8_t )strtol (carrier , NULL , 10 );
2413+
2414+ LOG_INF ("Operator Index: %u" , ictx .operator_index );
2415+ done :
2416+ return true;
2417+ }
2418+
23742419#ifdef CONFIG_NEWLIB_LIBC
23752420/* Handler: +CCLK: "yy/MM/dd,hh:mm:ss±zz" */
23762421static bool on_cmd_rtc_query (struct net_buf * * buf , uint16_t len )
@@ -3335,6 +3380,7 @@ static void hl7800_rx(void)
33353380 CMD_HANDLER ("+WPPP: 1,1," , atcmdinfo_pdp_authentication_cfg ),
33363381 CMD_HANDLER ("+CGDCONT: 1" , atcmdinfo_pdp_context ),
33373382 CMD_HANDLER ("AT+CEREG?" , network_report_query ),
3383+ CMD_HANDLER ("+KCARRIERCFG: " , operator_index_query ),
33383384#ifdef CONFIG_NEWLIB_LIBC
33393385 CMD_HANDLER ("+CCLK: " , rtc_query ),
33403386#endif
0 commit comments