blob: 569856acbd42d5363ea9cfc1decd8bd72e7e6e85 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**
2 *
3 * @file ext_amt_func.c
4 * @brief
5 * This file is part of FTM.
6 * AMTÄ£¿éÏà¹ØATÃüÁî
7 *
8 * @details
9 * @author Tools Team.
10 * @email
11 * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
12 * @warning
13 * @date 2019/02/02
14 * @version 1.1
15 * @pre
16 * @post
17 *
18 * @par
19 * Change History :
20 * ---------------------------------------------------------------------------
21 * date version author description
22 * ---------------------------------------------------------------------------
23 * 2018/04/28 1.0 liu.xin Create file
24 * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
25 * ---------------------------------------------------------------------------
26 *
27 *
28 */
29
30#include "ext_regist.h"
31#include "at_com.h"
32#include <unistd.h>
33#include <sys/syscall.h>
34#include "RONvParam_AMT.h"
35#include "ref_nv_def.h"
36#include "nv_api.h"
37#include "amtnv.h"
38#include <linux/soc/zte/efuse/efuse_zx.h>
xf.liaa4d92f2023-09-13 00:18:58 -070039#include <linux/soc/zte/otp/otp_zx.h>
lh9ed821d2023-04-07 01:36:19 -070040#include "NvParam_drv.h"
41#include "libkey.h"
42
43//mdlÓû§Ä£Ê½ÇÐÑз¢Ä£Ê½¼øÈ¨½á¹û
44static int auth_device_key_result = 0;
45
46#define GET_LCD_INFO 378
47#define GET_WIFI_INFO 379
48#define GET_FLASH_INFO 380
49#define GET_CPU_INFO 381
50#define GET_DDR_INFO 382
51//CP
52typedef unsigned char BYTE;
53
54#define DC_MacLen (BYTE)12
55#define DC_ImeiLen (BYTE)8
56#define MSN_MAX_NVINFO_LEN 20
57#define MSINFO_MAX_NVINFO_LEN 200
58#define MDMVERSION_MAX_LEN 64
59#define bInside(data, up, down) (((data) <= (up) && (data) >= (down)) || \
60 ((data) >= (up) && (data) <= (down)))
61typedef unsigned long u32_t;
62
63#ifndef SMEMCPY
64#define SMEMCPY(dst,src,len) memcpy(dst,src,len)
65#endif
66
67/**
68 * @brief ZMDMVERSIONÏìÓ¦ÏûÏ¢½á¹¹Ìå
69 * @param result ½á¹ûÂë AT_RSP_OK/AT_RSP_ERR
70 * @param mdmVer modem°æ±¾ºÅ
71 */
72typedef struct
73{
74 char mdmVer[MDMVERSION_MAX_LEN];
75 int result;
76}AT_MDMVERSION_RSP_INFO;
77
78//static char mdmVer[MDMVERSION_MAX_LEN] = {0};//ÓÃÓڼǼZGMR »Ø¸´½á¹û
79
80struct flash_ddr_info{
81 char manu[32];
82 char model[32];
83 char size[32];
84 char other[32];
85};
86
87struct lcd_info
88{
89 char manu[32];
90 char ic[32];
91 char resolution[32];
92};
93
94struct wifi_info
95{
96 char manu[32];
97 char ic[32];
98};
99struct cpu_info{
100 char manu[32];
101 char model[32];
102};
103
104/* Data structure for MD5 (Message-Digest) computation */
105typedef struct {
106 u32_t i[2]; /* number of _bits_ handled mod 2^64 */
107 u32_t buf[4]; /* scratch buffer */
108 unsigned char in[64]; /* input buffer */
109 unsigned char digest[16]; /* actual digest after md5_final call */
110} md5_ctx;
111
112
113extern void at_context_chn_info_mod(char *at_paras);
114
115/*
116 ***********************************************************************
117 ** Message-digest routines: **
118 ** To form the message digest for a message M **
119 ** (1) Initialize a context buffer ctx using md5_init **
120 ** (2) Call md5_update on ctx and M **
121 ** (3) Call md5_final on ctx **
122 ** The message digest is now in ctx->digest[0...15] **
123 ***********************************************************************
124 */
125
126/* forward declaration */
127static void transform(u32_t *buf, u32_t *in);
128
129static unsigned char PADDING[64] = {
130 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
138};
139
140/* F, G, H and I are basic MD5 functions */
141#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
142#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
143#define H(x, y, z) ((x) ^ (y) ^ (z))
144#define I(x, y, z) ((y) ^ ((x) | (~z)))
145
146/* ROTATE_LEFT rotates x left n bits */
147#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
148
149/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
150/* Rotation is separate from addition to prevent recomputation */
151#define FF(a, b, c, d, x, s, ac) \
152 {(a) += F ((b), (c), (d)) + (x) + (u32_t)(ac); \
153 (a) = ROTATE_LEFT ((a), (s)); \
154 (a) += (b); \
155 }
156#define GG(a, b, c, d, x, s, ac) \
157 {(a) += G ((b), (c), (d)) + (x) + (u32_t)(ac); \
158 (a) = ROTATE_LEFT ((a), (s)); \
159 (a) += (b); \
160 }
161#define HH(a, b, c, d, x, s, ac) \
162 {(a) += H ((b), (c), (d)) + (x) + (u32_t)(ac); \
163 (a) = ROTATE_LEFT ((a), (s)); \
164 (a) += (b); \
165 }
166#define II(a, b, c, d, x, s, ac) \
167 {(a) += I ((b), (c), (d)) + (x) + (u32_t)(ac); \
168 (a) = ROTATE_LEFT ((a), (s)); \
169 (a) += (b); \
170 }
171
172#ifdef __STDC__
173#define UL(x) x##UL
174#else
175#ifdef WIN32
176#define UL(x) x##UL
177#else
178#define UL(x) x
179#endif
180#endif
181
182/* The routine md5_init initializes the message-digest context
183 mdContext. All fields are set to zero.
184 */
185void md5_init(md5_ctx *ctx)
186{
187 ctx->i[0] = ctx->i[1] = (u32_t)0;
188
189 /* Load magic initialization constants. */
190 ctx->buf[0] = (u32_t)0x67452301UL;
191 ctx->buf[1] = (u32_t)0xefcdab89UL;
192 ctx->buf[2] = (u32_t)0x98badcfeUL;
193 ctx->buf[3] = (u32_t)0x10325476UL;
194}
195
196/* The routine md5_update updates the message-digest context to
197 account for the presence of each of the characters buf[0..inLen-1]
198 in the message whose digest is being computed.
199 */
200
201void md5_update(md5_ctx *ctx, unsigned char *buf, unsigned int len)
202{
203 u32_t in[16];
204 int mdi;
205 unsigned int i, ii;
206
207#if 0
208 ppp_trace(LOG_INFO, "MD5Update: %u:%.*H\n", len, MIN(len, 20) * 2, buf);
209 ppp_trace(LOG_INFO, "MD5Update: %u:%s\n", len, buf);
210#endif
211
212 /* compute number of bytes mod 64 */
213 mdi = (int)((ctx->i[0] >> 3) & 0x3F);
214
215 /* update number of bits */
216 if ((ctx->i[0] + ((u32_t)len << 3)) < ctx->i[0]) {
217 ctx->i[1]++;
218 }
219 ctx->i[0] += ((u32_t)len << 3);
220 ctx->i[1] += ((u32_t)len >> 29);
221
222 while (len--) {
223 /* add new character to buffer, increment mdi */
224 ctx->in[mdi++] = *buf++;
225
226 /* transform if necessary */
227 if (mdi == 0x40) {
228 for (i = 0, ii = 0; i < 16; i++, ii += 4) {
229 in[i] = (((u32_t)ctx->in[ii+3]) << 24) |
230 (((u32_t)ctx->in[ii+2]) << 16) |
231 (((u32_t)ctx->in[ii+1]) << 8) |
232 ((u32_t)ctx->in[ii]);
233 }
234 transform (ctx->buf, in);
235 mdi = 0;
236 }
237 }
238}
239
240/* The routine md5_final terminates the message-digest computation and
241 ends with the desired message digest in ctx->digest[0...15].
242 */
243
244void md5_final(unsigned char hash[], md5_ctx *ctx)
245{
246 u32_t in[16];
247 int mdi;
248 unsigned int i, ii;
249 unsigned int pad_len;
250
251 /* save number of bits */
252 in[14] = ctx->i[0];
253 in[15] = ctx->i[1];
254
255 /* compute number of bytes mod 64 */
256 mdi = (int)((ctx->i[0] >> 3) & 0x3F);
257
258 /* pad out to 56 mod 64 */
259 pad_len = (mdi < 56) ? (56 - mdi) : (120 - mdi);
260 md5_update (ctx, PADDING, pad_len);
261
262 /* append length in bits and transform */
263 for (i = 0, ii = 0; i < 14; i++, ii += 4) {
264 in[i] = (((u32_t)ctx->in[ii+3]) << 24) |
265 (((u32_t)ctx->in[ii+2]) << 16) |
266 (((u32_t)ctx->in[ii+1]) << 8) |
267 ((u32_t)ctx->in[ii]);
268 }
269 transform (ctx->buf, in);
270
271 /* store buffer in digest */
272 for (i = 0, ii = 0; i < 4; i++, ii += 4) {
273 ctx->digest[ii] = (unsigned char)(ctx->buf[i] & 0xFF);
274 ctx->digest[ii+1] =
275 (unsigned char)((ctx->buf[i] >> 8) & 0xFF);
276 ctx->digest[ii+2] =
277 (unsigned char)((ctx->buf[i] >> 16) & 0xFF);
278 ctx->digest[ii+3] =
279 (unsigned char)((ctx->buf[i] >> 24) & 0xFF);
280 }
281 SMEMCPY(hash, ctx->digest, 16);
282}
283
284/* Basic MD5 step. Transforms buf based on in.
285 */
286static void transform (u32_t *buf, u32_t *in)
287{
288 u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3];
289
290 /* Round 1 */
291 #define S11 7
292 #define S12 12
293 #define S13 17
294 #define S14 22
295 FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */
296 FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */
297 FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */
298 FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */
299 FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */
300 FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */
301 FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */
302 FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */
303 FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */
304 FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */
305 FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */
306 FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */
307 FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */
308 FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */
309 FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */
310 FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */
311
312 /* Round 2 */
313 #define S21 5
314 #define S22 9
315 #define S23 14
316 #define S24 20
317 GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */
318 GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */
319 GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */
320 GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */
321 GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */
322 GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */
323 GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */
324 GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */
325 GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */
326 GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */
327 GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */
328 GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */
329 GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */
330 GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */
331 GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */
332 GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */
333
334 /* Round 3 */
335 #define S31 4
336 #define S32 11
337 #define S33 16
338 #define S34 23
339 HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */
340 HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */
341 HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */
342 HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */
343 HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */
344 HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */
345 HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */
346 HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */
347 HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */
348 HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */
349 HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */
350 HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */
351 HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */
352 HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */
353 HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */
354 HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */
355
356 /* Round 4 */
357 #define S41 6
358 #define S42 10
359 #define S43 15
360 #define S44 21
361 II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */
362 II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */
363 II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */
364 II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */
365 II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */
366 II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */
367 II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */
368 II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */
369 II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */
370 II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */
371 II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */
372 II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */
373 II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */
374 II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */
375 II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */
376 II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */
377
378 buf[0] += a;
379 buf[1] += b;
380 buf[2] += c;
381 buf[3] += d;
382}
383
384static int is_mac_valid(char*macStr)
385{
386 int Macindex = 0;
387 for (; (macStr[Macindex] != '\0') && (Macindex < OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE); Macindex++)
388 {
389 char chmac = macStr[Macindex];
390 if (!(bInside(chmac, '0', '9') || bInside(chmac, 'a', 'f') || bInside(chmac, 'A', 'F')))
391 {
392 at_print(AT_DEBUG,"mac is not hex str\r");
393 return FALSE;
394 }
395 }
396 return TRUE;
397}
398static char Ascii2BCD(char iAscii)
399{
400 char iBCD;
401
402 if ( bInside(iAscii, '0', '9'))
403 {
404 iBCD = iAscii - '0';
405
406 }
407 else if (bInside(iAscii, 'a', 'f'))
408 {
409 iBCD = iAscii - 'a' + 0x0a;
410
411 }
412 else if (bInside(iAscii, 'A', 'F'))
413 {
414 iBCD = iAscii - 'A' + 0x0a;
415 }
416 else
417 {
418 return -1;
419 }
420
421 return iBCD;
422
423}
424
425static char BCD2Ascii(char iBCD)
426{
427 char iAscii;
428
429 if (bInside(iBCD, 0x00, 0x09))
430 {
431 iAscii = (unsigned char)(iBCD + '0');
432 }
433 else if (bInside(iBCD, 0x0a, 0x0f))
434 {
435 iAscii = (unsigned char)((iBCD - 0x0a) + 'A');
436 }
437 else
438 {
439 return -1;
440 }
441 return iAscii;
442}
443
444static int IsImeiStrValid(char* imeiStr)
445{
446 int i = 0;
447 for (; i < 15; ++i)
448 {
449 if (imeiStr[i] < '0' || imeiStr[i] > '9')
450 {
451 return FALSE;
452 }
453 }
454 return TRUE;
455}
456
457static long Char2Int(char chr)
458{
459 long value = 0;
460 value = (chr - '0');
461 return value;
462}
463
464static char Int2Char(long value)
465{
466 char ch = '0'+value;
467 return ch;
468}
469
470static unsigned long DC_Writeimei(char * imeistr)
471{
472 int Imeiindex =0,checkindex=0;
473 BYTE abImei[DC_ImeiLen]={0};
474 BYTE Index1=0,Index2=0;
475
476 for(Imeiindex=0;imeistr[Imeiindex]!='\0';Imeiindex+=2)
477 {
478 at_print(AT_DEBUG,"Imeiindex= %d\r\n",Imeiindex);
479 at_print(AT_DEBUG,"imeistr[%d]= %c\r\n",Imeiindex,imeistr[Imeiindex]);
480
481 Index1=Char2Int((char)imeistr[Imeiindex]);
482 at_print(AT_DEBUG,"Index1= %d\r",Index1);
483
484 if((imeistr[Imeiindex+1])!='\0')
485 {
486
487 Index2= Char2Int((char)imeistr[Imeiindex+1]);
488 at_print(AT_DEBUG,"Index2= %d, Index2<<4 =%x , (Index2<<4)&Index1 = %x\r\n",Index2,Index2<<4,(Index2<<4)|Index1);
489
490 abImei[Imeiindex/2]=(Index2<<4)|Index1;
491 at_print(AT_DEBUG,"abImei[%d]= %x\r\n",Imeiindex/2,abImei[Imeiindex/2]);
492 }
493 else
494 {
495 abImei[Imeiindex/2]=0xF0|Index1;
496 at_print(AT_DEBUG,"abImei[%d]= %x\r\n",Imeiindex/2,abImei[Imeiindex/2]);
497 break;
498 }
499 }
500 for(checkindex=0;checkindex<8;checkindex++)
501 {
502 at_print(AT_DEBUG,"abImei[%d] = %x\r\n",checkindex,abImei[checkindex]);
503 }
504
505 if(CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_IMEI_ADDRESS, sizeof(abImei), abImei))
506 {
507 at_print(AT_ERR,"Write amt imei failed\r\n");
508 return -1;
509 }
510
511 return 0;
512}
513
514
515/**************************************************************************
516* º¯ÊýÃû³Æ: DC_WriteMacAddr
517* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«MACµØÖ·Ð´Èëµ½NVÖÐ
518* ²ÎÊý˵Ã÷: (IN)
519* (OUT)
520* ·µ »Ø Öµ: ÎÞ
521* ÆäËü˵Ã÷:
522**************************************************************************/
523static unsigned long DC_WriteMacAddr(char *macstr)
524{
525 unsigned long Macindex = 0;
526 unsigned char abMac[OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE] = {0};
527 unsigned char Index1 = 0;
528 unsigned char Index2 = 0;
529
530 if(!is_mac_valid(macstr))
531 {
532 at_print(AT_DEBUG,"mac is not hex str\r");
533 return -1;
534 }
535
536 /*ASCIIÂëת»»³ÉBCDÂë*/
537 for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE); Macindex += 2)
538 {
539 Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
540 Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
541 abMac[Macindex/2]=(Index1<<4)|Index2;
542 }
543
544 if (CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_WIFIMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE, abMac))
545 {
546 at_print(AT_DEBUG,"Write amt mac failed\r");
547 return -1;
548 }
549
550 return 0;
551}
552
553/**************************************************************************
554* º¯ÊýÃû³Æ: DC_WriteMac2Addr
555* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«MACµØÖ·Ð´Èëµ½NVÖÐ
556* ²ÎÊý˵Ã÷: (IN)
557* (OUT)
558* ·µ »Ø Öµ: ÎÞ
559* ÆäËü˵Ã÷:
560**************************************************************************/
561static unsigned long DC_WriteMac2Addr(char *macstr)
562{
563 unsigned long Macindex = 0;
564 unsigned char abMac[OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE] = {0};
565 unsigned char Index1 = 0;
566 unsigned char Index2 = 0;
567
568 if(!is_mac_valid(macstr))
569 {
570 at_print(AT_DEBUG,"mac is not hex str\r");
571 return -1;
572 }
573
574 /*ASCIIÂëת»»³ÉBCDÂë*/
575 for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE); Macindex += 2)
576 {
577 Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
578 Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
579 abMac[Macindex/2]=(Index1<<4)|Index2;
580 }
581
582 if (CPNV_ERROR== amt_nvro_write(OS_FLASH_AMT_COMM_RO_WIFIMAC2_ADDRESS, OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE, abMac))
583 {
584 at_print(AT_DEBUG,"Write amt mac failed\r");
585 return -1;
586 }
587
588 return 0;
589}
590
591/**************************************************************************
592* º¯ÊýÃû³Æ: DC_WriteRJ45MacAddr
593* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«MACµØÖ·Ð´Èëµ½NVÖÐ
594* ²ÎÊý˵Ã÷: (IN)
595* (OUT)
596* ·µ »Ø Öµ: ÎÞ
597* ÆäËü˵Ã÷:
598**************************************************************************/
599unsigned long DC_WriteRJ45MacAddr(char *macstr)
600{
601 unsigned long Macindex = 0;
602 unsigned char abMac[OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE] = {0};
603 unsigned char Index1 = 0;
604 unsigned char Index2 = 0;
605
606 if(!is_mac_valid(macstr))
607 {
608 at_print(AT_DEBUG,"mac is not hex str\r");
609 return -1;
610 }
611
612 /*ASCIIÂëת»»³ÉBCDÂë*/
613 for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE); Macindex += 2)
614 {
615 Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
616 Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
617 abMac[Macindex/2]=(Index1<<4)|Index2;
618 }
619
620 if (CPNV_ERROR== amt_nvro_write(OS_FLASH_AMT_COMM_RO_ETHMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE, abMac))
621 {
622 at_print(AT_DEBUG,"Write amt ethmac failed\r");
623 return -1;
624 }
625
626 return 0;
627}
628
629
630/**************************************************************************
631* º¯ÊýÃû³Æ: DC_WriteMacAddr
632* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«USB MACµØÖ·Ð´Èëµ½NVÖÐ
633* ²ÎÊý˵Ã÷: (IN)
634* (OUT)
635* ·µ »Ø Öµ: ÎÞ
636* ÆäËü˵Ã÷:
637**************************************************************************/
638static unsigned long DC_WriteUSBMacAddr(char *macstr)
639{
640 unsigned long Macindex = 0;
641 unsigned char abMac[OS_FLASH_AMT_COMM_RO_USBMAC_SIZE] = {0};
642 unsigned char Index1 = 0;
643 unsigned char Index2 = 0;
644
645 if(!is_mac_valid(macstr))
646 {
647 at_print(AT_DEBUG,"mac is not hex str\r");
648 return -1;
649 }
650
651 /*ASCIIÂëת»»³ÉBCDÂë*/
652 for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_USBMAC_SIZE); Macindex += 2)
653 {
654 Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
655 Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
656 abMac[Macindex/2]=(Index1<<4)|Index2;
657 }
658
659 if (CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_USBMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_USBMAC_SIZE, abMac))
660 {
661 at_print(AT_DEBUG,"Write amt usb mac failed\r");
662 return -1;
663 }
664
665 return 0;
666}
667
668/**************************************************************************
669* º¯ÊýÃû³Æ: DC_WriteMacAddr
670* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«GMACµØÖ·Ð´Èëµ½NVÖÐ
671* ²ÎÊý˵Ã÷: (IN)
672* (OUT)
673* ·µ »Ø Öµ: ÎÞ
674* ÆäËü˵Ã÷:
675**************************************************************************/
676static unsigned long DC_WriteGmacAddr(char *macstr)
677{
678 unsigned long Macindex = 0;
679 unsigned char abMac[OS_FLASH_AMT_COMM_RO_GMAC_SIZE] = {0};
680 unsigned char Index1 = 0;
681 unsigned char Index2 = 0;
682
683 if(!is_mac_valid(macstr))
684 {
685 at_print(AT_DEBUG,"mac is not hex str\r");
686 return -1;
687 }
688
689 /*ASCIIÂëת»»³ÉBCDÂë*/
690 for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_GMAC_SIZE); Macindex += 2)
691 {
692 Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
693 Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
694 abMac[Macindex/2]=(Index1<<4)|Index2;
695 }
696
697 if (CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_GMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_GMAC_SIZE, abMac))
698 {
699 at_print(AT_DEBUG,"Write amt Gmac failed\r");
700 return -1;
701 }
702
703 return 0;
704}
705
706
707static int rkeydc_act_func(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
708{
709 int retCode = -1;
710 //char pStr[8] = {0};
711 char *at_str = NULL;
712 struct flash_ddr_info flashInfo = {{0}};
713 struct flash_ddr_info ddrInfo = {{0}};
714 struct cpu_info cpuInfo = {{0}};
715 struct wifi_info wifiInfo = {{0}};
716 struct lcd_info lcdInfo = {{0}};
717
718 at_print(AT_ERR,"rkeydc_act_func: \n");
719 at_str = malloc(64);
720 if(at_str == NULL)
721 return AT_END;
722 memset(at_str,0,64);
723 if(strstr(at_paras, "DDR"))
724 {
725 retCode = syscall(GET_DDR_INFO,ddrInfo.manu,ddrInfo.size,ddrInfo.model);
726 if(retCode < 0)
727 {
728 at_print(AT_ERR,"rkeydc_act_func: syscall GET_DDR_INFO failed \n");
729 free(at_str);
730 return AT_END;
731 }
732 at_print(AT_ERR,"rkeydc_act_func: ddrInfo.manu = %s,size = %s,model =%s\n",ddrInfo.manu,ddrInfo.size,ddrInfo.model);
733 snprintf((char*)at_str,64,"\r\n%s?NA?NA?%s?%s\r\n",ddrInfo.manu,ddrInfo.size,ddrInfo.model);
734 *res_msg = at_str;
735 *res_msglen = strlen(*res_msg);
736 }
737 else if(strstr(at_paras, "FLASH"))
738 {
739 retCode = syscall(GET_FLASH_INFO,flashInfo.manu,flashInfo.model,flashInfo.size);
740 if(retCode < 0)
741 {
742 at_print(AT_ERR,"rkeydc_act_func: syscall GET_FLASH_INFO failed \n");
743 free(at_str);
744 return AT_END;
745 }
746 at_print(AT_ERR,"rkeydc_act_func: flashInfo.manu = %s,model = %s,size =%s\n",flashInfo.manu,flashInfo.model,flashInfo.size);
747 snprintf((char*)at_str,64,"\r\n%s?%s?NA?%s?NA\r\n",flashInfo.manu,flashInfo.model,flashInfo.size);
748 *res_msg = at_str;
749 *res_msglen = strlen(*res_msg);
750 }
751 else if(strstr(at_paras, "LCD"))
752 {
753 retCode = syscall(GET_LCD_INFO,lcdInfo.manu,lcdInfo.ic,lcdInfo.resolution);
754 if(retCode < 0)
755 {
756 at_print(AT_ERR,"rkeydc_act_func: syscall GET_LCD_INFO failed \n");
757 free(at_str);
758 return AT_END;
759 }
760 at_print(AT_ERR,"rkeydc_act_func: lcdInfo.manu = %s,ic = %s,resolution =%s\n",lcdInfo.manu,lcdInfo.ic,lcdInfo.resolution);
761 snprintf((char*)at_str,64,"\r\n%s?%s?NA?NA?%s\r\n",lcdInfo.manu,lcdInfo.ic,lcdInfo.resolution);
762 *res_msg = at_str;
763 *res_msglen = strlen(*res_msg);
764 }
765 else if(strstr(at_paras, "WIFI"))
766 {
767 retCode = syscall(GET_WIFI_INFO,wifiInfo.manu,wifiInfo.ic);
768 if(retCode < 0)
769 {
770 at_print(AT_ERR,"rkeydc_act_func: syscall GET_WIFI_INFO failed \n");
771 free(at_str);
772 return AT_END;
773 }
774 at_print(AT_ERR,"rkeydc_act_func: wifiInfo.manu = %s,ic = %s\n",wifiInfo.manu,wifiInfo.ic);
775 snprintf((char*)at_str,64,"\r\n%s?%s?NA?NA?NA\r\n",wifiInfo.manu,wifiInfo.ic);
776 *res_msg = at_str;
777 *res_msglen = strlen(*res_msg);
778 }
779 else if(strstr(at_paras, "CPU"))
780 {
781 retCode = syscall(GET_CPU_INFO,cpuInfo.manu,cpuInfo.model);
782 if(retCode < 0)
783 {
784 at_print(AT_ERR,"rkeydc_act_func: syscall GET_CPU_INFO failed \n");
785 free(at_str);
786 return AT_END;
787 }
788 at_print(AT_ERR,"rkeydc_act_func: cpuInfo.manu = %s,model =%s\n",cpuInfo.manu,cpuInfo.model);
789 snprintf((char*)at_str,64,"\r\n%s?%s?NA?NA?NA\r\n",cpuInfo.manu,cpuInfo.model);
790 *res_msg = at_str;
791 *res_msglen = strlen(*res_msg);
792 }
793 else
794 {
795 free(at_str);
796 }
797
798 return AT_END;
799
800}
801
802int poweroff_act_func(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
803{
804 system("poweroff");
805 // add by houweifeng for zhangwei 20200707, systemº¯Êý²¢²»ÊÇÒ»¶¨Í¬²½Ö´ÐÐ
806 *res_msg = at_ok_build();
807 *res_msglen = strlen(*res_msg);
808 return AT_END;
809}
810
811/**************************************************************************
812* º¯ÊýÃû³Æ: chip_platform_read_act_func
813* ¹¦ÄÜÃèÊö: return chip platform 1:7520V3 2:7100
814* ²ÎÊý˵Ã÷: (IN)
815* (OUT)
816* ·µ »Ø Öµ: ÎÞ
817* ÆäËü˵Ã÷:
818**************************************************************************/
819int chip_platform_read_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
820{
821 char TmpChipPlatform[32] ={0};
822 snprintf((char *)TmpChipPlatform, 32,"1");
823 *res_msg = at_query_result_build("PLATFORM",TmpChipPlatform);
824 *res_msglen = strlen(*res_msg);
825
826 return AT_END;
827}
828
829/**************************************************************************
830* º¯ÊýÃû³Æ: imeiRead_act_func
831* ¹¦ÄÜÃèÊö: ¶ÁimeiºÅ
832* ²ÎÊý˵Ã÷: (IN)
833* (OUT)
834* ·µ »Ø Öµ: ÎÞ
835* ÆäËü˵Ã÷:
836**************************************************************************/
837int imeiRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
838{
839 unsigned int retCode = -1;
840 char TmpImei[DC_ImeiLen]= {0}; //imei³¤¶È×î´óÖµ
841 int abImeiindex = 0,imeistrindex = 0;
842 static char imeistr[2*DC_ImeiLen] = {0};
843 char *at_str = NULL;
844
845 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_IMEI_ADDRESS, (unsigned char *)TmpImei, OS_FLASH_AMT_COMM_RO_IMEI_SIZE);
846 at_print(AT_DEBUG,"retCode = %d\r\n",retCode );
847 if(CPNV_ERROR == retCode )
848 {
849 *res_msg = at_err_build(ATERR_PROC_FAILED);
850 *res_msglen = strlen(*res_msg);
851 return AT_END;
852 }
853
854 for (abImeiindex=0; abImeiindex<DC_ImeiLen-1; abImeiindex++,imeistrindex+=2)
855 {
856 imeistr[imeistrindex] = Int2Char(TmpImei[abImeiindex]&0x0F);
857 imeistr[imeistrindex+1] = Int2Char((TmpImei[abImeiindex]&0xF0)>>4);
858 }
859
860 imeistr[2*DC_ImeiLen-2]=Int2Char(TmpImei[DC_ImeiLen-1]&0x0F);
861 imeistr[2*DC_ImeiLen-1] = '\0';
862
863 //*res_msg = at_query_result_build(NULL,imeistr);
864 at_str = malloc(32);
865 if(at_str)
866 {
867 sprintf(at_str,"\r\n%s\r\nOK\r\n",imeistr);
868 *res_msg = at_str;
869 *res_msglen = strlen(*res_msg);
870 }
871 return AT_END;
872}
873
874
875/**************************************************************************
876* º¯ÊýÃû³Æ: imeiWrite_act_func
877* ¹¦ÄÜÃèÊö: дimeiºÅ
878* ²ÎÊý˵Ã÷: (IN)
879* (OUT)
880* ·µ »Ø Öµ: ÎÞ
881* ÆäËü˵Ã÷:
882**************************************************************************/
883int imeiWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
884{
885 //long retCode = -1;
886 char *at_str = NULL;
887 char Imeistr[2*DC_ImeiLen]= {0};
888
889
890 at_str = at_paras;
891
892 at_print(AT_DEBUG,"imeiWrite_act_func = %s.\n", at_str);
893
894 //if ((strstr((const char *)at_str,"\r")-(char *)at_str)!= (2*DC_ImeiLen-1) || !IsImeiStrValid(at_str))
895 if (strlen(at_paras) != (2*DC_ImeiLen-1) || !IsImeiStrValid(at_str))
896 {
897 *res_msg = at_err_build(ATERR_PARAM_INVALID);
898 *res_msglen = strlen(*res_msg);
899 }
900 else
901 {
902 if (-1 ==DC_Writeimei((char *)at_str))
903 {
904 *res_msg = at_err_build(ATERR_PROC_FAILED);
905 *res_msglen = strlen(*res_msg);
906 return AT_END;
907 }
908
909 memcpy(Imeistr,at_str,2*DC_ImeiLen-1);
910 Imeistr[2*DC_ImeiLen-1] = '\0';
911 *res_msg = at_query_result_build("MODIMEI",Imeistr);
912 *res_msglen = strlen(*res_msg);
913 }
914
915 return AT_END;
916}
917
918/**************************************************************************
919* º¯ÊýÃû³Æ: ssidRead_act_func
920* ¹¦ÄÜÃèÊö: »ñÈ¡SSIDºÅ
921* ²ÎÊý˵Ã÷: (IN)
922* (OUT)
923* ·µ »Ø Öµ: ÎÞ
924* ÆäËü˵Ã÷:
925**************************************************************************/
926int ssidRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
927{
928 unsigned int retCode = CPNV_ERROR;
929 char TmpSSID[ZPS_REF_MSINFO_MAX_SSID_LEN+1]={0};
930
931 retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_SSID_BASE_ADDR, (unsigned char*)TmpSSID, ZPS_REF_MSINFO_MAX_SSID_LEN);
932 TmpSSID[ZPS_REF_MSINFO_MAX_SSID_LEN] = '\0';
933 if(CPNV_ERROR == retCode)
934 {
935 at_print(AT_ERR,"cpnv_NvItemRead ssid fail !\n");
936 *res_msg = at_err_build(ATERR_PROC_FAILED);
937 *res_msglen = strlen(*res_msg);
938 return AT_END;
939 }
940 //strcpy(TmpSSID, (const char*)cfg_get("zssid"));
941
942 *res_msg = at_query_result_build("SSID",TmpSSID);
943 *res_msglen = strlen(*res_msg);
944 return AT_END;
945}
946
947/**************************************************************************
948* º¯ÊýÃû³Æ: ssidWrite_act_func
949* ¹¦ÄÜÃèÊö: дSSIDºÅ
950* ²ÎÊý˵Ã÷: (IN)
951* (OUT)
952* ·µ »Ø Öµ: ÎÞ
953* ÆäËü˵Ã÷: µ±SSIDºÅ¸Ä±äʱatserverÖ÷¶¯Éϱ¨¸øctrm£¬ctrm½«SSIDºÅдÈëNVÖÐ
954**************************************************************************/
955int ssidWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
956{
957 unsigned int retCode = CPNV_ERROR;
958 char *at_str = NULL;
959
960 at_print(AT_ERR,"at_paras=%s\n",at_paras);
961
962 at_str = at_paras;
963
964 retCode = cpnv_NvItemWrite(ZPS_REF_MSINFO_SSID_BASE_ADDR, (unsigned char*)at_str, strlen(at_str));
965 at_print(AT_ERR,"at_str=%s\n",at_str);
966 at_print(AT_ERR,"retCode=%d\n",retCode);
967
968 if(CPNV_ERROR == retCode)
969 {
970 at_print(AT_ERR,"cpnv_NvItemWrite ssid fail !\n");
971 *res_msg = at_err_build(ATERR_PROC_FAILED);
972 *res_msglen = strlen(*res_msg);
973 return AT_END;
974 }
975 else
976 {
977 at_print(AT_ERR,"cpnv_NvItemWrite ssid success !\n");
978 }
979
980 sc_cfg_set("zssid",at_str);
981
982 retCode = cpnv_NvramFlush();
983
984 if (retCode == CPNV_OK)
985 {
986 *res_msg = at_query_result_build("SSID",at_str);
987 }
988 else
989 {
990 at_print(AT_ERR,"cpnv_NvramFlush ssid fail !\n");
991 *res_msg = at_err_build(ATERR_PROC_FAILED);
992 }
993 *res_msglen = strlen(*res_msg);
994
995 return AT_END;
996
997}
998
999
1000/**************************************************************************
1001* º¯ÊýÃû³Æ: versionTypeSet_act_func
1002* ¹¦ÄÜÃèÊö: ÉèÖð汾ÀàÐÍ£¬AMT°æ±¾/´ó°æ±¾
1003* ²ÎÊý˵Ã÷: (IN)
1004* (OUT)
1005* ·µ »Ø Öµ: ÎÞ
1006* ÆäËü˵Ã÷: AT+ZVERSIONTYPE=0Ϊ´ó°æ±¾£¬AT+ZVERSIONTYPE=1ΪAMT°æ±¾
1007**************************************************************************/
1008int versionTypeSet_act_func(int at_fd, char * at_paras,void **res_msg, int * res_msglen)
1009{
1010 long retCode = -1;
1011 char *at_str = NULL;
1012 int ntype = -1;
1013
1014 at_print(AT_ERR,"at_paras=%s\n", at_paras);
1015 at_str = at_paras;
1016
1017 unsigned char bootmode[] = {0x54, 0x4D};
1018 unsigned char atmode[] = {0x41, 0x54};
1019 get_at_cmd_param_int(at_str, &ntype, (const char **)&at_str);
1020
1021 if(!is_at_cmd_end(at_str))
1022 {
1023 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1024 *res_msglen = strlen(*res_msg);
1025 return AT_END;
1026 }
1027
1028 if(ntype == 1)
1029 {
1030 retCode = amt_set_bootmode(bootmode);
1031 }
1032 else if(ntype == 0)
1033 {
1034 memset(bootmode, 0xFF, 2);
1035 retCode = amt_set_bootmode(bootmode);
1036 }
1037 else if(ntype == 2)
1038 {
1039 retCode = amt_set_amt_atmode(bootmode,atmode);
1040 }
1041 else
1042 {
1043 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1044 *res_msglen = strlen(*res_msg);
1045 return AT_END;
1046 }
1047 if (retCode == 0)
1048 {
1049 if (ntype == 0)
1050 {
1051 *res_msg = at_query_result_build("versionType","0");
1052 }
1053 else if(ntype == 1)
1054 {
1055 *res_msg = at_query_result_build("versionType","1");
1056 }
1057 else if(ntype == 2)
1058 {
1059 *res_msg = at_query_result_build("versionType","2");
1060 }
1061 }
1062 else
1063 {
1064 *res_msg = at_err_build(ATERR_PROC_FAILED);
1065 }
1066
1067 *res_msglen = strlen(*res_msg);
1068
1069 return AT_END;
1070}
1071
1072/**************************************************************************
1073* º¯ÊýÃû³Æ: macRead_act_func
1074* ¹¦ÄÜÃèÊö: ¶ÁMACµØÖ·
1075* ²ÎÊý˵Ã÷: (IN)
1076* (OUT)
1077* ·µ »Ø Öµ: ÎÞ
1078* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
1079**************************************************************************/
1080int macRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1081{
1082 unsigned int retCode = CPNV_ERROR;
1083 char TmpMacAddr[Comm_DEV_MSINFO_MAX_WIFIMAC_Area_Len] = {0};//imei³¤¶È×î´óÖµ
1084 char str[13];
1085 unsigned long abMacindex = 0;
1086 static char macstr[2 * AT_CMD_MAX - 1] = {0};
1087
1088 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_WIFIMAC_ADDRESS, (unsigned char *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE);
1089 at_print(AT_DEBUG,"retCode = %d\r\n",retCode );
1090 if(CPNV_ERROR == retCode )
1091 {
1092 *res_msg = at_err_build(ATERR_PROC_FAILED);
1093 *res_msglen = strlen(*res_msg);
1094 return AT_END;
1095 }
1096
1097 /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
1098 memset(str, 0, 13);
1099
1100 for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
1101 {
1102 str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
1103 str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
1104
1105 macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
1106 macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
1107 }
1108
1109 *res_msg = at_query_result_build("MAC",macstr);
1110 *res_msglen = strlen(*res_msg);
1111
1112 return AT_END;
1113
1114}
1115
1116/**************************************************************************
1117* º¯ÊýÃû³Æ: macWrite_act_func
1118* ¹¦ÄÜÃèÊö: дMACµØÖ·
1119* ²ÎÊý˵Ã÷: (IN)
1120* (OUT)
1121* ·µ »Ø Öµ: ÎÞ
1122* ÆäËü˵Ã÷:
1123**************************************************************************/
1124int macWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1125{
1126 //long retCode = CPNV_ERROR;
1127 char *at_str = NULL;
1128
1129 //zOss_ASSERT(at_paras!=NULL);
1130 at_str = at_paras;
1131
1132 if (strlen(at_str) != DC_MacLen)
1133 {
1134 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1135 }
1136 else
1137 {
1138 if (-1 == DC_WriteMacAddr((char *)at_str))
1139 {
1140 *res_msg = at_err_build(ATERR_PROC_FAILED);
1141 }
1142 else
1143 {
1144 //*res_msg = at_query_result_build("MAC",at_str);
1145 *res_msg = at_ok_build();
1146 }
1147 }
1148
1149 *res_msglen = strlen(*res_msg);
1150
1151 return AT_END;
1152}
1153
1154/**************************************************************************
1155* º¯ÊýÃû³Æ: wifikeyRead_act_func
1156* ¹¦ÄÜÃèÊö: »ñÈ¡WifiKeyµÄÖµ
1157* ²ÎÊý˵Ã÷: (IN)
1158* (OUT)
1159* ·µ »Ø Öµ: ÎÞ
1160* ÆäËü˵Ã÷:
1161**************************************************************************/
1162int wifikeyRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1163{
1164 unsigned int retCode = CPNV_ERROR;
1165 char TmpWifiKey[ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN+1]={0};
1166
1167 retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_NEWWIFIKEY_BASE_ADDR, (unsigned char *)TmpWifiKey, ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN);
1168 TmpWifiKey[ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN] = '\0';
1169 //zOss_ASSERT(retCode!=ZOSS_ERROR);
1170 if(CPNV_ERROR == retCode)
1171 {
1172 at_print(AT_ERR,"cpnv_NvItemRead wifikey fail !\n");
1173 *res_msg = at_err_build(ATERR_PROC_FAILED);
1174 *res_msglen = strlen(*res_msg);
1175 return AT_END;
1176 }
1177 //strcpy(TmpWifiKey, (const char*)cfg_get("zwifikey"));
1178
1179 *res_msg = at_query_result_build("WIFIKEY",TmpWifiKey);
1180 *res_msglen = strlen(*res_msg);
1181
1182 return AT_END;
1183}
1184
1185/**************************************************************************
1186* º¯ÊýÃû³Æ: wifikeyWrite_act_func
1187* ¹¦ÄÜÃèÊö: дWIFI KEYµÄÖµ
1188* ²ÎÊý˵Ã÷: (IN)
1189* (OUT)
1190* ·µ »Ø Öµ: ÎÞ
1191* ÆäËü˵Ã÷:
1192**************************************************************************/
1193int wifikeyWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1194{
1195 char *at_str = NULL;
1196 //char *pStrValue = NULL;
1197 unsigned long retCode = CPNV_ERROR;
1198
1199 //zOss_ASSERT(at_paras!=NULL);
1200 at_str = at_paras;
1201 if(strlen(at_str)> ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN)
1202 {
1203 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1204 *res_msglen = strlen(*res_msg);
1205 return AT_END;
1206 }
1207
1208 retCode = cpnv_NvItemWrite(ZPS_REF_MSINFO_NEWWIFIKEY_BASE_ADDR, (unsigned char *)at_str, strlen(at_str));
1209 //sc_cfg_set("zwifikey",at_str);
1210
1211 if (retCode == CPNV_OK)
1212 {
1213 retCode = cpnv_NvramFlush();
1214
1215 if (retCode == CPNV_OK)
1216 {
1217 *res_msg = at_query_result_build("WIFIKEY",at_str);
1218 }
1219 else
1220 {
1221 *res_msg = at_err_build(ATERR_PROC_FAILED);
1222 }
1223
1224 }
1225 else
1226 {
1227 *res_msg = at_err_build(ATERR_PROC_FAILED);
1228 }
1229
1230 *res_msglen = strlen(*res_msg);
1231 return AT_END;
1232}
1233
1234/**************************************************************************
1235* º¯ÊýÃû³Æ: rj45MacAddrRead_act_func
1236* ¹¦ÄÜÃèÊö: ¶ÁMACµØÖ·
1237* ²ÎÊý˵Ã÷: (IN)
1238* (OUT)
1239* ·µ »Ø Öµ: ÎÞ
1240* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
1241**************************************************************************/
1242int rj45MacAddrRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1243{
1244 unsigned long retCode = CPNV_ERROR;
1245 char TmpMacAddr[OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE] = {0};
1246 char str[13];
1247 long abMacindex = 0;
1248 static char macstr[2 * OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE - 1] = {0};
1249
1250 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_ETHMAC_ADDRESS, (unsigned char *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE);
1251 at_print(AT_DEBUG,"retCode = %d\r\n",retCode );
1252 if(CPNV_ERROR == retCode )
1253 {
1254 *res_msg = at_err_build(ATERR_PROC_FAILED);
1255 *res_msglen = strlen(*res_msg);
1256 return AT_END;
1257 }
1258
1259 /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
1260 memset(str, 0, 13);
1261
1262 for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
1263 {
1264 str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
1265 str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
1266
1267 macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
1268 macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
1269 }
1270
1271 /* MACµØÖ·×ª»»½áÊø*/
1272 *res_msg = at_query_result_build("ETHMAC",macstr);
1273 *res_msglen = strlen(*res_msg);
1274
1275 return AT_END;
1276}
1277
1278/**************************************************************************
1279* º¯ÊýÃû³Æ: rj45MacAddWrite_act_func
1280* ¹¦ÄÜÃèÊö: дMACµØÖ·
1281* ²ÎÊý˵Ã÷: (IN)
1282* (OUT)
1283* ·µ »Ø Öµ: ÎÞ
1284* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
1285**************************************************************************/
1286int rj45MacAddWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1287{
1288 //long retCode = CPNV_ERROR;
1289 char *at_str = NULL;
1290
1291 //zOss_ASSERT(at_paras!=NULL);
1292 at_str = at_paras;
1293
1294 if (strlen(at_str)!= DC_MacLen)
1295 {
1296 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1297 }
1298 else
1299 {
1300 if (-1 == DC_WriteRJ45MacAddr((char *)at_str))
1301 {
1302 *res_msg = at_err_build(ATERR_PROC_FAILED);
1303 }
1304 else
1305 {
1306 *res_msg = at_query_result_build("ETHMAC",at_str);
1307 }
1308 }
1309
1310 *res_msglen = strlen(*res_msg);
1311
1312 return AT_END;
1313}
1314
1315/**************************************************************************
1316* º¯ÊýÃû³Æ: mac2Read_act_func
1317* ¹¦ÄÜÃèÊö: ¶ÁMACµØÖ·
1318* ²ÎÊý˵Ã÷: (IN)
1319* (OUT)
1320* ·µ »Ø Öµ: ÎÞ
1321* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
1322**************************************************************************/
1323int mac2Read_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1324{
1325 unsigned long retCode = CPNV_ERROR;
1326 char TmpMacAddr[OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE] = {0};//imei³¤¶È×î´óÖµ
1327 char str[13];
1328 long abMacindex = 0;
1329 static char macstr[2 * OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE - 1] = {0};
1330
1331 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_WIFIMAC2_ADDRESS, (UINT8 *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE);
1332
1333 if (CPNV_ERROR == retCode )
1334 {
1335 *res_msg = at_err_build(ATERR_PROC_FAILED);
1336 *res_msglen = strlen(*res_msg);
1337 return AT_END;
1338 }
1339
1340 /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
1341 memset(str, 0, 13);
1342
1343 for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
1344 {
1345 str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
1346 str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
1347
1348 macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
1349 macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
1350 }
1351
1352 /* MACµØÖ·×ª»»½áÊø*/
1353 *res_msg = at_query_result_build("MAC2",macstr);
1354 *res_msglen = strlen(*res_msg);
1355 return AT_END;
1356}
1357
1358/**************************************************************************
1359* º¯ÊýÃû³Æ: mac2Write_act_func
1360* ¹¦ÄÜÃèÊö: дMACµØÖ·
1361* ²ÎÊý˵Ã÷: (IN)
1362* (OUT)
1363* ·µ »Ø Öµ: ÎÞ
1364* ÆäËü˵Ã÷:
1365**************************************************************************/
1366int mac2Write_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1367{
1368 //long retCode = CPNV_ERROR;
1369 char *at_str = NULL;
1370
1371 //zOss_ASSERT(at_paras!=NULL);
1372 at_str = at_paras;
1373
1374 if (strlen(at_str)!= DC_MacLen)
1375 {
1376 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1377 }
1378 else
1379 {
1380 if (-1 == DC_WriteMac2Addr((char *)at_str))
1381 {
1382 *res_msg = at_err_build(ATERR_PROC_FAILED);
1383 }
1384 else
1385 {
1386 *res_msg = at_query_result_build("MAC2",at_str);
1387 }
1388 }
1389
1390 *res_msglen = strlen(*res_msg);
1391
1392 return AT_END;
1393}
1394
1395/**************************************************************************
1396* º¯ÊýÃû³Æ: usbmacRead_act_func
1397* ¹¦ÄÜÃèÊö: ¶ÁUSB MACµØÖ·
1398* ²ÎÊý˵Ã÷: (IN)
1399* (OUT)
1400* ·µ »Ø Öµ: ÎÞ
1401* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
1402**************************************************************************/
1403int usbmacRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1404{
1405 unsigned long retCode = CPNV_ERROR;
1406 char TmpMacAddr[OS_FLASH_AMT_COMM_RO_USBMAC_SIZE] = {0};//imei³¤¶È×î´óÖµ
1407 char str[13];
1408 long abMacindex = 0;
1409 static char macstr[2 * OS_FLASH_AMT_COMM_RO_USBMAC_SIZE - 1] = {0};
1410
1411 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_USBMAC_ADDRESS, (UINT8 *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_USBMAC_SIZE);
1412
1413 if (CPNV_ERROR == retCode )
1414 {
1415 *res_msg = at_err_build(ATERR_PROC_FAILED);
1416 *res_msglen = strlen(*res_msg);
1417 return AT_END;
1418 }
1419
1420 /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
1421 memset(str, 0, 13);
1422
1423 for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
1424 {
1425 str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
1426 str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
1427
1428 macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
1429 macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
1430 }
1431
1432 /* MACµØÖ·×ª»»½áÊø*/
1433 *res_msg = at_query_result_build("USBMAC",macstr);
1434 *res_msglen = strlen(*res_msg);
1435 return AT_END;
1436}
1437
1438/**************************************************************************
1439* º¯ÊýÃû³Æ: usbmacWrite_act_func
1440* ¹¦ÄÜÃèÊö: дUSB MACµØÖ·
1441* ²ÎÊý˵Ã÷: (IN)
1442* (OUT)
1443* ·µ »Ø Öµ: ÎÞ
1444* ÆäËü˵Ã÷:
1445**************************************************************************/
1446int usbmacWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1447{
1448 //long retCode = CPNV_ERROR;
1449 char *at_str = NULL;
1450
1451 //zOss_ASSERT(at_paras!=NULL);
1452 at_str = at_paras;
1453
1454 if (strlen(at_str)!= DC_MacLen)
1455 {
1456 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1457 }
1458 else
1459 {
1460 if (-1 == DC_WriteUSBMacAddr((char *)at_str))
1461 {
1462 *res_msg = at_err_build(ATERR_PROC_FAILED);
1463 }
1464 else
1465 {
1466 *res_msg = at_query_result_build("USBMAC",at_str);
1467 }
1468 }
1469
1470 *res_msglen = strlen(*res_msg);
1471
1472 return AT_END;
1473
1474}
1475
1476/**************************************************************************
1477* º¯ÊýÃû³Æ: gmacRead_act_func
1478* ¹¦ÄÜÃèÊö: ¶ÁGMACµØÖ·
1479* ²ÎÊý˵Ã÷: (IN)
1480* (OUT)
1481* ·µ »Ø Öµ: ÎÞ
1482* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
1483**************************************************************************/
1484
1485int gmacRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1486{
1487 unsigned long retCode = CPNV_ERROR;
1488 char TmpMacAddr[OS_FLASH_AMT_COMM_RO_GMAC_SIZE] = {0};//imei³¤¶È×î´óÖµ
1489 char str[13];
1490 long abMacindex = 0;
1491 static char macstr[2 * OS_FLASH_AMT_COMM_RO_GMAC_SIZE - 1] = {0};
1492
1493 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_GMAC_ADDRESS, (UINT8 *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_GMAC_SIZE);
1494
1495 if (CPNV_ERROR == retCode )
1496 {
1497 *res_msg = at_err_build(ATERR_PROC_FAILED);
1498 *res_msglen = strlen(*res_msg);
1499 return AT_END;
1500 }
1501
1502 /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
1503 memset(str, 0, 13);
1504
1505 for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
1506 {
1507 str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
1508 str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
1509
1510 macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
1511 macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
1512 }
1513
1514 /* MACµØÖ·×ª»»½áÊø*/
1515 *res_msg = at_query_result_build("GMAC",macstr);
1516 *res_msglen = strlen(*res_msg);
1517 return AT_END;
1518}
1519
1520/**************************************************************************
1521* º¯ÊýÃû³Æ: gmacWrite_act_func
1522* ¹¦ÄÜÃèÊö: дGMACµØÖ·
1523* ²ÎÊý˵Ã÷: (IN)
1524* (OUT)
1525* ·µ »Ø Öµ: ÎÞ
1526* ÆäËü˵Ã÷:
1527**************************************************************************/
1528int gmacWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1529{
1530 //long retCode = CPNV_ERROR;
1531 char *at_str = NULL;
1532
1533 //zOss_ASSERT(at_paras!=NULL);
1534 at_str = at_paras;
1535
1536 if (strlen(at_str)!= DC_MacLen)
1537 {
1538 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1539 }
1540 else
1541 {
1542 if (-1 == DC_WriteGmacAddr((char *)at_str))
1543 {
1544 *res_msg = at_err_build(ATERR_PROC_FAILED);
1545 }
1546 else
1547 {
1548 *res_msg = at_query_result_build("GMAC",at_str);
1549 }
1550 }
1551
1552 *res_msglen = strlen(*res_msg);
1553
1554 return AT_END;
1555
1556}
1557
1558/**************************************************************************
1559* º¯ÊýÃû³Æ: batdetRead_act_func
1560* ¹¦ÄÜÃèÊö: »ñÈ¡BATDETµÄÖµ
1561* ²ÎÊý˵Ã÷: (IN)
1562* (OUT)
1563* ·µ »Ø Öµ: ÎÞ
1564* ÆäËü˵Ã÷:
1565**************************************************************************/
1566int batdetRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1567{
1568 unsigned int retCode = CPNV_ERROR;
1569 char TmpBatdet[32] = {0};
1570 int nv_value = 0;
1571
1572 retCode = cpnv_NvItemRead(DRV_PERI_NV_ADDR, (unsigned char *)&nv_value, 1);
1573
1574 at_print(AT_DEBUG, "batdetRead_act_func:nv_value = %d\n", nv_value);
1575
1576 snprintf((char *)TmpBatdet, 32, "%d", nv_value);
1577 if(retCode != CPNV_ERROR)
1578 {
1579 *res_msg = at_query_result_build("BATDET", TmpBatdet);
1580 *res_msglen = strlen(*res_msg);
1581 }
1582 else
1583 {
1584 *res_msg = at_err_build(ATERR_PROC_FAILED);
1585 *res_msglen = strlen(*res_msg);
1586 }
1587 return AT_END;
1588}
1589
1590/**************************************************************************
1591* º¯ÊýÃû³Æ: batdetWrite_act_func
1592* ¹¦ÄÜÃèÊö: дBATDETµÄÖµ
1593* ²ÎÊý˵Ã÷: (IN)
1594* (OUT)
1595* ·µ »Ø Öµ: ÎÞ
1596* ÆäËü˵Ã÷:
1597**************************************************************************/
1598int batdetWrite_act_func(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
1599{
1600 char *at_str = NULL;
1601 //char *pStrValue = NULL;
1602 //char TmpBatdet[32] = {0};
1603 unsigned long retCode = CPNV_ERROR;
1604 int nv_value = -1;
1605
1606 at_str = at_paras;
1607 at_print(AT_DEBUG, "batdetWrite_act_func:at_str = %s\n", at_str);
1608
1609 get_at_cmd_param_int(at_str, &nv_value, (const char **)&at_str);
1610
1611 at_print(AT_DEBUG,"batdetWrite_act_func:at_str = %s\n", at_str);
1612 at_print(AT_DEBUG,"batdetWrite_act_func:nv_value = %d\n", nv_value);
1613
1614 if(!(0 == nv_value || 1 == nv_value)) // szLanEnableÖ»ÓÐ0ºÍ1Á½¸öÖµ
1615 {
1616 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1617 *res_msglen = strlen(*res_msg);
1618 return AT_END;
1619 }
1620
1621 retCode =amt_set_batdet_flag(nv_value);
1622
1623 if (retCode == CPNV_OK)
1624 {
1625 if(nv_value == 1)
1626 {
1627 *res_msg = at_query_result_build("BATDET","1");
1628 }
1629 else
1630 {
1631 *res_msg = at_query_result_build("BATDET","0");
1632 }
1633 }
1634 else
1635 {
1636 *res_msg = at_err_build(ATERR_PROC_FAILED);
1637 }
1638
1639 *res_msglen = strlen(*res_msg);
1640 return AT_END;
1641}
1642
1643int msnRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1644{
1645 unsigned int retCode = CPNV_ERROR;
1646 char TmpMSN[MSN_MAX_NVINFO_LEN+1]= {0};
1647
1648 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_MSerialNum_ADDRESS, (UINT8 *)TmpMSN, MSN_MAX_NVINFO_LEN);
1649 TmpMSN[MSN_MAX_NVINFO_LEN] = '\0';
1650 if(retCode != CPNV_ERROR)
1651 {
1652 *res_msg = at_query_result_build("MSN",TmpMSN);
1653 *res_msglen = strlen(*res_msg);
1654 }
1655 else
1656 {
1657 *res_msg = at_err_build(ATERR_PROC_FAILED);
1658 *res_msglen = strlen(*res_msg);
1659 }
1660 return AT_END;
1661}
1662
1663int msnWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1664{
1665 unsigned int retCode = CPNV_ERROR;
1666 char *at_str = NULL;
1667
1668 if(NULL !=at_paras)
1669 {
1670 at_str = at_paras;
1671 at_print(AT_DEBUG,"msnWrite_act_func = %s.\n", at_str);
1672 if((strlen(at_str) >= 12) && (strlen(at_str) <= 20))
1673 {
1674 retCode = amt_nvro_write(OS_FLASH_AMT_COMM_RO_MSerialNum_ADDRESS, MSN_MAX_NVINFO_LEN, (unsigned char *)at_str);
1675 if(retCode != CPNV_ERROR)
1676 {
1677 *res_msg = at_ok_build();
1678 *res_msglen = strlen(*res_msg);
1679 return AT_END;
1680 }
1681 }
1682 }
1683 *res_msg = at_err_build(ATERR_PROC_FAILED);
1684 *res_msglen = strlen(*res_msg);
1685 return AT_END;
1686
1687}
1688
1689int testInfoRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1690{
1691 unsigned int retCode = CPNV_ERROR;
1692 char TmpTestInfo[MSINFO_MAX_NVINFO_LEN+1] = {0};
1693
1694 retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_TestInfo_ADDRESS, (UINT8 *)TmpTestInfo, MSINFO_MAX_NVINFO_LEN);
1695 TmpTestInfo[MSINFO_MAX_NVINFO_LEN] = '\0';
1696 if(retCode != CPNV_ERROR)
1697 {
1698 *res_msg = at_query_result_build("RTESTINFO",TmpTestInfo);
1699 *res_msglen = strlen(*res_msg);
1700 }
1701 else
1702 {
1703 *res_msg = at_err_build(ATERR_PROC_FAILED);
1704 *res_msglen = strlen(*res_msg);
1705 }
1706 return AT_END;
1707}
1708
1709int closeAutoInd_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1710{
1711 if('1' == at_paras[0])
1712 {
1713 at_context_chn_info_mod("none");
1714 *res_msg = at_ok_build();
1715 *res_msglen = strlen(*res_msg);
1716 }
1717 else
1718 {
1719 *res_msg = at_err_build(ATERR_PROC_FAILED);
1720 *res_msglen = strlen(*res_msg);
1721 }
1722 return AT_END;
1723}
1724
1725
1726
1727int zphone_mode_query_req_act(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
1728{
1729 UINT32 retCode = CPNV_ERROR;
1730 UINT8 TmpPhoneMode = 0;
1731 char *pPtr = NULL;
1732
1733 pPtr = malloc(256);
1734 if(pPtr == NULL)
1735 {
1736 softap_assert("");
1737 return AT_END;
1738 }
1739 memset(pPtr, 0x00, 256);
1740
1741 retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR, &TmpPhoneMode, sizeof(UINT8));
1742 if(retCode == CPNV_ERROR){softap_assert("");}
1743
1744 if( 1 == (TmpPhoneMode & 0x1)) //×îºóһλÊÇ1 ´¿modem°æ±¾
1745 {
1746 snprintf((char *)pPtr, 64,"\r\n+PHONEMODE: %d", 0);
1747 }
1748 else if (0 == (TmpPhoneMode & 0x1)) //×îºóһλÊÇ 0 Õý³£°æ±¾
1749 {
1750 snprintf((char *)pPtr, 64,"\r\n+PHONEMODE: %d", 1);
1751 }
1752
1753 strcat((char *)pPtr,"\r\n\r\nOK\r\n");
1754
1755
1756 *res_msg = pPtr;
1757 *res_msglen = strlen(pPtr);
1758
1759 return AT_END;
1760}
1761
1762int zphone_mode_set_req_act(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
1763{
1764 UINT8 phoneModeStatus = 0;
1765 UINT32 retCode = CPNV_ERROR;
1766
1767 retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR,&phoneModeStatus,sizeof(UINT8));
1768 if(retCode == CPNV_ERROR)
1769 {
1770 softap_assert("");
1771 }
1772
1773 //Õý³£°æ±¾
1774 if('1' == at_paras[0])
1775 {
1776 phoneModeStatus = (0xfe & phoneModeStatus); // ºóһλ0±íʾÕý³£°æ±¾
1777 sc_cfg_set("version_mode","0");
1778 }
1779 //´¿modem°æ±¾
1780 else if('0' == at_paras[0])
1781 {
1782 phoneModeStatus = (0x1 | phoneModeStatus); // ºóһλ1±íʾÊÇ´¿modem°æ±¾
1783 sc_cfg_set("version_mode","1"); //version_mode==1 phonemode==0 Ϊ´¿modem°æ±¾
1784 }
1785 else
1786 {
1787 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1788 *res_msglen = strlen(*res_msg);
1789 return AT_END;
1790 }
1791 retCode = cpnv_NvItemWrite(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR,&phoneModeStatus,sizeof(UINT8));
1792 if(retCode == CPNV_ERROR){softap_assert("");}
1793 retCode = cpnv_NvramFlush();
1794 if(retCode == CPNV_ERROR){softap_assert("");}
1795
1796 *res_msg = at_ok_build();
1797 *res_msglen = strlen(*res_msg);
1798 return AT_END;
1799}
1800
1801/**************************************************************************
1802* º¯ÊýÃû³Æ: zsoftreset_act_func
1803* ¹¦ÄÜÃèÊö: ÉèÖÃÈí¼þÖØÆô
1804* ²ÎÊý˵Ã÷: (IN)
1805* (OUT)
1806* ·µ »Ø Öµ: ÎÞ
1807* ÆäËü˵Ã÷:
1808**************************************************************************/
1809int zsoftreset_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
1810{
1811 //char *pPtr = NULL;
1812
1813 //zOss_SysSoftReset(SYS_RESET_TO_NORMAL);
1814 ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);
1815
1816 *res_msg = at_query_result_build("ZSOFTRESET", "");
1817 *res_msglen = strlen(*res_msg);
1818
1819 return AT_END;
1820}
1821
1822int ext_ramdump_func(char *at_paras, void ** res_msg)
1823{
1824 assert(0);
1825 return AT_END;
1826}
1827
1828int zmodeSet_act_func_check_mode(char *at_paras, void ** res_msg, int *res_msglen)
1829{
1830 int iUsbMode = -1;
1831 char* at_str = NULL;
1832
1833
1834 if(at_paras==NULL)
1835 softap_assert("zmodeSet_act_func:at_paras is null");
1836
1837 at_str = at_paras;
1838 get_at_cmd_param_int(at_str, &iUsbMode, (const char **)&at_str);
1839 at_print(AT_DEBUG,"zmodeSet_act_func:iUsbMode == %d\n", iUsbMode);
1840
1841 char strCfgGetItem[AT_CMD_MAX] = {0};
1842 nv_get_item(NV_RO, "usb_modetype", strCfgGetItem, sizeof(strCfgGetItem));
1843 at_print(AT_ERR,"current usb mode type = %s\n", strCfgGetItem);
1844
1845 //´ÓÓû§Ä£Ê½Çе½ÆäËû·ÇÓû§Ä£Ê½¶¼ÐèÒª¼øÈ¨
1846/* if((strcmp(strCfgGetItem,"user")== 0)&&(iUsbMode != 0))
1847 {
1848 if(auth_device_key_result != 1 && auth_device_key_init_value() != 1)
1849 {
1850 at_print(AT_ERR,"auth_device_key_result=%d,device key verify fail!\n", auth_device_key_result);
1851 *res_msg = at_err_build(ATERR_NOT_ALLOWED);
1852 *res_msglen = strlen(*res_msg);
1853
1854 iUsbMode = -1;
1855 }
1856 }*/
1857
1858 return iUsbMode;
1859}
1860
1861
1862int zmodeSet_act_func(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
1863{
1864 int iUsbMode = 0;
1865 UINT8 bootmode[] = {0x54,0x4D};
1866 long retCode = -1;
1867
1868 at_print(AT_DEBUG,"ext_amt_func.c:zmodeSet_act_func\n");
1869
1870 iUsbMode = zmodeSet_act_func_check_mode(at_paras, res_msg, res_msglen);
1871 if(iUsbMode < 0)
1872 {
1873 return AT_END;
1874 }
1875
1876 switch(iUsbMode)
1877 {
1878 case 0: //user mode
1879 {
1880 nv_set_item(NV_RO, "usb_modetype", "user", 1);
1881 bootmode[1] =0x00;
1882 retCode = amt_set_bootmode(bootmode);
1883 break;
1884 }
1885 case 1://debug mode
1886 {
1887 nv_set_item(NV_RO, "usb_modetype", "debug", 1);
1888 bootmode[1] =0x01;
1889 retCode = amt_set_bootmode(bootmode);
1890 break;
1891 }
1892 case 2://factory mode
1893 {
1894 nv_set_item(NV_RO, "usb_modetype", "factory", 1);
1895 bootmode[1] =0x02;
1896 retCode = amt_set_bootmode(bootmode);
1897 break;
1898 }
1899 case 3://amt mode
1900 {
1901 //nv_set_item(NV_RO, "usb_modetype", "amt", 1);
1902 retCode = amt_set_bootmode(bootmode);
1903 break;
1904 }
1905 default:
1906 {
1907 *res_msg = at_err_build(ATERR_PARAM_INVALID);
1908 *res_msglen = strlen(*res_msg);
1909 return AT_END;
1910 }
1911 }
1912
1913 nv_commit(NV_RO);
1914
1915 at_print(AT_DEBUG,"zmodeSet_act_func:retCode == %d\n", retCode);
1916 if (retCode == 0)
1917 {
1918 *res_msg = at_ok_build();
1919 }
1920 else
1921 {
1922 *res_msg = at_err_build(ATERR_PROC_FAILED);
1923 }
1924 *res_msglen = strlen(*res_msg);
1925 return AT_END;
1926}
1927
xf.liaa4d92f2023-09-13 00:18:58 -07001928
1929#define SHA256_ROTL(a,b) (((a>>(32-b))&(0x7fffffff>>(31-b)))|(a<<b))
1930#define SHA256_SR(a,b) ((a>>b)&(0x7fffffff>>(b-1)))
1931#define SHA256_Ch(x,y,z) ((x&y)^((~x)&z))
1932#define SHA256_Maj(x,y,z) ((x&y)^(x&z)^(y&z))
1933#define SHA256_E0(x) (SHA256_ROTL(x,30)^SHA256_ROTL(x,19)^SHA256_ROTL(x,10))
1934#define SHA256_E1(x) (SHA256_ROTL(x,26)^SHA256_ROTL(x,21)^SHA256_ROTL(x,7))
1935#define SHA256_O0(x) (SHA256_ROTL(x,25)^SHA256_ROTL(x,14)^SHA256_SR(x,3))
1936#define SHA256_O1(x) (SHA256_ROTL(x,15)^SHA256_ROTL(x,13)^SHA256_SR(x,10))
1937
1938
1939/**
1940 * @brief ¼ÆËãSHA-256
1941 * @param[in,out] str ÐèÒª¼ÆËãSHA-256 hashÖµµÄÂëÁ÷Ö¸Õë
1942 * @param[in,out] length ÂëÁ÷³¤¶È
1943 * @param[in,out] sha256 ÓÃÓÚ±£´æSHA-256µÄÖ¸Õë
1944 * @return ³É¹¦·µ»Øsha256£¬Ê§°Ü·µ»Ø0
1945 * @note
1946 * @see
1947 */
1948
1949unsigned char* StrSHA256(const unsigned char* str, long long length, unsigned char* sha256)
1950{
1951 /*
1952 ¼ÆËã×Ö·û´®SHA-256
1953 ²ÎÊý˵Ã÷£º
1954 str ×Ö·û´®Ö¸Õë
1955 length ×Ö·û´®³¤¶È
1956 sha256 ÓÃÓÚ±£´æSHA-256µÄ×Ö·û´®Ö¸Õë
1957 ·µ»ØÖµÎª²ÎÊýsha256
1958 */
1959 unsigned char *pp, *ppend;
1960 long l, i, W[64], T1, T2, A, B, C, D, E, F, G, H, H0, H1, H2, H3, H4, H5, H6, H7;
1961 H0 = 0x6a09e667, H1 = 0xbb67ae85, H2 = 0x3c6ef372, H3 = 0xa54ff53a;
1962 H4 = 0x510e527f, H5 = 0x9b05688c, H6 = 0x1f83d9ab, H7 = 0x5be0cd19;
1963 long K[64] = {
1964 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
1965 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
1966 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
1967 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
1968 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
1969 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
1970 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
1971 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
1972 };
1973 l = length + ((length % 64 >= 56) ? (128 - length % 64) : (64 - length % 64));
1974 if (!(pp = (unsigned char*)malloc((unsigned long)l))) return 0;
1975 for (i = 0; i < length; pp[i + 3 - 2 * (i % 4)] = str[i], i++);
1976 for (pp[i + 3 - 2 * (i % 4)] = 128, i++; i < l; pp[i + 3 - 2 * (i % 4)] = 0, i++);
1977 *((long*)(pp + l - 4)) = length << 3;
1978 *((long*)(pp + l - 8)) = length >> 29;
1979 for (ppend = pp + l; pp < ppend; pp += 64){
1980 for (i = 0; i < 16; W[i] = ((long*)pp)[i], i++);
1981 for (i = 16; i < 64; W[i] = (SHA256_O1(W[i - 2]) + W[i - 7] + SHA256_O0(W[i - 15]) + W[i - 16]), i++);
1982 A = H0, B = H1, C = H2, D = H3, E = H4, F = H5, G = H6, H = H7;
1983 for (i = 0; i < 64; i++){
1984 T1 = H + SHA256_E1(E) + SHA256_Ch(E, F, G) + K[i] + W[i];
1985 T2 = SHA256_E0(A) + SHA256_Maj(A, B, C);
1986 H = G, G = F, F = E, E = D + T1, D = C, C = B, B = A, A = T1 + T2;
1987 }
1988 H0 += A, H1 += B, H2 += C, H3 += D, H4 += E, H5 += F, H6 += G, H7 += H;
1989 }
1990 free(pp - l);
1991 memcpy(sha256,&H0,sizeof(H0));
1992 memcpy(sha256 + sizeof(H0),&H1,sizeof(H1));
1993 memcpy(sha256 + sizeof(H0) + sizeof(H1),&H2,sizeof(H2));
1994 memcpy(sha256 + sizeof(H0) + sizeof(H1) + sizeof(H2),&H3,sizeof(H3));
1995 memcpy(sha256 + sizeof(H0) + sizeof(H1) + sizeof(H2) + sizeof(H3),&H4,sizeof(H4));
1996 memcpy(sha256 + sizeof(H0) + sizeof(H1) + sizeof(H2) + sizeof(H3) + sizeof(H4),&H5,sizeof(H5));
1997 memcpy(sha256 + sizeof(H0) + sizeof(H1) + sizeof(H2) + sizeof(H3) + sizeof(H4) + sizeof(H5),&H6,sizeof(H6));
1998 memcpy(sha256 + sizeof(H0) + sizeof(H1) + sizeof(H2) + sizeof(H3) + sizeof(H4) + sizeof(H5) + sizeof(H6),&H7,sizeof(H7));
1999 return sha256;
2000}
2001
2002static int IsEnhancedSecurity()
2003{
2004 #define CMDLINE_MAX_SIZE (4*1024)
2005 int cmdline_fd = -1;
2006 char*cmdline_buf = malloc(CMDLINE_MAX_SIZE);
2007 char*temp = NULL;
2008 int ret_size = 0;
2009 if(cmdline_buf == NULL)
2010 {
2011 at_print(AT_ERR,"malloc cmdline_buf fail.\n");
2012 return -1;
2013 }
xf.lie31de8b2023-12-26 23:38:58 -08002014 memset(cmdline_buf,0,CMDLINE_MAX_SIZE);
xf.liaa4d92f2023-09-13 00:18:58 -07002015 //²éÕÒcmdlineÖеÄEnhancedSecurityÊÇ·ñ´æÔÚ
2016 cmdline_fd = open("/proc/cmdline", O_RDONLY);
2017 if (cmdline_fd < 0) {
2018 at_print(AT_ERR,"open %s fail.\n","/proc/cmdline");
xf.li9d1a0e12023-09-20 01:43:20 -07002019 free(cmdline_buf);
xf.liaa4d92f2023-09-13 00:18:58 -07002020 return -1;
2021 }
xf.lie31de8b2023-12-26 23:38:58 -08002022 ret_size = read(cmdline_fd, cmdline_buf, CMDLINE_MAX_SIZE - 1);
xf.liaa4d92f2023-09-13 00:18:58 -07002023 if(ret_size <= 0)
2024 {
2025 at_print(AT_ERR,"read /proc/cmdline fail.\n");
2026 close(cmdline_fd);
xf.li9d1a0e12023-09-20 01:43:20 -07002027 free(cmdline_buf);
xf.liaa4d92f2023-09-13 00:18:58 -07002028 return -1;
2029 }
2030 close(cmdline_fd);
2031 temp = strstr(cmdline_buf,"EnhancedSecurity=");
2032 if(temp == NULL)
2033 {
2034 at_print(AT_ERR,"can not find EnhancedSecurity=\n");
xf.li9d1a0e12023-09-20 01:43:20 -07002035 free(cmdline_buf);
xf.liaa4d92f2023-09-13 00:18:58 -07002036 return -1;
2037 }
2038 temp = temp + strlen("EnhancedSecurity=");
2039 if(temp == NULL)
2040 {
2041 at_print(AT_ERR,"temp = NULL\n");
xf.li9d1a0e12023-09-20 01:43:20 -07002042 free(cmdline_buf);
xf.liaa4d92f2023-09-13 00:18:58 -07002043 return -1;
2044 }
2045 if(*temp == '0')
2046 {
xf.li9d1a0e12023-09-20 01:43:20 -07002047 free(cmdline_buf);
xf.liaa4d92f2023-09-13 00:18:58 -07002048 return 0;
2049 }
2050 else if(*temp == '1')
2051 {
2052 at_print(AT_ERR,"EnhancedSecurity=1\n");
xf.li9d1a0e12023-09-20 01:43:20 -07002053 free(cmdline_buf);
xf.liaa4d92f2023-09-13 00:18:58 -07002054 return 1;
2055 }
2056 else
2057 {
xf.li9d1a0e12023-09-20 01:43:20 -07002058 free(cmdline_buf);
xf.liaa4d92f2023-09-13 00:18:58 -07002059 return -1;
2060 }
2061}
2062
2063
lh9ed821d2023-04-07 01:36:19 -07002064int write_security_info(int at_fd, char *at_paras, void **res_msg, int *res_msglen)
2065{
2066 UINT32 pubKeyHash[4] = {0};
2067 UINT32 secureFlag = 0xFF;
2068 T_ZDrvEfuse_Secure efuseInfo = {{0}};
2069 char strValue[16];
2070 char strLog[256] = {0};
2071 md5_ctx stStc;
2072 int i;
2073 int efuse_fd = -1;
lh9ed821d2023-04-07 01:36:19 -07002074
xf.liaa4d92f2023-09-13 00:18:58 -07002075 UINT32 pubKeyHash_otp[8] = {0};
2076 UINT32 secureFlag_otp = 0x00;
2077 T_ZDrvOtp_Secure otpInfo = {{0}};
2078 int otp_fd = -1;
2079 int is_Enhanced_Security = -1;
2080
2081 is_Enhanced_Security = IsEnhancedSecurity();
2082 at_print(AT_ERR,"is_Enhanced_Security = %d.\n",is_Enhanced_Security);
2083 if(is_Enhanced_Security == -1)
2084 {
2085 at_print(AT_ERR,"IsEnhancedSecurity() fail.\n");
2086 *res_msg = at_err_build(ATERR_PROC_FAILED);
2087 *res_msglen = strlen(*res_msg);
2088 return AT_END;
2089 }
2090
lh9ed821d2023-04-07 01:36:19 -07002091 /*************************»ñÈ¡¹«Ô¿hash**************************/
2092 // »ñÈ¡¹«Ô¿
2093 efuse_fd = open("/dev/efuse", O_RDWR);
2094 if (efuse_fd < 0) {
2095 at_print(AT_ERR,"open %s fail.\n","/dev/efuse");
2096 *res_msg = at_err_build(ATERR_PROC_FAILED);
2097 *res_msglen = strlen(*res_msg);
2098 return AT_END;
2099 }
2100
xf.liaa4d92f2023-09-13 00:18:58 -07002101 at_print(AT_ERR,"open %s success.\n","/dev/efuse");
2102
lh9ed821d2023-04-07 01:36:19 -07002103 if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuseInfo)!= 0)
2104 {
2105 at_print(AT_ERR,"ioctl: EFUSE_GET_DATA fail.\n");
2106 *res_msg = at_err_build(ATERR_PROC_FAILED);
2107 *res_msglen = strlen(*res_msg);
2108 close(efuse_fd);
2109 return AT_END;
2110 }
xf.liaa4d92f2023-09-13 00:18:58 -07002111 at_print(AT_ERR, "security flag in efuse: %08X\n", efuseInfo.secureFlag);
2112
2113 //ÅжÏefuseÀïÃæµÄ¹«Ô¿ÊÇ·ñºÏ·¨£¬Èç¹ûÊÇÈ«0£¬Ö±½ÓÍ˳ö
2114 for (i = 0; i < sizeof(efuseInfo.pubKeyRsaE)/sizeof(UINT32); i++)
2115 {
2116 if(efuseInfo.pubKeyRsaE[i] != 0)
2117 {
2118 break;
2119 }
2120 }
2121 if(i == sizeof(efuseInfo.pubKeyRsaE)/sizeof(UINT32))
2122 {
2123 at_print(AT_ERR,"efuse pubkey E is all zero.\n");
2124 *res_msg = at_err_build(ATERR_PROC_FAILED);
2125 *res_msglen = strlen(*res_msg);
2126 close(efuse_fd);
2127 return AT_END;
2128 }
2129
2130 for (i = 0; i < sizeof(efuseInfo.pubKeyRsaN)/sizeof(UINT32); i++)
2131 {
2132 if(efuseInfo.pubKeyRsaN[i] != 0)
2133 {
2134 break;
2135 }
2136 }
2137 if(i == sizeof(efuseInfo.pubKeyRsaN)/sizeof(UINT32))
2138 {
2139 at_print(AT_ERR,"efuse pubkey N is all zero.\n");
2140 *res_msg = at_err_build(ATERR_PROC_FAILED);
2141 *res_msglen = strlen(*res_msg);
2142 close(efuse_fd);
2143 return AT_END;
2144 }
2145
2146
2147 // ´òÓ¡¹«Ô¿
xf.li9d1a0e12023-09-20 01:43:20 -07002148 #if 0
xf.liaa4d92f2023-09-13 00:18:58 -07002149 strLog[0] = '\0';
2150 for (i = 0; i < 16; i++)
2151 {
2152 sprintf(strValue, "%08lX", efuseInfo.pubKeyRsaE[i]);
2153 strcat(strLog, strValue);
2154 }
2155
2156 at_print(AT_ERR, "efuse Pubkey E1: %s\n", strLog);
2157
2158 memset(strLog, 0, sizeof(strLog));
2159 for (i = 16; i < 32; i++)
2160 {
2161 sprintf(strValue, "%08lX", efuseInfo.pubKeyRsaE[i]);
2162 strcat(strLog, strValue);
2163 }
2164
2165 at_print(AT_ERR, "efuse Pubkey E2: %s\n", strLog);
2166
2167 memset(strLog, 0, sizeof(strLog));
2168 for (i = 0; i < 16; i++)
2169 {
2170 sprintf(strValue, "%08lX", efuseInfo.pubKeyRsaN[i]);
2171 strcat(strLog, strValue);
2172 }
2173
2174 at_print(AT_ERR, "efuse Pubkey N1: %s\n", strLog);
2175
2176 memset(strLog, 0, sizeof(strLog));
2177 for (i = 16; i < 32; i++)
2178 {
2179 sprintf(strValue, "%08lX", efuseInfo.pubKeyRsaN[i]);
2180 strcat(strLog, strValue);
2181 }
2182
2183 at_print(AT_ERR, "efuse Pubkey N2: %s\n", strLog);
2184 #endif
2185
lh9ed821d2023-04-07 01:36:19 -07002186
2187 // ¼ÆË㹫ԿhashÖµ
2188 md5_init(&stStc);
2189 md5_update(&stStc, (unsigned char *)efuseInfo.pubKeyRsaE, sizeof(efuseInfo.pubKeyRsaE));
2190 md5_update(&stStc, (unsigned char *)efuseInfo.pubKeyRsaN, sizeof(efuseInfo.pubKeyRsaN));
2191 md5_final((UINT8 *)pubKeyHash, &stStc);
2192
2193 // ´òÓ¡¹«Ô¿hash
2194 strLog[0] = '\0';
2195 for (i = 0; i < sizeof(pubKeyHash)/sizeof(UINT32); i++)
2196 {
2197 pubKeyHash[i] = ((pubKeyHash[i] & 0xff000000) >> 24)
2198 | ((pubKeyHash[i] & 0x00ff0000) >> 8)
2199 | ((pubKeyHash[i] & 0x0000ff00) << 8)
2200 | ((pubKeyHash[i] & 0x000000ff) << 24) ;
2201
2202 sprintf(strValue, "%08lX", pubKeyHash[i]);
2203 strcat(strLog, strValue);
2204 }
2205
xf.li9d1a0e12023-09-20 01:43:20 -07002206 at_print(AT_ERR, "efuse Public key hash: %s\n", strLog);
lh9ed821d2023-04-07 01:36:19 -07002207
2208 /*************************½«°²È«ÐÅϢдÈëefuse**************************/
lh9ed821d2023-04-07 01:36:19 -07002209 if (memcmp(efuseInfo.pubKeyHash, pubKeyHash, sizeof(pubKeyHash)) != 0)
2210 {
2211 // ¹«Ô¿hashֵдÈëefuse
2212 if (ioctl(efuse_fd , EFUSE_SET_PUB_KEY_HASH, pubKeyHash) != 0)
2213 {
xf.liaa4d92f2023-09-13 00:18:58 -07002214 at_print(AT_ERR, "Write public key hash to efuse fail!\n");
lh9ed821d2023-04-07 01:36:19 -07002215 *res_msg = at_err_build(ATERR_PROC_FAILED);
2216 *res_msglen = strlen(*res_msg);
2217 close(efuse_fd);
2218 return AT_END;
2219 }
2220 else
2221 {
xf.liaa4d92f2023-09-13 00:18:58 -07002222 at_print(AT_ERR, "Write public key hash to efuse success!\n");
lh9ed821d2023-04-07 01:36:19 -07002223 }
2224 }
2225 else
2226 {
xf.li9d1a0e12023-09-20 01:43:20 -07002227 at_print(AT_ERR, "efuse Public key's hash value already exists!\n");
lh9ed821d2023-04-07 01:36:19 -07002228 }
xf.liaa4d92f2023-09-13 00:18:58 -07002229
2230 /*************************ÅжÏдÈëµÄ¹«Ô¿hashÖµÊÇ·ñÕýÈ·**************************/
2231 // ´Óefuse¶ÁÈ¡
2232 memset(&efuseInfo, 0, sizeof(efuseInfo));
2233 if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuseInfo)!= 0)
2234 {
2235 at_print(AT_ERR,"ioctl: EFUSE_GET_DATA fail.\n");
2236 *res_msg = at_err_build(ATERR_PROC_FAILED);
2237 *res_msglen = strlen(*res_msg);
2238 close(efuse_fd);
2239 return AT_END;
2240 }
2241 if (memcmp(efuseInfo.pubKeyHash, pubKeyHash, sizeof(pubKeyHash)) != 0)
2242 {
xf.li9d1a0e12023-09-20 01:43:20 -07002243 at_print(AT_ERR, "efuse Public key hash is not consistent!\n");
xf.liaa4d92f2023-09-13 00:18:58 -07002244 *res_msg = at_err_build(ATERR_PROC_FAILED);
2245 *res_msglen = strlen(*res_msg);
2246 close(efuse_fd);
2247 return AT_END;
2248 }
xf.liaa4d92f2023-09-13 00:18:58 -07002249
2250 if(is_Enhanced_Security == 1)
2251 {
2252 /*************************»ñÈ¡¹«Ô¿hash**************************/
2253 // »ñÈ¡¹«Ô¿
2254 otp_fd = open("/dev/otp", O_RDWR);
2255 if (otp_fd < 0) {
2256 at_print(AT_ERR,"open %s fail.\n","/dev/otp");
2257 *res_msg = at_err_build(ATERR_PROC_FAILED);
2258 *res_msglen = strlen(*res_msg);
xf.lie31de8b2023-12-26 23:38:58 -08002259 close(efuse_fd);
xf.liaa4d92f2023-09-13 00:18:58 -07002260 return AT_END;
2261 }
2262 at_print(AT_ERR,"open %s success.\n","/dev/otp");
lh9ed821d2023-04-07 01:36:19 -07002263
xf.liaa4d92f2023-09-13 00:18:58 -07002264 if(ioctl(otp_fd , OTP_GET_DATA, &otpInfo)!= 0)
2265 {
2266 at_print(AT_ERR,"ioctl: OTP_GET_DATA fail.\n");
2267 *res_msg = at_err_build(ATERR_PROC_FAILED);
2268 *res_msglen = strlen(*res_msg);
2269 close(otp_fd);
xf.lie31de8b2023-12-26 23:38:58 -08002270 close(efuse_fd);
xf.liaa4d92f2023-09-13 00:18:58 -07002271 return AT_END;
2272 }
2273
2274 at_print(AT_ERR, "security flag in otp: %08X\n", otpInfo.secureFlag);
lh9ed821d2023-04-07 01:36:19 -07002275
xf.liaa4d92f2023-09-13 00:18:58 -07002276 // ´òÓ¡¹«Ô¿
xf.li9d1a0e12023-09-20 01:43:20 -07002277 #if 0
xf.liaa4d92f2023-09-13 00:18:58 -07002278 strLog[0] = '\0';
2279 for (i = 0; i < 16; i++)
2280 {
2281 sprintf(strValue, "%08lX", otpInfo.pubKey[i]);
2282 strcat(strLog, strValue);
2283 }
2284
2285 at_print(AT_ERR, "OTP Public key1: %s\n", strLog);
2286
2287 memset(strLog, 0, sizeof(strLog));
2288 for (i = 16; i < 32; i++)
2289 {
2290 sprintf(strValue, "%08lX", otpInfo.pubKey[i]);
2291 strcat(strLog, strValue);
2292 }
2293
2294 at_print(AT_ERR, "OTP Public key2: %s\n", strLog);
2295
2296 memset(strLog, 0, sizeof(strLog));
2297 for (i = 32; i < 48; i++)
2298 {
2299 sprintf(strValue, "%08lX", otpInfo.pubKey[i]);
2300 strcat(strLog, strValue);
2301 }
2302
2303 at_print(AT_ERR, "OTP Public key3: %s\n", strLog);
2304
2305 memset(strLog, 0, sizeof(strLog));
2306 for (i = 48; i < 64; i++)
2307 {
2308 sprintf(strValue, "%08lX", otpInfo.pubKey[i]);
2309 strcat(strLog, strValue);
2310 }
2311
2312 at_print(AT_ERR, "OTP Public key4: %s\n", strLog);
2313
2314 memset(strLog, 0, sizeof(strLog));
2315 for (i = 64; i < 80; i++)
2316 {
2317 sprintf(strValue, "%08lX", otpInfo.pubKey[i]);
2318 strcat(strLog, strValue);
2319 }
2320
2321 at_print(AT_ERR, "OTP Public key5: %s\n", strLog);
2322
2323 memset(strLog, 0, sizeof(strLog));
2324 for (i = 80; i < sizeof(otpInfo.pubKey)/sizeof(UINT32); i++)
2325 {
2326 sprintf(strValue, "%08lX", otpInfo.pubKey[i]);
2327 strcat(strLog, strValue);
2328 }
2329
2330 at_print(AT_ERR, "OTP Public key6: %s\n", strLog);
2331 #endif
2332 //¼ÆË㹫ԿhashÖµ
2333 StrSHA256((const unsigned char*)otpInfo.pubKey, sizeof(otpInfo.pubKey), (unsigned char*)pubKeyHash_otp);
2334 // ´òÓ¡¹«Ô¿hash
2335 memset(strLog, 0, sizeof(strLog));
2336 for (i = 0; i < sizeof(pubKeyHash_otp)/sizeof(UINT32); i++)
2337 {
2338 sprintf(strValue, "%08lX", pubKeyHash_otp[i]);
2339 strcat(strLog, strValue);
2340 }
2341
2342 at_print(AT_ERR, "OTP Public key hash: %s\n", strLog);
2343
xf.liaa4d92f2023-09-13 00:18:58 -07002344 /*************************½«°²È«ÐÅϢдÈëotp**************************/
2345
2346 if (memcmp(otpInfo.pubKeyHash, pubKeyHash_otp, sizeof(pubKeyHash_otp)) != 0)
2347 {
2348 // ¹«Ô¿hashֵдÈëotp
2349 if (ioctl(otp_fd , OTP_SET_PUB_KEY_HASH, pubKeyHash_otp) != 0)
2350 {
2351 at_print(AT_ERR, "Write public key hash to otp fail!\n");
2352 *res_msg = at_err_build(ATERR_PROC_FAILED);
2353 *res_msglen = strlen(*res_msg);
2354 close(otp_fd);
xf.lie31de8b2023-12-26 23:38:58 -08002355 close(efuse_fd);
xf.liaa4d92f2023-09-13 00:18:58 -07002356 return AT_END;
2357 }
2358 else
2359 {
xf.li9d1a0e12023-09-20 01:43:20 -07002360 at_print(AT_ERR, "Write public key hash to otp success!\n");
xf.liaa4d92f2023-09-13 00:18:58 -07002361 }
2362 }
2363 else
2364 {
xf.li9d1a0e12023-09-20 01:43:20 -07002365 at_print(AT_ERR, "Public key's hash value in otp already exists!\n");
xf.liaa4d92f2023-09-13 00:18:58 -07002366 }
2367
2368 /*************************ÅжÏдÈëµÄ¹«Ô¿hashÖµÊÇ·ñÕýÈ·**************************/
2369 // ´Óotp¶ÁÈ¡
2370 memset(&otpInfo, 0, sizeof(otpInfo));
2371 if(ioctl(otp_fd , OTP_GET_DATA, &otpInfo)!= 0)
2372 {
2373 at_print(AT_ERR,"ioctl: OTP_GET_DATA fail.\n");
2374 *res_msg = at_err_build(ATERR_PROC_FAILED);
2375 *res_msglen = strlen(*res_msg);
2376 close(otp_fd);
xf.lie31de8b2023-12-26 23:38:58 -08002377 close(efuse_fd);
xf.liaa4d92f2023-09-13 00:18:58 -07002378 return AT_END;
2379 }
2380 //±£Ö¤Ç°Ã湫Կhashֵд³É¹¦ÁË£¬ÔÙдÈ밲ȫboot flag
2381 if (memcmp(otpInfo.pubKeyHash, pubKeyHash_otp, sizeof(pubKeyHash_otp)) != 0)
2382 {
2383 at_print(AT_ERR, "Public key hash in otp is not consistent!\n");
2384 *res_msg = at_err_build(ATERR_PROC_FAILED);
2385 *res_msglen = strlen(*res_msg);
2386 close(otp_fd);
xf.lie31de8b2023-12-26 23:38:58 -08002387 close(efuse_fd);
xf.liaa4d92f2023-09-13 00:18:58 -07002388 return AT_END;
2389 }
xf.liaa4d92f2023-09-13 00:18:58 -07002390
xf.li9d1a0e12023-09-20 01:43:20 -07002391 /*otpInfo.secureFlag×îºóÒ»¸ö×Ö½ÚÊǰ²È«Ê¹ÄܱêÖ¾*/
xf.liaa4d92f2023-09-13 00:18:58 -07002392
2393 if ((otpInfo.secureFlag&0xff) != secureFlag_otp)
2394 {
2395 // ʹÄܱêʶλдÈëotp
2396 if (ioctl(otp_fd , OTP_SET_SECURE_EN, &secureFlag_otp) != 0)
2397 {
2398 at_print(AT_ERR, "Write security flag to otp fail!\n");
2399 *res_msg = at_err_build(ATERR_PROC_FAILED);
2400 *res_msglen = strlen(*res_msg);
2401 close(otp_fd);
xf.lie31de8b2023-12-26 23:38:58 -08002402 close(efuse_fd);
xf.liaa4d92f2023-09-13 00:18:58 -07002403 return AT_END;
2404 }
2405 else
2406 {
xf.li9d1a0e12023-09-20 01:43:20 -07002407 at_print(AT_ERR, "Write security flag to otp success!\n");
xf.liaa4d92f2023-09-13 00:18:58 -07002408 }
2409 }
2410 else
2411 {
xf.li9d1a0e12023-09-20 01:43:20 -07002412 at_print(AT_ERR, "Secure flag in otp already exists!\n");
xf.liaa4d92f2023-09-13 00:18:58 -07002413 }
2414
2415 /*************************ÅжÏдÈëµÄsecure flagÊÇ·ñÕýÈ·**************************/
2416 // ´Óotp¶ÁÈ¡
2417 memset(&otpInfo, 0, sizeof(otpInfo));
2418 if(ioctl(otp_fd , OTP_GET_DATA, &otpInfo)!= 0)
2419 {
2420 at_print(AT_ERR,"ioctl: OTP_GET_DATA fail.\n");
2421 *res_msg = at_err_build(ATERR_PROC_FAILED);
2422 *res_msglen = strlen(*res_msg);
2423 close(otp_fd);
xf.lie31de8b2023-12-26 23:38:58 -08002424 close(efuse_fd);
xf.liaa4d92f2023-09-13 00:18:58 -07002425 return AT_END;
2426 }
2427
xf.li9d1a0e12023-09-20 01:43:20 -07002428 close(otp_fd);
2429
2430 if ((otpInfo.secureFlag&0xff) != secureFlag_otp)
xf.liaa4d92f2023-09-13 00:18:58 -07002431 {
xf.li9d1a0e12023-09-20 01:43:20 -07002432 at_print(AT_ERR, "Security flag(%#08X) in otp is not consistent!\n", otpInfo.secureFlag);
xf.liaa4d92f2023-09-13 00:18:58 -07002433 *res_msg = at_err_build(ATERR_PROC_FAILED);
2434 *res_msglen = strlen(*res_msg);
xf.lie31de8b2023-12-26 23:38:58 -08002435 close(efuse_fd);
xf.li9d1a0e12023-09-20 01:43:20 -07002436 return AT_END;
xf.liaa4d92f2023-09-13 00:18:58 -07002437 }
xf.liaa4d92f2023-09-13 00:18:58 -07002438 }
xf.li9d1a0e12023-09-20 01:43:20 -07002439
2440 //×îºóдefuse°²È«flag
2441 /*efuseInfo.secureFlagÇ°Ãæ3¸ö×Ö½ÚÊÇchip flag,×îºóÒ»¸ö×Ö½ÚÊǰ²È«Ê¹ÄܱêÖ¾*/
2442
2443 if ((efuseInfo.secureFlag&0xff) != secureFlag)
2444 {
2445 // ʹÄܱêʶλдÈëefuse
2446 if (ioctl(efuse_fd , EFUSE_SET_SECURE_EN, &secureFlag) != 0)
2447 {
2448 at_print(AT_ERR, "Write security flag to efuse fail!\n");
2449 *res_msg = at_err_build(ATERR_PROC_FAILED);
2450 *res_msglen = strlen(*res_msg);
2451 close(efuse_fd);
2452 return AT_END;
2453 }
2454 else
2455 {
2456 at_print(AT_ERR, "Write security flag to efuse success!\n");
2457 }
2458 }
2459 else
2460 {
2461 at_print(AT_ERR, "Secure flag in efuse already exists!\n");
2462 }
2463
2464 /*************************ÅжÏдÈëµÄÐÅÏ¢ÊÇ·ñÕýÈ·**************************/
2465 // ´Óefuse¶ÁÈ¡
2466 memset(&efuseInfo, 0, sizeof(efuseInfo));
2467 if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuseInfo)!= 0)
2468 {
2469 at_print(AT_ERR,"ioctl: EFUSE_GET_DATA fail.\n");
2470 *res_msg = at_err_build(ATERR_PROC_FAILED);
2471 *res_msglen = strlen(*res_msg);
2472 close(efuse_fd);
2473 return AT_END;
2474 }
2475
2476 close(efuse_fd);
2477
2478 if ((efuseInfo.secureFlag&0xff) != secureFlag)
2479 {
2480 at_print(AT_ERR, "Security flag(%#08X) in efuse is not consistent!\n", efuseInfo.secureFlag);
2481 *res_msg = at_err_build(ATERR_PROC_FAILED);
2482 *res_msglen = strlen(*res_msg);
2483 return AT_END;
2484 }
2485
2486 *res_msg = at_query_result_build("write security infomation", NULL);
2487 *res_msglen = strlen(*res_msg);
2488 return AT_END;
lh9ed821d2023-04-07 01:36:19 -07002489}
xf.liaa4d92f2023-09-13 00:18:58 -07002490
2491int read_security_info(int at_fd, char *at_paras, void **res_msg, int *res_msglen)
2492{
2493 char strValue[16];
2494 char strLog[256] = {0};
2495 int i;
2496 int ret = 0;
2497 T_ZDrvEfuse_Secure efuseInfo = {{0}};
2498 int efuse_fd = -1;
2499
2500 T_ZDrvOtp_Secure otpInfo = {{0}};
2501 int otp_fd = -1;
2502 int is_Enhanced_Security = -1;
2503
2504 is_Enhanced_Security = IsEnhancedSecurity();
2505 at_print(AT_ERR,"is_Enhanced_Security = %d.\n",is_Enhanced_Security);
2506 if(is_Enhanced_Security == -1)
2507 {
2508 at_print(AT_ERR,"IsEnhancedSecurity() fail.\n");
2509 *res_msg = at_err_build(ATERR_PROC_FAILED);
2510 *res_msglen = strlen(*res_msg);
2511 return AT_END;
2512 }
2513
2514 efuse_fd = open("/dev/efuse", O_RDWR);
2515 if (efuse_fd < 0)
2516 {
2517 at_print(AT_ERR,"open %s fail.\n","/dev/efuse");
2518 *res_msg = at_err_build(ATERR_PROC_FAILED);
2519 *res_msglen = strlen(*res_msg);
2520 return AT_END;
2521 }
2522
2523 at_print(AT_ERR,"open %s success.\n","/dev/efuse");
2524
2525 // ´Óefuse¶ÁÈ¡
2526 if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuseInfo)!= 0)
2527 {
2528 at_print(AT_ERR,"ioctl: EFUSE_GET_DATA fail.\n");
2529 *res_msg = at_err_build(ATERR_PROC_FAILED);
2530 *res_msglen = strlen(*res_msg);
2531 close(efuse_fd);
2532 return AT_END;
2533 }
2534 else
2535 {
2536 at_print(AT_ERR,"ioctl: EFUSE_GET_DATA success.\n");
2537 strLog[0] = '\0';
2538 sprintf(strValue, "%02X,", efuseInfo.secureFlag&0xFF);
2539 strcat(strLog, strValue);
2540 for (i = 0; i < sizeof(efuseInfo.pubKeyHash)/sizeof(UINT32); i++)
2541 {
2542 sprintf(strValue, "%08lX", efuseInfo.pubKeyHash[i]);
2543 strcat(strLog, strValue);
2544 }
2545 at_print(AT_ERR, "Secure Flag,Public key hash: %s\n", strLog);
2546 close(efuse_fd);
2547 if(is_Enhanced_Security == 0)
2548 {
2549 *res_msg = at_query_result_build("read security information", strLog);
2550 *res_msglen = strlen(*res_msg);
2551 return AT_END;
2552 }
2553 }
2554
xf.li9d1a0e12023-09-20 01:43:20 -07002555 if(is_Enhanced_Security == 1)
xf.liaa4d92f2023-09-13 00:18:58 -07002556 {
2557 otp_fd = open("/dev/otp", O_RDWR);
2558 if (otp_fd < 0)
2559 {
2560 at_print(AT_ERR,"open %s fail.\n","/dev/otp");
2561 *res_msg = at_err_build(ATERR_PROC_FAILED);
2562 *res_msglen = strlen(*res_msg);
2563 return AT_END;
2564 }
2565
2566 at_print(AT_ERR,"open %s success.\n","/dev/otp");
2567
2568 // ´Óotp¶ÁÈ¡
2569 if(ioctl(otp_fd , OTP_GET_DATA, &otpInfo)!= 0)
2570 {
2571 at_print(AT_ERR,"ioctl: OTP_GET_DATA fail.\n");
2572 *res_msg = at_err_build(ATERR_PROC_FAILED);
2573 *res_msglen = strlen(*res_msg);
2574 close(otp_fd);
2575 return AT_END;
2576 }
2577 else
2578 {
2579 memset(strLog, 0, sizeof(strLog));
2580 sprintf(strValue, "%02X,", efuseInfo.secureFlag&0xFF);
2581 strcat(strLog, strValue);
2582 for (i = 0; i < sizeof(otpInfo.pubKeyHash)/sizeof(UINT32); i++)
2583 {
2584 sprintf(strValue, "%08lX", otpInfo.pubKeyHash[i]);
2585 strcat(strLog, strValue);
2586 }
2587 at_print(AT_ERR, "Secure Flag,Public key hash: %s\n", strLog);
2588 *res_msg = at_query_result_build("read security information", strLog);
2589 *res_msglen = strlen(*res_msg);
2590 close(otp_fd);
2591 return AT_END;
2592 }
2593 }
xf.liaa4d92f2023-09-13 00:18:58 -07002594
2595}
2596
xf.li9d1a0e12023-09-20 01:43:20 -07002597#ifdef USE_NVRO_BACKUP
2598int backup_nvro_func(int at_fd, char *at_paras, void **res_msg, int *res_msglen)
2599{
2600 unsigned int ret = CPNV_ERROR;
2601
2602 ret = cpnv_NvroBackup();
2603 if (CPNV_ERROR== ret)
2604 {
2605 at_print(AT_ERR,"nvro backup failed\n");
2606 *res_msg = at_err_build(ATERR_PROC_FAILED);
2607 }
2608 else
2609 {
2610 at_print(AT_ERR, "nvro backup success\n");
2611 *res_msg = at_ok_build();
2612 }
2613
2614 *res_msglen = strlen(*res_msg);
2615 return AT_END;
2616}
2617#endif
2618
2619
xf.liaa4d92f2023-09-13 00:18:58 -07002620
lh9ed821d2023-04-07 01:36:19 -07002621/*
2622int auth_device_key(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
2623{
2624 char *at_str = NULL;
2625
2626 at_print(AT_ERR,"at_paras=%s\n",at_paras);
2627
2628 at_str = at_paras;
2629 char seed[] = SEED;
2630 auth_device_key_result = verify_device_key(at_str,strlen(at_str),seed,strlen(seed));
2631 at_print(AT_ERR,"auth_device_key_result=%d\n",auth_device_key_result);
2632
2633 if (auth_device_key_result == 1)
2634 {
2635 *res_msg = at_ok_build();
2636 }
2637 else
2638 {
2639 at_print(AT_ERR,"verify device key fail !\n");
2640 *res_msg = at_err_build(ATERR_PROC_FAILED);
2641 }
2642 *res_msglen = strlen(*res_msg);
2643
2644 return AT_END;
2645}
2646*/
2647
2648int ext_amt_regist(void)
2649{
2650 if(!ext_is_usermode())
2651 {
2652 register_serv_func2("MODIMEI=",0,0,0,imeiWrite_act_func,NULL);
2653 register_serv_func2("PHONEMODE=",0,0,0,zphone_mode_set_req_act, 0);
2654 register_serv_func("ramdump",0,ext_ramdump_func);
2655 // дÈ밲ȫÐÅÏ¢
2656 register_serv_func2("WSCYINFO",0,0,0,write_security_info,NULL);
2657 }
2658 register_serv_func2("RKEYDC=",0,0,0,rkeydc_act_func,NULL);
2659 register_serv_func2("ZPOWEROFF",0,0,0,poweroff_act_func,NULL);
2660 register_serv_func2("PLATFORM?",0,0,0,chip_platform_read_act_func,NULL);
2661 register_serv_func2("READIMEI",0,0,0,imeiRead_act_func,NULL);
2662 register_serv_func2("READIMEI?",0,0,0,imeiRead_act_func,NULL);
2663 register_serv_func2("SSID?",0,0,0,ssidRead_act_func,NULL);
2664 register_serv_func2("SSID=",0,0,0,ssidWrite_act_func,NULL);
2665 register_serv_func2("ZVERSIONTYPE=",0,0,0,versionTypeSet_act_func,NULL);
2666 register_serv_func2("MAC?",0,0,0,macRead_act_func,NULL);
2667 register_serv_func2("MAC=",0,0,0,macWrite_act_func,NULL);
2668 register_serv_func2("WIFIKEY?",0,0,0,wifikeyRead_act_func,NULL);
2669 register_serv_func2("WIFIKEY=",0,0,0,wifikeyWrite_act_func,NULL);
2670 register_serv_func2("ETHMAC?",0,0,0,rj45MacAddrRead_act_func,NULL);
2671 register_serv_func2("ETHMAC=",0,0,0,rj45MacAddWrite_act_func,NULL);
2672 register_serv_func2("MAC2?",0,0,0,mac2Read_act_func,NULL);
2673 register_serv_func2("MAC2=",0,0,0,mac2Write_act_func,NULL);
2674 register_serv_func2("USBMAC?",0,0,0,usbmacRead_act_func,NULL);
2675 register_serv_func2("USBMAC=",0,0,0,usbmacWrite_act_func,NULL);
2676 register_serv_func2("GMAC?",0,0,0,gmacRead_act_func,NULL);
2677 register_serv_func2("GMAC=",0,0,0,gmacWrite_act_func,NULL);
2678 register_serv_func2("BATDET?",0,0,0,batdetRead_act_func,NULL);
2679 register_serv_func2("BATDET=",0,0,0,batdetWrite_act_func,NULL);
2680 register_serv_func2("MSN?",0,0,0,msnRead_act_func,NULL);
2681 register_serv_func2("MSN=",0,0,0,msnWrite_act_func,NULL);
2682 register_serv_func2("RTESTINFO",0,0,0,testInfoRead_act_func,NULL);
2683 register_serv_func2("ZAMTMODE=",0,0,0,closeAutoInd_act_func,NULL);
2684
2685 //Çл»Õý³£°æ±¾ºÍ´¿modem°æ±¾
2686 register_serv_func2("PHONEMODE?",0,0,0,zphone_mode_query_req_act, 0);
2687
2688 register_serv_func2("ZSOFTRESET",0,0,0,zsoftreset_act_func,NULL);
2689
2690 register_serv_func2("zmode=",0,0,0,zmodeSet_act_func,NULL);
2691 //mdlÓû§Ä£Ê½ÇÐÑз¢Ä£Ê½¼øÈ¨AT+ZAUTH=KEY
2692 //register_serv_func2("ZAUTH=",0,0,0,auth_device_key,NULL);
xf.liaa4d92f2023-09-13 00:18:58 -07002693 register_serv_func2("RSCYINFO",0,0,0,read_security_info,NULL);
2694
xf.li9d1a0e12023-09-20 01:43:20 -07002695 #ifdef USE_NVRO_BACKUP
2696 register_serv_func2("NVROBACKUP",0,0,0,backup_nvro_func,NULL);
2697 #endif
2698
lh9ed821d2023-04-07 01:36:19 -07002699 return 0;
2700}