cameraHelper.h
25.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
#ifndef _CAMERA_HELPER_H
#define _CAMERA_HELPER_H
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "include/include/ScTypeEx.h"
#include "include/include/mxml.h"
#include "include/app/trafficSDKHelper.h"
#include "include/app/characterCoder.h"
#include "include/app/trafficMxml.h"
//删除节点操作的宏
#define DEL_CONFIG_NODE 0
#define DEBUG_SWITCH 0
#if DEBUG_SWITCH
#define tc_printf_debug(fmt,args...) printf(fmt, ##args)
#else
#define tc_printf_debug(fmt,args...) /*do nothing */
#endif
int HexDecode(unsigned char * buf, const char * base64code, int src_len);
/*
* 字符串中解析填充ScSystemTime结构体
*/
int tcString2Time(ScSystemTime *pScTime, char *pValue);
/*
*从HSCConfig中取出Val的xml流,并将gbk的流转换为utf8的流,以便于浏览器显示
*/
int tcGetKeyXmlutf8(char *xmlString, int xmlLen);
/*
*从HSCConfig中取出Att的xml流,并将gbk的流转换为utf8的流,以便于浏览器显示
*/
int tcGetValXmlutf8(char *xmlString, int xmlLen);
/*
* 字符串分析,从形如"root//node1//node2//node3#0"的字符串中
* 解析出key值"root//node1//node2//node3“和类型nValueType=2
*/
int tcAnalysisKeyTypeString(char *sourKeyString, char *outKey, int *valueType);
/*
* 根据key值和类型nValueType来完成config参数的设置
*/
int tcSetValueByKeyType(char* szKey, void *pValue, int nValueType);
void tcTrafficResult(int nResultType, void* pResultData,long nDataLen, unsigned int dwUser);
//封装后的注册回调函数
void tcRegisterCallback();
/*
* 从xml流中删除已经在settingsConfig.xml中出现过的key值,并输出到outXmlBuf中
*/
int tcDelXmlNode(char *inXmlString, char *outXmlBuf, int bufLen, char *iniPath);
ScErr tcAddValueByReferer(const char *refererInfo, HttpConn* curConn);
ScErr tcAddAttributeByReferer(const char *refererInfo, HttpConn* curConn);
/*************************************************************************************************************************/
int HexDecode(unsigned char * buf, const char * base64code, int src_len)
{
if (src_len == 0)
src_len = strlen(base64code);
int len = 0;
char data[16] = {0};
int i=0;
for(i=0; i<src_len;)
{
data[0] = base64code[i];
data[1] = base64code[i+1];
sscanf(data, "%02X", &buf[len]);
i += 2;
len ++;
}
return len;
}
/*
* 字符串中解析填充ScSystemTime结构体
*/
int tcString2Time(ScSystemTime *pScTime, char *pValue)
{
if(pValue == NULL || pScTime == NULL)
return SC_ErrParamerErr;
//pValue的格式形如 Hour:Minute:Second(固定页面提交),Hour:Minute(高级参数树提交)
char pSrcTime[64] = "";
char *itemTime = NULL;
memcpy(pSrcTime, pValue, strlen(pValue));
char *tmpPt = NULL;
if((itemTime = strtok_r(pSrcTime, ":", &tmpPt)) != NULL)
{
pScTime->wHour = atoi(itemTime);
if((itemTime = strtok_r(NULL, ":", &tmpPt)) != NULL)
{
pScTime->wMinute = atoi(itemTime);
if((itemTime = strtok_r(NULL, ":", &tmpPt)) != NULL)
{
pScTime->wSecond = atoi(itemTime);
}
}
}
pScTime->wYear = 0;
pScTime->wMonth = 0;
pScTime->wDayOfWeek = 0;
pScTime->wDay = 0;
pScTime->wMilliseconds = 0;
return SC_ErrSuccess;
}
/*
*从HSCConfig中取出Val的xml流,并将gbk的流转换为utf8的流,以便于浏览器显示
*/
int tcGetKeyXmlutf8(char *xmlString, int xmlLen)
{
HSCConfig pConfig = getHSCConfig();
if(pConfig == NULL)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: getHSCConfig !!!!!!!!!!!!\n");
return SC_ErrNoResources;
}
int nValLen = 0;
char* xmlValStream = scCfgGetValStream(pConfig, &nValLen);
if(xmlValStream == NULL)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: scCfgGetValStream !!!!!!!!!!!!\n");
return SC_ErrUnknow;
}
#if DEL_CONFIG_NODE
/************************************转码操作*****************************************************/
char utfXmlString[1024*256] = "";
int utfXmlLen = sizeof(utfXmlString);
if(gbk2utf(xmlValStream, strlen(xmlValStream), utfXmlString, utfXmlLen) != 0)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: gbk2uft !!!!!!!!!!!!\n");
return SC_ErrUnknow;
}
tcDelXmlNode(utfXmlString, xmlString, xmlLen, NULL);
#else
if(gbk2utf(xmlValStream, strlen(xmlValStream), xmlString, xmlLen) != 0)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: gbk2uft !!!!!!!!!!!!\n");
return SC_ErrUnknow;
}
#endif
return SC_ErrSuccess;
}
/*
*从HSCConfig中取出Att的xml流,并将gbk的流转换为utf8的流,以便于浏览器显示
*/
int tcGetValXmlutf8(char *xmlString, int xmlLen)
{
HSCConfig pConfig = getHSCConfig();
if(pConfig == NULL)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: getHSCConfig !!!!!!!!!!!!\n");
return SC_ErrNoResources;
}
int nValLen = 0;
char* xmlAttStream = scCfgGetAttStream(hConfig, &nValLen);
if(xmlAttStream == NULL)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: scCfgGetAttStream !!!!!!!!!!!!\n");
return SC_ErrUnknow;
}
#if DEL_CONFIG_NODE
/************************************转码操作*****************************************************/
char utfXmlString[1024*256] = "";
int utfXmlLen = sizeof(utfXmlString);
if(gbk2utf(xmlAttStream, strlen(xmlAttStream), utfXmlString, utfXmlLen) != 0)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: gbk2uft !!!!!!!!!!!!\n");
return SC_ErrUnknow;
}
tcDelXmlNode(utfXmlString, xmlString, xmlLen, NULL);
#else
if(gbk2utf(xmlAttStream, strlen(xmlAttStream), xmlString, xmlLen) != 0)
{
tc_printf_debug("!!!!!!!!!!!! WARNNING: gbk2uft !!!!!!!!!!!!\n");
return SC_ErrUnknow;
}
#endif
return SC_ErrSuccess;
}
/*
* 字符串分析,从形如"root//node1//node2//node3#0"的字符串中
* 解析出key值"root//node1//node2//node3“和类型nValueType=2
*/
int tcAnalysisKeyTypeString(char *sourKeyString, char *outKey, int *valueType)
{
if((sourKeyString == NULL) || (outKey == NULL) || (valueType == NULL))
{
return SC_ErrParamerErr;
}
char *pShape = strrchr(sourKeyString, '#');
if(pShape == NULL)
{
return SC_ErrParamerErr;
}
char intString[4] = "";
memcpy(outKey, sourKeyString, pShape-sourKeyString);
memcpy(intString, pShape+1, strlen(pShape));
*valueType = atoi(intString);
return SC_ErrSuccess;
}
/*
* 根据key值和类型nValueType来完成config参数的设置
*/
int tcSetValueByKeyType(char* szKey, void *pValue, int nValueType)
{
if(szKey == NULL || pValue == NULL)
return SC_ErrParamerErr;
HTrafficSDK pTrafficSDK = NULL;
HSCConfig pConfig = NULL;
if(((pTrafficSDK = getTrafficSDK()) == NULL) || ((pConfig = getHSCConfig()) == NULL))
return SC_ErrNoResources;
//utf8转gbk后再进行设置参数
char gbkKey[256] = "";
char gbkValue[256] = "";
if((utf2gbk(szKey, strlen(szKey), gbkKey, sizeof(gbkKey)) != 0) ||
(utf2gbk(pValue, strlen(pValue), gbkValue, sizeof(gbkValue)) != 0))
{
tc_printf_debug("----------转码失败---------\n");
}
if(nValueType == CT_INT || nValueType == CT_ENUM || nValueType == CT_BOOL)
{
int nInt = atoi((char*)gbkValue);
return TrafficSDK_SetHSCConfigKeyValue(pTrafficSDK, pConfig, gbkKey, &nInt, sizeof(nInt), nValueType, NULL, 0);
}
else if(nValueType == CT_FLOAT)
{
float fFloat = atof((char*)gbkValue);
return TrafficSDK_SetHSCConfigKeyValue(pTrafficSDK, pConfig, gbkKey, &fFloat, sizeof(fFloat), nValueType, NULL, 0);
}
else if(nValueType == CT_STRING)
{
return TrafficSDK_SetHSCConfigKeyValue(pTrafficSDK, pConfig, gbkKey, gbkValue, strlen(gbkValue), nValueType, NULL, 0);
}
else if(nValueType == CT_TIME)
{
ScSystemTime scTime;
memset(&scTime, 0, sizeof(scTime));
if(tcString2Time(&scTime, (char*)gbkValue) == SC_ErrSuccess)
{
return TrafficSDK_SetHSCConfigKeyValue(pTrafficSDK, pConfig, gbkKey, &scTime, sizeof(scTime), nValueType, NULL, 0);
}
return SC_ErrUnknow;
}
return SC_ErrUnknow;
}
void tcTrafficResult(int nResultType, void* pResultData,long nDataLen, unsigned int dwUser)
{
//转码操作gbk->utf8
char outbuf[1024*5] = "";
if(gbk2utf(pResultData, strlen(pResultData), outbuf, sizeof(outbuf)) != 0)
{
tc_printf_debug("----------转码失败---------\n");
}
EnQueue(&trafficQueue, outbuf);
return;
}
/**
* 从xml流中删除已经在settingsConfig.xml中出现过的key值,并输出到outXmlBuf中
* 目前只是删除了"root/基础配置", "root/功能配置", "root/高级配置"
*/
int tcDelXmlNode(char *inXmlString, char *outXmlBuf, int bufLen, char *iniPath)
{
mxml_node_t *xmlRoot = mxmlSAXLoadString(NULL, inXmlString, NULL, NULL, NULL);
// char *delNodeArray[] = {"root/基础配置", "root/功能配置", "root/高级配置"};
char *delNodeArray[] = {"root/基础配置/"};
int nIndex = 0;
int nIndexSize = sizeof(delNodeArray)/sizeof(delNodeArray[0]);
for(nIndex = 0; nIndex < nIndexSize; nIndex++)
{
mxml_node_t *tmpNode = mxmlFindPath(xmlRoot, delNodeArray[nIndex]);
if(tmpNode == NULL)
{
// printf("------Could not found node: %s------\n", szKey);
continue;
}
printf("------DEL node: %s------\n", delNodeArray[nIndex]);
mxmlDelete(tmpNode);
}
mxmlSaveString(xmlRoot, outXmlBuf, bufLen, NULL);
return SC_ErrSuccess;
}
ScErr tcAddValueByReferer(const char *refererInfo, HttpConn* curConn)
{
HTrafficSDK pTrafficSDK = NULL;
HSCConfig pConfig = NULL;
if( ((pTrafficSDK = getTrafficSDK()) == NULL) ||
((pConfig = getHSCConfig()) == NULL) )
{
return SC_ErrNoResources;
}
mxml_node_t *pTrafficMxml = NULL;
if((pTrafficMxml = getTrafficMxml()) == NULL)
{
return SC_ErrUnknow;
}
mxml_node_t *refererNode = NULL;
mxml_node_t *itemConfigNode = NULL;
if((refererNode = mxmlFindElement(pTrafficMxml, pTrafficMxml, refererInfo, NULL, NULL, MXML_DESCEND)) != NULL)
{
itemConfigNode = mxmlGetFirstChild(refererNode);
}
while(itemConfigNode != NULL)
{
if(mxmlGetType(itemConfigNode) == MXML_ELEMENT)
{
const char *keyId = mxmlElementGetAttr(itemConfigNode, "keyId");
const char *keyName = mxmlElementGetAttr(itemConfigNode, "keyName");
const char *valueType = mxmlElementGetAttr(itemConfigNode, "valueType");
const char *keySource = mxmlElementGetAttr(itemConfigNode, "keySource");
if((keyId != NULL) && (keyName != NULL) && (valueType != NULL) && (keySource != NULL))
{
if(strcmp(keySource, "SDK") != 0)
{
//mxmlLoadFile操作gbk格式的文件,会返回空,所以暂时只能自己转码
char gbkKey[256] = "";
char szKey[256] = "";
memcpy(szKey, keyName, strlen(keyName));
if(utf2gbk(szKey, strlen(szKey), gbkKey, sizeof(gbkKey)) == 0) //utf转gbk转码成功
{
int nValueType = atoi(valueType);
if(nValueType == CT_INT)
{
int nInt = 0;
if(scCfgGetAttribValue_int(pConfig, gbkKey, &nInt) == SC_ErrSuccess ||
scCfgGetAttribDefault_int(pConfig, gbkKey, &nInt) == SC_ErrSuccess)
{
tc_printf_debug("----------------------keyName=%s, nValueType=%d, value=%d-------------------------\n", gbkKey, nValueType, nInt);
espSetFeedback(curConn, keyId, "%d", nInt);
}
else
{
tc_printf_debug("----------------------keyName=%s, return NULL -------------------------\n");
espSetFeedback(curConn, keyId, "");
}
}
else if(nValueType == CT_ENUM)
{
int nEnum = 0;
if(scCfgGetAttribValue_enum(pConfig, gbkKey, &nEnum) == SC_ErrSuccess ||
scCfgGetAttribDefault_enum(pConfig, gbkKey, &nEnum) == SC_ErrSuccess)
{
tc_printf_debug("----------------------keyName=%s, nValueType=%d, value=%d-------------------------\n", gbkKey, nValueType, nEnum);
espSetFeedback(curConn, keyId, "%d", nEnum);
}
else
{
tc_printf_debug("----------------------keyName=%s, return NULL -------------------------\n");
espSetFeedback(curConn, keyId, "");
}
}
else if(nValueType == CT_BOOL)
{
int nBool = 0;
if(scCfgGetAttribValue_bool(pConfig, gbkKey, &nBool) == SC_ErrSuccess ||
scCfgGetAttribDefault_bool(pConfig, gbkKey, &nBool) == SC_ErrSuccess)
{
tc_printf_debug("----------------------keyName=%s, nValueType=%d, value=%d-------------------------\n", gbkKey, nValueType, nBool);
espSetFeedback(curConn, keyId, "%d", nBool);
}
else
{
tc_printf_debug("----------------------keyName=%s, return NULL -------------------------\n");
espSetFeedback(curConn, keyId, "");
}
}
else if(nValueType == CT_FLOAT)
{
float fFloat = 0.0f;
if(scCfgGetAttribValue_float(pConfig, gbkKey, &fFloat) == SC_ErrSuccess ||
scCfgGetAttribDefault_float(pConfig, gbkKey, &fFloat) == SC_ErrSuccess)
{
tc_printf_debug("----------------------keyName=%s, nValueType=%d, value=%f-------------------------\n", gbkKey, nValueType, fFloat);
espSetFeedback(curConn, keyId, "%f", fFloat);
}
else
{
tc_printf_debug("----------------------keyName=%s, return NULL -------------------------\n");
espSetFeedback(curConn, keyId, "");
}
}
else if(nValueType == CT_STRING)
{
char sStr[128] = "";
if(scCfgGetAttribValue_string(pConfig, gbkKey, sStr) != SC_ErrSuccess)
{
scCfgGetAttribDefault_string(pConfig, gbkKey, sStr);
}
tc_printf_debug("----------------------keyName=%s, nValueType=%d, value=%s-------------------------\n", gbkKey, nValueType, sStr);
//转码操作gbk->utf8
char outbuf[128] = "";
if(gbk2utf(sStr, strlen(sStr), outbuf, sizeof(outbuf)) != 0)
{
tc_printf_debug("----------转码失败---------\n");
}
//espSetFeedback(curConn, keyId, outbuf);
//espSetFeedback(curConn, keyId,"%s",outbuf);
espSetFeedbackWithType(curConn, keyId,CT_STRING,"%s",outbuf);
}
else if(nValueType == CT_TIME)
{
ScSystemTime scTime;
memset(&scTime, 0, sizeof(scTime));
if(scCfgGetAttribValue_time(pConfig, gbkKey, &scTime) != SC_ErrSuccess)
{
scCfgGetAttribDefault_time(pConfig, gbkKey, &scTime);
}
tc_printf_debug("---------------------Hour:%d, Minute:%d, Second:%d----------------\n", scTime.wHour, scTime.wMinute, scTime.wSecond);
espSetFeedback(curConn, keyId, "%d:%d", scTime.wHour, scTime.wMinute);
}
}
}
else if(strcmp(keySource, "SDK") == 0)
{
//如果是获取IP信息
if(strcmp(keyId, "15") == 0)
{
SysIVENetInfo netInfo;
memset(&netInfo, 0, sizeof(netInfo));
unsigned int valueLen = 0;
if(TrafficSDK_GetData(pTrafficSDK, KEY_GET_NET_INFO, &netInfo, &valueLen, NULL, 0) == SC_ErrSuccess)
{
tc_printf_debug("--------------------------------------------------------------\n");
tc_printf_debug("szIP = %s\n", netInfo.szIP);
tc_printf_debug("szMask = %s\n", netInfo.szMask);
tc_printf_debug("szGateway = %s\n", netInfo.szGateway);
tc_printf_debug("--------------------------------------------------------------\n");
espSetFeedback(curConn, "15", "%s", netInfo.szIP);
espSetFeedback(curConn, "16", "%s", netInfo.szMask);
espSetFeedback(curConn, "17", "%s", netInfo.szGateway);
}
}
else if(strcmp(keyId, "21") == 0)
{
SysIVENetInfo netInfo;
memset(&netInfo, 0, sizeof(netInfo));
unsigned int valueLen = 0;
ScErr errRet;
if((errRet = TrafficSDK_GetData(pTrafficSDK, KEY_GET_OPS_PARENT_IPPORT, &netInfo, &valueLen, NULL, 0)) == SC_ErrSuccess)
{
tc_printf_debug("--------------------------------------------------------------\n");
tc_printf_debug("szIP = %s\n", netInfo.szIP);
tc_printf_debug("nPort = %s\n", netInfo.nPort);
tc_printf_debug("--------------------------------------------------------------\n");
espSetFeedback(curConn, "21", "%s", netInfo.szIP);
espSetFeedback(curConn, "22", "%d", netInfo.nPort);
}
}
else if(strcmp(keyId, "1") == 0)
{
BasicInfo basicInfo;
memset(&basicInfo, 0, sizeof(basicInfo));
unsigned int valenLen = 0;
if(TrafficSDK_GetData(pTrafficSDK, KEY_GET_BASIC_INFO, &basicInfo, &valenLen, NULL, 0) == SC_ErrSuccess)
{
char gbkKey[1024] = "";
char szKey[1024] = "";
memset(gbkKey,0,sizeof(gbkKey));
memset(szKey,0,sizeof(szKey));
strncpy(gbkKey,basicInfo.szAuthorizedStatus,sizeof(gbkKey));
if(gbk2utf(gbkKey, strlen(gbkKey), szKey, sizeof(szKey)) == 0) //utf转gbk转码成功
{
strncpy(basicInfo.szAuthorizedStatus,szKey,sizeof(basicInfo.szAuthorizedStatus));
}
memset(gbkKey,0,sizeof(gbkKey));
memset(szKey,0,sizeof(szKey));
strncpy(gbkKey,basicInfo.szAuthorizedInfo,sizeof(gbkKey));
if(gbk2utf(gbkKey, strlen(gbkKey), szKey, sizeof(szKey)) == 0) //utf转gbk转码成功
{
strncpy(basicInfo.szAuthorizedInfo,szKey,sizeof(basicInfo.szAuthorizedInfo));
}
tc_printf_debug("--------------------------------------------------------------\n");
tc_printf_debug("szResolution = %s\n", basicInfo.szResolution);
tc_printf_debug("szHardwareVersion = %s\n", basicInfo.szHardwareVersion);
tc_printf_debug("szFPGAVersion = %s\n", basicInfo.szFPGAVersion);
tc_printf_debug("szSysVersion = %s\n", basicInfo.szSysVersion);
tc_printf_debug("szBSPVersion = %s\n", basicInfo.szBSPVersion);
tc_printf_debug("szSoftwareVersion = %s\n", basicInfo.szSoftwareVersion);
tc_printf_debug("szAlgVersion = %s\n", basicInfo.szAlgVersion);
tc_printf_debug("szDeviceID = %s\n", basicInfo.szDeviceID);
tc_printf_debug("szAuthorizedStatus = %s\n", basicInfo.szAuthorizedStatus);
tc_printf_debug("szAuthorizedInfo = %s\n", basicInfo.szAuthorizedInfo);
tc_printf_debug("--------------------------------------------------------------\n");
//espSetFeedback(curConn, "0", basicInfo.szResolution);
//espSetFeedback(curConn, "1", basicInfo.szHardwareVersion);
//espSetFeedback(curConn, "2", basicInfo.szFPGAVersion);
//espSetFeedback(curConn, "3", basicInfo.szSysVersion);
//espSetFeedback(curConn, "4", basicInfo.szBSPVersion);
//espSetFeedback(curConn, "5", basicInfo.szSoftwareVersion);
//espSetFeedback(curConn, "6", basicInfo.szAlgVersion);
//espSetFeedback(curConn, "7", basicInfo.szDeviceID);
//espSetFeedback(curConn, "8", basicInfo.szAuthorizedStatus);
//espSetFeedback(curConn, "9", basicInfo.szAuthorizedInfo);
espSetFeedbackWithType(curConn, "0", CT_STRING, "%s", basicInfo.szResolution);
espSetFeedbackWithType(curConn, "1", CT_STRING, "%s", basicInfo.szHardwareVersion);
espSetFeedbackWithType(curConn, "2", CT_STRING, "%s", basicInfo.szFPGAVersion);
espSetFeedbackWithType(curConn, "3", CT_STRING, "%s", basicInfo.szSysVersion);
espSetFeedbackWithType(curConn, "4", CT_STRING, "%s", basicInfo.szBSPVersion);
espSetFeedbackWithType(curConn, "5", CT_STRING, "%s", basicInfo.szSoftwareVersion);
espSetFeedbackWithType(curConn, "6", CT_STRING, "%s", basicInfo.szAlgVersion);
espSetFeedbackWithType(curConn, "7", CT_STRING, "%s", basicInfo.szDeviceID);
espSetFeedbackWithType(curConn, "8", CT_STRING, "%s", basicInfo.szAuthorizedStatus);
espSetFeedbackWithType(curConn, "9", CT_STRING, "%s", basicInfo.szAuthorizedInfo);
espSetFeedbackWithType(curConn, "10", CT_STRING, "%s", basicInfo.szDeviceTypeDesc);
}
}
else if(strcmp(keyId, "146") == 0)
{
StorageDevInfos DevInfo;
memset(&DevInfo, 0, sizeof(DevInfo));
unsigned int valenLen = 0;
if(TrafficSDK_GetData(pTrafficSDK, KEY_GET_STORAGE_DEV_INFO, &DevInfo, &valenLen, NULL, 0) == SC_ErrSuccess)
{
espSetFeedback(curConn, "146", DevInfo.aStorageDevInfo[0].szPath);
if (DevInfo.nDevCount == 1)
{
espSetFeedback(curConn, "146001", "%d", 1);
espSetFeedback(curConn, "147", "%0.2f", DevInfo.aStorageDevInfo[0].dfTotalSize);
espSetFeedback(curConn, "148", "%0.2f", DevInfo.aStorageDevInfo[0].dfLeftSize);
espSetFeedback(curConn, "149", "%0.2f", DevInfo.aStorageDevInfo[0].aPartitionInfo[0].dfTotalSize);
espSetFeedback(curConn, "150", "%0.2f", DevInfo.aStorageDevInfo[0].aPartitionInfo[0].dfLeftSize);
espSetFeedback(curConn, "151", "%0.2f", DevInfo.aStorageDevInfo[0].aPartitionInfo[1].dfTotalSize);
espSetFeedback(curConn, "152", "%0.2f", DevInfo.aStorageDevInfo[0].aPartitionInfo[1].dfLeftSize);
}
else if (DevInfo.nDevCount == 2)
{
espSetFeedback(curConn, "146001", "%d", 2);
float fTotalSize = DevInfo.aStorageDevInfo[0].dfTotalSize + DevInfo.aStorageDevInfo[1].dfTotalSize;
float fTotalLeft = DevInfo.aStorageDevInfo[0].dfLeftSize + DevInfo.aStorageDevInfo[1].dfLeftSize;
espSetFeedback(curConn, "147", "%0.2f", fTotalSize);
espSetFeedback(curConn, "148", "%0.2f", fTotalLeft);
espSetFeedback(curConn, "149", "%0.2f", DevInfo.aStorageDevInfo[0].dfTotalSize);
espSetFeedback(curConn, "150", "%0.2f", DevInfo.aStorageDevInfo[0].dfLeftSize);
espSetFeedback(curConn, "151", "%0.2f", DevInfo.aStorageDevInfo[1].dfTotalSize);
espSetFeedback(curConn, "152", "%0.2f", DevInfo.aStorageDevInfo[1].dfLeftSize);
}
else
{
espSetFeedback(curConn, "146001", "%d", 0);
}
}
}
else if(strcmp(keyId, "920") == 0)
{
SysIVEAdvancedNetInfo netInfo;
memset(&netInfo, 0, sizeof(netInfo));
unsigned int valueLen = 0;
if(TrafficSDK_GetData(pTrafficSDK, KEY_GET_ADVANCED_NET_INFO, &netInfo, &valueLen, NULL, 0) == SC_ErrSuccess)
{
tc_printf_debug("--------------------------------------------------------------\n");
tc_printf_debug("szLocalMAC = %s\n", netInfo.szLocalMAC);
tc_printf_debug("nMTU = %d\n", netInfo.nMTU);
tc_printf_debug("szDNSServer = %s\n", netInfo.szDNSServer);
tc_printf_debug("--------------------------------------------------------------\n");
espSetFeedback(curConn, "920", "%s", netInfo.szLocalMAC);
espSetFeedback(curConn, "921", "%d", netInfo.nMTU);
espSetFeedback(curConn, "922", "%s", netInfo.szDNSServer);
}
}
else if (strcmp(keyId, "112101") == 0)
{
SysIVENetInfo netInfo;//复用一下已有结构体
memset(&netInfo, 0, sizeof(netInfo));
unsigned int valueLen = 0;
if (TrafficSDK_GetData(pTrafficSDK, KEY_3G4G_INFO_GET, &netInfo, &valueLen, NULL, 0) == SC_ErrSuccess)
{
tc_printf_debug("--------------------------------------------------------------\n");
tc_printf_debug("szIP = %s\n", netInfo.szIP);
tc_printf_debug("szMask = %s\n", netInfo.szMask);
tc_printf_debug("--------------------------------------------------------------\n");
espSetFeedback(curConn, "112101", "%s", netInfo.szIP);
espSetFeedback(curConn, "112102", "%s", netInfo.szMask);
}
}
}
}
}
itemConfigNode = mxmlGetNextSibling(itemConfigNode);
}
return SC_ErrSuccess;
}
ScErr tcAddAttributeByReferer(const char *refererInfo, HttpConn* curConn)
{
HTrafficSDK pTrafficSDK = NULL;
HSCConfig pConfig = NULL;
if( ((pTrafficSDK = getTrafficSDK()) == NULL) ||
((pConfig = getHSCConfig()) == NULL) )
{
return SC_ErrNoResources;
}
char rangeBuf[128] = "";
mxml_node_t *pTrafficMxml = NULL;
if((pTrafficMxml = getTrafficMxml()) == NULL)
{
return SC_ErrUnknow;
}
mxml_node_t *refererNode = NULL;
mxml_node_t *itemConfigNode = NULL;
if((refererNode = mxmlFindElement(pTrafficMxml, pTrafficMxml, refererInfo, NULL, NULL, MXML_DESCEND)) != NULL)
{
itemConfigNode = mxmlGetFirstChild(refererNode);
}
while(itemConfigNode != NULL)
{
if(mxmlGetType(itemConfigNode) == MXML_ELEMENT)
{
const char *keyId = mxmlElementGetAttr(itemConfigNode, "keyId");
const char *keyName = mxmlElementGetAttr(itemConfigNode, "keyName");
const char *valueType = mxmlElementGetAttr(itemConfigNode, "valueType");
const char *keySource = mxmlElementGetAttr(itemConfigNode, "keySource");
if((keyId != NULL) && (keyName != NULL) && (valueType != NULL) && (keySource != NULL))
{
if(strcmp(keySource, "Config") == 0)
{
//mxmlLoadFile操作gbk格式的文件,会返回空,所以暂时只能自己转码
char gbkKey[256] = "";
char szKey[256] = "";
memcpy(szKey, keyName, strlen(keyName));
if(utf2gbk(szKey, strlen(szKey), gbkKey, sizeof(gbkKey)) == 0) //utf转gbk转码成功
{
int nValueType = atoi(valueType);
if(nValueType == CT_INT)
{
ScAttribIntRange rangeInt;
memset(&rangeInt, 0, sizeof(rangeInt));
if(scCfgGetAttribRange_int(pConfig, gbkKey, &rangeInt) == SC_ErrSuccess)
{
sprintf(rangeBuf, "范围:%d - %d", rangeInt.nValMin, rangeInt.nValMax);
}
tc_printf_debug("----------------------CT_INT: keyId=%s, rangeBuf=%s-------------------------\n", gbkKey, rangeBuf);
espSetFeedback(curConn, keyId, rangeBuf);
}
else if(nValueType == CT_ENUM)
{
}
else if(nValueType == CT_BOOL)
{
}
else if(nValueType == CT_FLOAT)
{
ScAttribFloatRange rangeFloat;
memset(&rangeFloat, 0, sizeof(rangeFloat));
if(scCfgGetAttribRange_float(pConfig, gbkKey, &rangeFloat) == SC_ErrSuccess)
{
sprintf(rangeBuf, "范围:%f - %f", rangeFloat.fltValMin, rangeFloat.fltValMax);
}
tc_printf_debug("----------------------CT_FLOAT: keyId=%s, rangeBuf=%s-------------------------\n", gbkKey, rangeBuf);
espSetFeedback(curConn, keyId, rangeBuf);
}
else if(nValueType == CT_STRING)
{
int nStrLength = 0;
if(scCfgGetAttribRange_string(pConfig, gbkKey, &nStrLength) == SC_ErrSuccess)
{
sprintf(rangeBuf, "字符串长度限制:%d", nStrLength);
}
tc_printf_debug("----------------------CT_STRING: szKey=%s, rangeBuf=%s-------------------------\n", gbkKey, rangeBuf);
espSetFeedback(curConn, keyId, rangeBuf);
}
else if(nValueType == CT_TIME)
{
}
}
}
}
}
itemConfigNode = mxmlGetNextSibling(itemConfigNode);
}
return SC_ErrSuccess;
}
#endif