diff --git a/application/quectel_CM_5G_M/src/QCQMI.h b/application/quectel_CM_5G_M/src/QCQMI.h index e9cab6b..63ca3cc 100644 --- a/application/quectel_CM_5G_M/src/QCQMI.h +++ b/application/quectel_CM_5G_M/src/QCQMI.h @@ -314,6 +314,11 @@ typedef struct _QMI_TLV #define QMUX_CTL_FLAG_TYPE_IND 0x04 #define QMUX_CTL_FLAG_MASK_COMPOUND 0x01 #define QMUX_CTL_FLAG_MASK_TYPE 0x06 // 00-cmd, 01-rsp, 10-ind +// Add these definitions to the DMS message types section +#define QMIDMS_FOXCONN_SET_FCC_AUTH_REQ 0x555C +#define QMIDMS_FOXCONN_SET_FCC_AUTH_RESP 0x555C +#define QMIDMS_FOXCONN_SET_FCC_AUTH_V2_REQ 0x555D +#define QMIDMS_FOXCONN_SET_FCC_AUTH_V2_RESP 0x555D #pragma pack(pop) diff --git a/application/quectel_CM_5G_M/src/QCQMUX.h b/application/quectel_CM_5G_M/src/QCQMUX.h index eb42dd8..640f59a 100644 --- a/application/quectel_CM_5G_M/src/QCQMUX.h +++ b/application/quectel_CM_5G_M/src/QCQMUX.h @@ -399,25 +399,25 @@ typedef struct _QCTLV_PKT_STATISTICS //#ifdef QC_IP_MODE /* - �Bit 0 �Profile identifier - �Bit 1 �Profile name - �Bit 2 �PDP type - �Bit 3 �APN name - �Bit 4 �DNS address - �Bit 5 �UMTS/GPRS granted QoS - �Bit 6 �Username - �Bit 7 �Authentication Protocol - �Bit 8 �IP address - �Bit 9 �Gateway information (address and subnet mask) - �Bit 10 �PCSCF address using a PCO flag - �Bit 11 �PCSCF server address list - �Bit 12 �PCSCF domain name list - �Bit 13 �MTU - �Bit 14 �Domain name list - �Bit 15 �IP family - �Bit 16 �IM_CM flag - �Bit 17 �Technology name - �Bit 18 �Operator reserved PCO + �?Bit 0 �?Profile identifier + �?Bit 1 �?Profile name + �?Bit 2 �?PDP type + �?Bit 3 �?APN name + �?Bit 4 �?DNS address + �?Bit 5 �?UMTS/GPRS granted QoS + �?Bit 6 �?Username + �?Bit 7 �?Authentication Protocol + �?Bit 8 �?IP address + �?Bit 9 �?Gateway information (address and subnet mask) + �?Bit 10 �?PCSCF address using a PCO flag + �?Bit 11 �?PCSCF server address list + �?Bit 12 �?PCSCF domain name list + �?Bit 13 �?MTU + �?Bit 14 �?Domain name list + �?Bit 15 �?IP family + �?Bit 16 �?IM_CM flag + �?Bit 17 �?Technology name + �?Bit 18 �?Operator reserved PCO */ #define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4DNS_ADDR (1 << 4) #define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4_ADDR (1 << 8) @@ -4067,6 +4067,25 @@ typedef struct _QMIUIM_SET_CARD_SLOT_REQ_MSG #define QMI_COEX_GET_WWAN_STATE_REQ 0x22 #define QMI_COEX_GET_WWAN_STATE_RESP 0x22 +// Add these structure definitions after existing message structures + +#ifdef CONFIG_FOXCONN_FCC_AUTH +typedef struct _QMIDMS_FOXCONN_SET_FCC_AUTH_REQ_MSG +{ + USHORT Type; + USHORT Length; + UCHAR TLVType; + USHORT TLVLength; + UCHAR magic_value; +} __attribute__ ((packed)) QMIDMS_FOXCONN_SET_FCC_AUTH_REQ_MSG, *PQMIDMS_FOXCONN_SET_FCC_AUTH_REQ_MSG; + +typedef struct _QMIDMS_FOXCONN_SET_FCC_AUTH_V2_REQ_MSG +{ + USHORT Type; + USHORT Length; +} __attribute__ ((packed)) QMIDMS_FOXCONN_SET_FCC_AUTH_V2_REQ_MSG, *PQMIDMS_FOXCONN_SET_FCC_AUTH_V2_REQ_MSG; +#endif + typedef struct { uint32_t freq; @@ -4293,6 +4312,10 @@ typedef struct _QMUX_MSG QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG SetDataFormatReq; QMI_WDA_SET_LOOPBACK_CONFIG_REQ_MSG SetLoopBackReq; QMI_WDA_SET_LOOPBACK_CONFIG_IND_MSG SetLoopBackInd; +#ifdef CONFIG_FOXCONN_FCC_AUTH + QMIDMS_FOXCONN_SET_FCC_AUTH_REQ_MSG FoxconnSetFccAuthReq; + QMIDMS_FOXCONN_SET_FCC_AUTH_V2_REQ_MSG FoxconnSetFccAuthV2Req; +#endif }; } __attribute__ ((packed)) QMUX_MSG, *PQMUX_MSG; diff --git a/application/quectel_CM_5G_M/src/QMIThread.c b/application/quectel_CM_5G_M/src/QMIThread.c index 8f7e866..ca49704 100644 --- a/application/quectel_CM_5G_M/src/QMIThread.c +++ b/application/quectel_CM_5G_M/src/QMIThread.c @@ -1832,6 +1832,88 @@ static int requestQueryDataCall(UCHAR *pConnectionStatus, int curIpFamily) { return 0; } +// Add these implementations after existing function implementations + +#ifdef CONFIG_FOXCONN_FCC_AUTH +// Make sure these functions are static to avoid symbol conflicts +static USHORT DmsFoxconnSetFccAuthenticationReq(PQMUX_MSG pMUXMsg, void *arg) { + UCHAR magic_value = *((UCHAR *)arg); + + pMUXMsg->FoxconnSetFccAuthReq.TLVType = 0x01; + pMUXMsg->FoxconnSetFccAuthReq.TLVLength = cpu_to_le16(1); + pMUXMsg->FoxconnSetFccAuthReq.magic_value = magic_value; + + return sizeof(QMIDMS_FOXCONN_SET_FCC_AUTH_REQ_MSG); +} + +static USHORT DmsFoxconnSetFccAuthenticationV2Req(PQMUX_MSG pMUXMsg, void *arg) { + FOXCONN_FCC_AUTH_V2_T *fcc_auth = (FOXCONN_FCC_AUTH_V2_T *)arg; + USHORT TLVLength = 0; + UCHAR *pTLV; + + pTLV = (UCHAR *)(&pMUXMsg->FoxconnSetFccAuthV2Req + 1); + + // Magic string TLV (0x01) + *pTLV++ = 0x01; // TLV Type + *(USHORT *)pTLV = cpu_to_le16(strlen(fcc_auth->magic_string)); + pTLV += 2; + memcpy(pTLV, fcc_auth->magic_string, strlen(fcc_auth->magic_string)); + pTLV += strlen(fcc_auth->magic_string); + TLVLength += 3 + strlen(fcc_auth->magic_string); + + // Magic number TLV (0x02) + *pTLV++ = 0x02; // TLV Type + *(USHORT *)pTLV = cpu_to_le16(1); + pTLV += 2; + *pTLV++ = fcc_auth->magic_number; + TLVLength += 4; + + return sizeof(QMIDMS_FOXCONN_SET_FCC_AUTH_V2_REQ_MSG) + TLVLength; +} + +// These functions should NOT be static since they're used externally +int requestFoxconnSetFccAuthentication(UCHAR magic_value) { + PQCQMIMSG pRequest; + PQCQMIMSG pResponse; + PQMUX_MSG pMUXMsg; + int err; + + dbg_time("%s(magic_value=0x%02x)", __func__, magic_value); + + pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_FOXCONN_SET_FCC_AUTH_REQ, DmsFoxconnSetFccAuthenticationReq, &magic_value); + err = QmiThreadSendQMI(pRequest, &pResponse); + qmi_rsp_check_and_return(); + + free(pResponse); + return 0; +} + +int requestFoxconnSetFccAuthenticationV2(const char *magic_string, UCHAR magic_number) { + PQCQMIMSG pRequest; + PQCQMIMSG pResponse; + PQMUX_MSG pMUXMsg; + int err; + FOXCONN_FCC_AUTH_V2_T fcc_auth; + + dbg_time("%s(magic_string='%s', magic_number=0x%02x)", __func__, magic_string, magic_number); + + if (!magic_string || strlen(magic_string) >= sizeof(fcc_auth.magic_string)) { + dbg_time("%s: Invalid magic_string", __func__); + return -1; + } + + strcpy(fcc_auth.magic_string, magic_string); + fcc_auth.magic_number = magic_number; + + pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_FOXCONN_SET_FCC_AUTH_V2_REQ, DmsFoxconnSetFccAuthenticationV2Req, &fcc_auth); + err = QmiThreadSendQMI(pRequest, &pResponse); + qmi_rsp_check_and_return(); + + free(pResponse); + return 0; +} +#endif + static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) { PQCQMIMSG pRequest; PQCQMIMSG pResponse; @@ -2555,6 +2637,10 @@ const struct request_ops qmi_request_ops = { #ifdef CONFIG_COEX_WWAN_STATE .requestGetCoexWWANState = requestGetCoexWWANState, #endif +#ifdef CONFIG_FOXCONN_FCC_AUTH + .requestFoxconnSetFccAuthentication = requestFoxconnSetFccAuthentication, + .requestFoxconnSetFccAuthenticationV2 = requestFoxconnSetFccAuthenticationV2, +#endif }; #ifdef CONFIG_CELLINFO diff --git a/application/quectel_CM_5G_M/src/QMIThread.h b/application/quectel_CM_5G_M/src/QMIThread.h index b088e42..546b958 100644 --- a/application/quectel_CM_5G_M/src/QMIThread.h +++ b/application/quectel_CM_5G_M/src/QMIThread.h @@ -20,6 +20,7 @@ //#define CONFIG_REG_QOS_IND //#define CONFIG_GET_QOS_INFO //#define CONFIG_GET_QOS_DATA_RATE +#define CONFIG_FOXCONN_FCC_AUTH #if (defined(CONFIG_REG_QOS_IND) || defined(CONFIG_GET_QOS_INFO) || defined(CONFIG_GET_QOS_DATA_RATE)) #ifndef CONFIG_REG_QOS_IND @@ -344,7 +345,20 @@ struct request_ops { int (*requestRegisterQos)(PROFILE_T *profile); int (*requestGetQosInfo)(PROFILE_T *profile); int (*requestGetCoexWWANState)(void); +#ifdef CONFIG_FOXCONN_FCC_AUTH + int (*requestFoxconnSetFccAuthentication)(UCHAR magic_value); + int (*requestFoxconnSetFccAuthenticationV2)(const char *magic_string, UCHAR magic_number); +#endif }; + +// Add structure for V2 parameters +#ifdef CONFIG_FOXCONN_FCC_AUTH +typedef struct { + char magic_string[256]; + UCHAR magic_number; +} FOXCONN_FCC_AUTH_V2_T; +#endif + extern const struct request_ops qmi_request_ops; extern const struct request_ops mbim_request_ops; extern const struct request_ops atc_request_ops;