[Bugfix][API-413][Factory-test]None AT command to read IMEI2
[BUgfix][API-490][Factory-test]The VCOM fails to be opened.
Change-Id: I2a0faaaae42fe866285bd9e7dcbdddc6cf1ae2fa
diff --git a/framework/lynq-ril-service/src/ril.cpp b/framework/lynq-ril-service/src/ril.cpp
index 915b399..057790b 100755
--- a/framework/lynq-ril-service/src/ril.cpp
+++ b/framework/lynq-ril-service/src/ril.cpp
@@ -174,6 +174,7 @@
/*For at extension to receive at buffer*/
char *at_buf_ext[MAX_AT_CMD];
int sockfd = 0;
+int imei_cnt = 0;
/*lei add*/
#if RILC_LOG
static char printBuf[PRINTBUF_SIZE];
@@ -3903,6 +3904,31 @@
return;
}
+/**
+ * @brief To handle comma-separated strings, take the character before the first comma eg:123456,78 ->123456
+ *
+ * @param buf Type:[IN]
+ */
+static void parse_imei(char buf[])
+{
+ if(NULL == buf)
+ {
+ return;
+ }
+ const char s[2] = ",";
+ char *token;
+ token = strtok(buf, s);
+ return;
+}
+
+static char * lynqStrdupReadString(Parcel &p) {
+ size_t stringlen;
+ const char16_t *s16;
+
+ s16 = p.readString16Inplace(&stringlen);
+ return strndup16to8(s16, stringlen);
+}
+
extern "C" void
RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
RequestInfo *pRI;
@@ -4165,7 +4191,64 @@
}
printf("n = %d\n",n);
}
+ break;
}
+ /*lei add for AT+CGSN 2022/8/4*/
+ case RIL_REQUEST_DEVICE_IDENTITY:
+ {
+ int resp_type;
+ int request;
+ int slot_id;
+ int error1;
+ int num;
+ char imei[32] = {0};
+ if(pRI->lynqEvent==1)
+ {
+ //printf("lei test %s\n" ,printBuf);
+ p.setDataPosition(0);
+ if(p.dataAvail() > 0)
+ {
+ p.readInt32(&resp_type);
+ p.readInt32(&request);
+ p.readInt32(&slot_id);
+ p.readInt32(&error1);
+ if(!error1)
+ {
+ p.readInt32(&num);
+ char * test = lynqStrdupReadString(p);
+ parse_imei(test);
+ if(imei_cnt % 2 == 0)
+ {
+ sprintf(imei,"%s%s%s", "+CGSN: ", test, "\n");
+ int n = write(ttyGS3_fd,imei,strlen(imei));
+ if(n<0)
+ {
+ perror("lynq resp write:");
+ }
+ }
+ else
+ {
+ sprintf(imei,"%s%s%s", "+CGSN: ", test, "\n");
+ int n = write(ttyGS3_fd,imei,strlen(imei));
+ if(n<0)
+ {
+ perror("lynq resp write:");
+ }
+ char eBuf[64] = {0};
+ sprintf(eBuf,"OK\n");
+ n = write(ttyGS3_fd,eBuf,strlen(eBuf));
+ if(n<0)
+ {
+ perror("lynq resp write:");
+ }
+ }
+ imei_cnt++;
+ }
+ }
+ }
+ break;
+ }
+ /*lei add for AT+CGSN 2022/8/4*/
default:
break;
}