正在显示
4 个修改的文件
包含
469 行增加
和
431 行删除
@@ -721,7 +721,7 @@ T_JZsdkReturnCode HalSend_type1Send_Reply_TTS_tone(int Uartport ,int tone) | @@ -721,7 +721,7 @@ T_JZsdkReturnCode HalSend_type1Send_Reply_TTS_tone(int Uartport ,int tone) | ||
721 | //发送语速 | 721 | //发送语速 |
722 | T_JZsdkReturnCode HalSend_type1Send_Reply_TTS_speed(int Uartport ,int speed) | 722 | T_JZsdkReturnCode HalSend_type1Send_Reply_TTS_speed(int Uartport ,int speed) |
723 | { | 723 | { |
724 | - printf("发送音色帧\n"); | 724 | + printf("发送语速帧\n"); |
725 | 725 | ||
726 | unsigned char sendbuf[256]; | 726 | unsigned char sendbuf[256]; |
727 | int send_buf_len; | 727 | int send_buf_len; |
1 | -// /** | ||
2 | -// 方案一:调用该文件中的对外函数输入参数国家码,可能需要更改获取序列号中地区码的部分代码,等待返回值即可,返回值:0 表明国家码与地区码一致。 | ||
3 | -// 方案二:调用该文件中的对外函数输入参数国家码、序列号中的地区码,等待返回值即可。 | ||
4 | -// */ | ||
5 | -// #include "FreeRTOS.h" | ||
6 | -// #include "task.h" | ||
7 | -// #include "Country_Code.h" | ||
8 | -// #include "myflash.h" | ||
9 | -// #include "dji_logger.h" | ||
10 | - | ||
11 | - | ||
12 | - | ||
13 | -// /*____________________________________________________ Country code array module ____________________________________________________*/ | ||
14 | -// #if 1 //国家码 | ||
15 | -// //4个有效数据 | ||
16 | -// uint16_t CN[] = { //中国 | ||
17 | -// 156, //中国大陆 | ||
18 | -// 344, //香港 | ||
19 | -// 446, //澳门 | ||
20 | -// 158, //台湾 | ||
21 | -// }; | ||
22 | -// //37个有效数据(国家码) | ||
23 | -// uint16_t NA[] = { //美洲 | ||
24 | -// 3, //0; 国家码的百位为0~2的数据的位置<_*_*_> | ||
25 | -// 17, //1; 国家码的百位为3~5的数据的位置<_*_*_> | ||
26 | -// 32, //2; 国家码的百位为6~8的数据的位置<_*_*_> | ||
27 | - | ||
28 | -// 13, //3; 国家码的百位为0~2的数据的数量<_*_*_> | ||
29 | -// 28, //4; 安提瓜和巴布达 | ||
30 | -// 44, //5; 巴哈马 | ||
31 | -// 52, //6; 巴巴多斯 | ||
32 | -// 60, //7; 百慕大(英国) | ||
33 | -// 84, //8; 伯利兹 | ||
34 | -// 92, //9; 英属维尔京群岛 | ||
35 | -// 124, //10; 加拿大 | ||
36 | -// 136, //11; 开曼群岛(英国) | ||
37 | -// 188, //12; 哥斯达黎加 | ||
38 | -// 192, //13; 古巴 | ||
39 | -// 212, //14; 多米尼克 | ||
40 | -// 214, //15; 多米尼加 | ||
41 | -// 222, //16; 萨尔瓦多 | ||
42 | - | ||
43 | -// 14, //17; 国家码的百位为3~4的数据的数量<_*_*_> | ||
44 | -// 304, //18; 格陵兰(丹麦) | ||
45 | -// 308, //19; 格林纳达 | ||
46 | -// 312, //20; 瓜德罗普(法国) | ||
47 | -// 320, //21; 危地马拉 | ||
48 | -// 332, //22; 海地 | ||
49 | -// 340, //23; 洪都拉斯 | ||
50 | -// 388, //24; 牙买加 | ||
51 | -// 474, //25; 马提尼克(法国) | ||
52 | -// 484, //26; 墨西哥 | ||
53 | -// 500, //27; 蒙特塞拉特(英国) | ||
54 | -// 530, //28; 荷属安的列斯 | ||
55 | -// 533, //29; 阿鲁巴(荷兰) | ||
56 | -// 558, //30; 尼加拉瓜 | ||
57 | -// 591, //31; 巴拿马 | ||
58 | - | ||
59 | -// 10, //32; 国家码的百位为6~8的数据的数量<_*_*_> | ||
60 | -// 630, //33; 波多黎各(美国) | ||
61 | -// 659, //34; 圣基茨和尼维斯 | ||
62 | -// 660, //35; 安圭拉(英国) | ||
63 | -// 662, //36; 圣卢西亚 | ||
64 | -// 666, //37; 圣皮埃尔和密克隆(法国) | ||
65 | -// 670, //38; 圣文森特和格林纳丁斯 | ||
66 | -// 780, //39; 特立尼达和多巴哥 | ||
67 | -// 796, //40; 特克斯和凯科斯群岛(英国) | ||
68 | -// 840, //41; 美国 | ||
69 | -// 850, //42; 美属维尔京群岛 | ||
70 | -// }; | ||
71 | - | ||
72 | -// //45个数据 | ||
73 | -// uint16_t EU[] = { //欧洲 | ||
74 | -// 3, //0; 国家码的百位为0~2的数据的位置<_*_*_> | ||
75 | -// 19, //1; 国家码的百位为3~5的数据的位置<_*_*_> | ||
76 | -// 36, //2; 国家码的百位为6~8的数据的位置<_*_*_> | ||
77 | - | ||
78 | -// 15, //3; 国家码的百位为0~2的数据的数量<_*_*_> | ||
79 | -// 8, //4; 阿尔巴尼亚 | ||
80 | -// 20, //5; 安道尔 | ||
81 | -// 40, //6; 奥地利 | ||
82 | -// 56, //7; 比利时 | ||
83 | -// 100, //8; 保加利亚 | ||
84 | -// 112, //9; 白俄罗斯 | ||
85 | -// 191, //10; 克罗地亚 | ||
86 | -// 203, //11; 捷克 | ||
87 | -// 208, //12; 丹麦 | ||
88 | -// 233, //13; 爱沙尼亚 | ||
89 | -// 234, //14; 法罗群岛(丹麦) | ||
90 | -// 246, //15; 芬兰 | ||
91 | -// 250, //16; 法国 | ||
92 | -// 276, //17; 德国 | ||
93 | -// 292, //18; 直布罗陀 | ||
94 | - | ||
95 | -// 16, //19; 国家码的百位为3~5的数据的数量<_*_*_> | ||
96 | -// 300, //20; 希腊 | ||
97 | -// 336, //21; 梵蒂冈 | ||
98 | -// 348, //22; 匈牙利 | ||
99 | -// 352, //23; 冰岛 | ||
100 | -// 372, //24; 爱尔兰 | ||
101 | -// 380, //25; 意大利 | ||
102 | -// 428, //26; 拉脱维亚 | ||
103 | -// 438, //27; 列支敦士登 | ||
104 | -// 440, //28; 立陶宛 | ||
105 | -// 442, //29; 卢森堡 | ||
106 | -// 470, //30; 马耳他 | ||
107 | -// 492, //31; 摩纳哥 | ||
108 | -// 498, //32; 摩尔多瓦 | ||
109 | -// 499, //33; 黑山 | ||
110 | -// 528, //34; 荷兰 | ||
111 | -// 578, //35; 挪威 | ||
112 | - | ||
113 | -// 14, //36; 国家码的百位为6~8的数据的数量<_*_*_> | ||
114 | -// 616, //37; 波兰 | ||
115 | -// 620, //38; 葡萄牙 | ||
116 | -// 642, //39; 罗马尼亚 | ||
117 | -// 643, //40; 俄罗斯联邦 | ||
118 | -// 674, //41; 圣马力诺 | ||
119 | -// 688, //42; 塞尔维亚 | ||
120 | -// 703, //43; 斯洛伐克 | ||
121 | -// 705, //44; 斯洛文尼亚 | ||
122 | -// 724, //45; 西班牙 | ||
123 | -// 752, //46; 瑞典 | ||
124 | -// 756, //47; 瑞士 | ||
125 | -// 792, //48; 土耳其欧洲部分 | ||
126 | -// 804, //49; 乌克兰 | ||
127 | -// 826, //50; 英国 | ||
128 | -// }; | ||
129 | - | ||
130 | -// /* | ||
131 | -// uint16_t AF[] = { //非洲 | ||
132 | - | ||
133 | -// }; | ||
134 | - | ||
135 | -// uint16_t OC[] = { //大洋洲 | ||
136 | - | ||
137 | -// }; | ||
138 | -// */ | ||
139 | -// #endif | ||
140 | -// /*____________________________________________________ Country code array module ____________________________________________________*/ | ||
141 | - | ||
142 | - | ||
143 | - | ||
144 | -// //变量定义 | ||
145 | -// T_country_code_param country_code_Param[] = { | ||
146 | -// {.name = "CN", .name_address = CN,}, | ||
147 | -// {.name = "NA", .name_address = NA,}, | ||
148 | -// {.name = "EU", .name_address = EU,},//新增区域时,在此处新增对应的区域名字符串,以及对应的国家码数组 | ||
149 | -// }; | ||
150 | - | ||
151 | - | ||
152 | - | ||
153 | -// /*____________________________________________________ Country Code func module ____________________________________________________*/ | ||
154 | -// #if 1 //国家码比对函数模块 | ||
155 | -// /** | ||
156 | -// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1 | ||
157 | -// @Param: code 国家码参数结构体 | ||
158 | -// @Param: CountryCode 国家码 | ||
159 | -// @return:no | ||
160 | -// */ | ||
161 | -// static uint8_t IF_Country_Code(T_country_code_param * code , uint16_t CountryCode) | ||
162 | -// { | ||
163 | -// uint8_t i = 0; | ||
164 | -// uint8_t hundred = 0;//存储传进参数的百位的值 | ||
165 | -// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置 | ||
166 | -// uint8_t number = 0; | ||
167 | - | ||
168 | -// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置 | ||
169 | -// if(hundred <= 2) | ||
170 | -// { | ||
171 | -// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素 | ||
172 | -// }else if(hundred >=3 && hundred <= 5) | ||
173 | -// { | ||
174 | -// hundred = 1; | ||
175 | -// }else if(hundred >=6 && hundred <= 8) | ||
176 | -// { | ||
177 | -// hundred = 2; | ||
178 | -// } | ||
179 | -// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置 | ||
180 | -// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量 | ||
181 | - | ||
182 | -// for(i = 0;i<number;i++) | ||
183 | -// { | ||
184 | -// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致 | ||
185 | -// { | ||
186 | -// return 0;//对比成功,数组中存在该元素 | ||
187 | -// }else | ||
188 | -// { | ||
189 | -// } | ||
190 | -// } | ||
191 | -// return 1;//对比失败,数组中未存在该元素 | ||
192 | -// } | ||
193 | -// /** | ||
194 | -// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1 | ||
195 | -// @Param: CountryCode 国家码 | ||
196 | -// @Param: xarea 序列号中的国家码(地区位) | ||
197 | -// @return:0/1 成功/失败 | ||
198 | -// */ | ||
199 | -// #if 1 //方案二 | ||
200 | -// uint8_t Country_Code_handle(uint16_t CountryCode , char * xarea) | ||
201 | -// { | ||
202 | -// if(strcmp(xarea,country_code_Param[0].name) == 0)//中国地区 | ||
203 | -// { | ||
204 | -// if(CountryCode == country_code_Param[0].name_address[0] | ||
205 | -// || CountryCode == country_code_Param[0].name_address[1] | ||
206 | -// || CountryCode == country_code_Param[0].name_address[2] | ||
207 | -// || CountryCode == country_code_Param[0].name_address[3])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158) | ||
208 | -// { | ||
209 | -// return 0;//返回成功 | ||
210 | -// }else | ||
211 | -// { | ||
212 | -// return 1;//返回不成功 | ||
213 | -// } | ||
214 | -// } | ||
215 | -// else if(strcmp(xarea,country_code_Param[1].name) == 0)//美洲地区 | ||
216 | -// { | ||
217 | -// return IF_Country_Code(&country_code_Param[1],CountryCode); | ||
218 | -// } | ||
219 | -// else if(strcmp(xarea,country_code_Param[2].name) == 0)//欧洲地区 | ||
220 | -// { | ||
221 | -// return IF_Country_Code(&country_code_Param[2],CountryCode); | ||
222 | -// } | ||
223 | -// else | ||
224 | -// { | ||
225 | - | ||
226 | -// } | ||
227 | - | ||
228 | -// return 1;//返回不成功 | ||
229 | -// } | ||
230 | -// #else //方案一 | ||
231 | -// uint8_t Country_Code_handle(uint16_t CountryCode) | ||
232 | -// { | ||
233 | -// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号 | ||
234 | -// char area[3] = {0};//保存序列号中的地区码 | ||
235 | - | ||
236 | -// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号 | ||
237 | -// SN_Code[16] = '\0'; | ||
238 | -// area[0] = SN_Code[4]; | ||
239 | -// area[1] = SN_Code[5]; | ||
240 | -// area[2] = '\0'; | ||
241 | - | ||
242 | -// if(strcmp(area,country_code_Param[0].name) == 0)// | ||
243 | -// { | ||
244 | -// if(CountryCode == country_code_Param[0].name_address[0] | ||
245 | -// || CountryCode == country_code_Param[0].name_address[0] | ||
246 | -// || CountryCode == country_code_Param[0].name_address[0] | ||
247 | -// || CountryCode == country_code_Param[0].name_address[0])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158) | ||
248 | -// { | ||
249 | -// return 0;//返回成功 | ||
250 | -// }else | ||
251 | -// { | ||
252 | -// return 1;//返回不成功 | ||
253 | -// } | ||
254 | -// } | ||
255 | -// else if(strcmp(area,country_code_Param[1].name) == 0) | ||
256 | -// { | ||
257 | -// return IF_Country_Code(&country_code_Param[1],CountryCode); | ||
258 | -// } | ||
259 | -// else if(strcmp(area,country_code_Param[2].name) == 0) | ||
260 | -// { | ||
261 | -// return IF_Country_Code(&country_code_Param[2],CountryCode); | ||
262 | -// } | ||
263 | -// else | ||
264 | -// { | ||
265 | - | ||
266 | -// } | ||
267 | - | ||
268 | -// return 1;//返回不成功 | ||
269 | -// } | ||
270 | -// #endif | ||
271 | -// #endif | ||
272 | -// /*____________________________________________________ Country Code func module ____________________________________________________*/ | ||
273 | - | ||
274 | - | ||
275 | - | ||
276 | -// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/ | ||
277 | -// #if 0 //国家码函数调用例子 | ||
278 | -// static void Country_Code_init(void)//方案二 | ||
279 | -// { | ||
280 | -// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号 | ||
281 | -// char area[3] = {0};//保存序列号中的地区码 | ||
282 | -// uint8_t activate_flag = 0;//激活标志位,该处位局部变量真正工程中需变为全局变量或其它操作 | ||
283 | -// uint8_t Country_Code = 156;//假如从飞机获取的国家码是156,真正工程中需变为全局变量或其它操作 | ||
284 | - | ||
285 | -// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号,需更改为工程的对应的获取序列号的函数 | ||
286 | -// SN_Code[16] = '\0'; | ||
287 | -// area[0] = SN_Code[4]; | ||
288 | -// area[1] = SN_Code[5]; | ||
289 | -// area[2] = '\0'; | ||
290 | - | ||
291 | -// activate_flag = Get_Active_State(); //获取激活状态,需更改为工程的对应的获取激活状态的函数 | ||
292 | - | ||
293 | -// if(activate_flag == 0x01)//激活后才需要判断国家码与序列号的码是否一致,app_activate_flag == 0x01 | ||
294 | -// { | ||
295 | -// USER_LOG_INFO("SN = %s,activate = %x,CountryCode = %d,area = %s\r\n",SN_Code,activate_flag,Country_Code,area);//输出序列号,国家码, | ||
296 | -// activate_flag = Country_Code_handle(Country_Code,area);//获取国家码比对结果。 | ||
297 | -// USER_LOG_INFO("app_country_flag = %d\r\n",activate_flag); | ||
298 | -// if(activate_flag == 0)//国家码与序列号地区码比对一致 | ||
299 | -// { | ||
300 | - | ||
301 | -// }else | ||
302 | -// { | ||
303 | -// activate_flag = 0;//非法地区,禁止使用 | ||
304 | -// } | ||
305 | -// } | ||
306 | -// } | ||
307 | -// #endif | ||
308 | -// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/ | ||
309 | - | ||
310 | - | ||
311 | - | ||
312 | -// /*____________________________________________________ Country code test module ____________________________________________________*/ | ||
313 | -// #if COUNTRY_CODE_TEST //测试国家码是否能对应查找以及对比成功 | ||
314 | -// /** | ||
315 | -// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1 | ||
316 | -// @Param: code 国家码参数结构体 | ||
317 | -// @Param: CountryCode 国家码 | ||
318 | -// @return:no | ||
319 | -// */ | ||
320 | -// uint8_t TEST_IF_Country_Code(T_country_code_param * code , uint16_t CountryCode) | ||
321 | -// { | ||
322 | -// uint8_t i = 0; | ||
323 | -// uint8_t hundred = 0;//存储传进参数的百位的值 | ||
324 | -// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置 | ||
325 | -// uint8_t number = 0; | ||
326 | -// uint8_t state = 1;//返回检查状态 | ||
327 | - | ||
328 | -// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置 | ||
329 | -// if(hundred <= 2) | ||
330 | -// { | ||
331 | -// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素 | ||
332 | -// }else if(hundred >=3 && hundred <= 5) | ||
333 | -// { | ||
334 | -// hundred = 1; | ||
335 | -// }else if(hundred >=6 && hundred <= 8) | ||
336 | -// { | ||
337 | -// hundred = 2; | ||
338 | -// } | ||
339 | -// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置 | ||
340 | -// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量 | ||
341 | - | ||
342 | -// for(i = 0;i<number;i++) | ||
343 | -// { | ||
344 | -// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致 | ||
345 | -// { | ||
346 | -// state = 0; | ||
347 | -// }else | ||
348 | -// { | ||
349 | -// USER_LOG_INFO("CountryCode = %d\n",code->name_address[hundred_address+(1+i)]); //输出 | ||
350 | -// vTaskDelay(pdMS_TO_TICKS(2)); | ||
351 | -// } | ||
352 | -// } | ||
353 | -// return state;//对比成功,数组中存在该元素 | ||
354 | -// } | ||
355 | -// /** | ||
356 | -// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1 | ||
357 | -// @Param: CountryCode 国家码 | ||
358 | -// @Param: xarea 序列号中的国家码(地区位) | ||
359 | -// @return:0/1 成功/失败 | ||
360 | -// */ | ||
361 | -// uint8_t TEST_Country_Code_handle(uint16_t CountryCode , char * xarea) | ||
362 | -// { | ||
363 | -// USER_LOG_INFO("CountryCode = %d,%s\n",CountryCode,xarea); //输出 | ||
364 | - | ||
365 | -// if(strcmp(xarea,country_code_Param[0].name) == 0)// | ||
366 | -// { | ||
367 | -// if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158) | ||
368 | -// { | ||
369 | -// return 0;//返回成功 | ||
370 | -// }else | ||
371 | -// { | ||
372 | -// return 1;//返回不成功 | ||
373 | -// } | ||
374 | -// } | ||
375 | -// else if(strcmp(xarea,country_code_Param[1].name) == 0) | ||
376 | -// { | ||
377 | -// return TEST_IF_Country_Code(&country_code_Param[1],CountryCode); | ||
378 | -// } | ||
379 | -// else if(strcmp(xarea,country_code_Param[2].name) == 0) | ||
380 | -// { | ||
381 | -// return TEST_IF_Country_Code(&country_code_Param[2],CountryCode); | ||
382 | -// } | ||
383 | -// else | ||
384 | -// { | ||
385 | - | ||
386 | -// } | ||
387 | - | ||
388 | -// return 1;//返回不成功 | ||
389 | -// } | ||
390 | -// /** | ||
391 | -// @brief: 测试国家码 | ||
392 | -// @Param: no | ||
393 | -// @return:no | ||
394 | -// */ | ||
395 | -// void TEST_guojiama(void) | ||
396 | -// { | ||
397 | -// char area[5] = {0};//保存序列号中的地区码 | ||
398 | -// uint8_t state = 2; | ||
399 | - | ||
400 | -// area[0] = 'C'; | ||
401 | -// area[1] = 'N'; | ||
402 | -// area[2] = '\0'; | ||
403 | - | ||
404 | -// state = TEST_Country_Code_handle(156,area); | ||
405 | -// USER_LOG_INFO("%d\r\n",state);//国家码比对结果返回 | ||
406 | -// vTaskDelay(pdMS_TO_TICKS(500)); | ||
407 | -// area[0] = 'N'; | ||
408 | -// area[1] = 'A'; | ||
409 | -// area[2] = '\0'; | ||
410 | - | ||
411 | -// state = TEST_Country_Code_handle(8,area); | ||
412 | -// USER_LOG_INFO("%d\r\n",state); | ||
413 | -// vTaskDelay(pdMS_TO_TICKS(500)); | ||
414 | -// area[0] = 'E'; | ||
415 | -// area[1] = 'U'; | ||
416 | -// area[2] = '\0'; | ||
417 | - | ||
418 | -// state = TEST_Country_Code_handle(800,area); | ||
419 | -// USER_LOG_INFO("%d\r\n",state); | ||
420 | -// vTaskDelay(pdMS_TO_TICKS(500)); | ||
421 | -// } | ||
422 | -// #endif | ||
423 | -// /*____________________________________________________ Country code test module ____________________________________________________*/ | ||
424 | - | ||
425 | - | ||
426 | - | ||
427 | - |
1 | +// /** | ||
2 | +// 方案一:调用该文件中的对外函数输入参数国家码,可能需要更改获取序列号中地区码的部分代码,等待返回值即可,返回值:0 表明国家码与地区码一致。 | ||
3 | +// 方案二:调用该文件中的对外函数输入参数国家码、序列号中的地区码,等待返回值即可。 | ||
4 | +// */ | ||
5 | +// #include "FreeRTOS.h" | ||
6 | +// #include "task.h" | ||
7 | +// #include "Country_Code.h" | ||
8 | +// #include "myflash.h" | ||
9 | +// #include "dji_logger.h" | ||
10 | + | ||
11 | + | ||
12 | +#include "JZsdkLib.h" | ||
13 | + | ||
14 | +#include "DeviceInfo/SerialNumberProc/FirewareOriginMAT/FirewareOriginMAT.h" | ||
15 | + | ||
16 | + | ||
17 | +/*____________________________________________________ Country code array module ____________________________________________________*/ | ||
18 | + | ||
19 | +//中国国家码 | ||
20 | +unsigned int CN[] = | ||
21 | +{ | ||
22 | + 156, //中国大陆 | ||
23 | + 344, //香港 | ||
24 | + 446, //澳门 | ||
25 | + 158, //台湾 | ||
26 | +}; | ||
27 | + | ||
28 | + | ||
29 | +//美洲美洲 | ||
30 | +unsigned int NA[] = | ||
31 | +{ | ||
32 | + | ||
33 | + 28, //4; 安提瓜和巴布达 | ||
34 | + 44, //5; 巴哈马 | ||
35 | + 52, //6; 巴巴多斯 | ||
36 | + 60, //7; 百慕大(英国) | ||
37 | + 84, //8; 伯利兹 | ||
38 | + 92, //9; 英属维尔京群岛 | ||
39 | + 124, //10; 加拿大 | ||
40 | + 136, //11; 开曼群岛(英国) | ||
41 | + 188, //12; 哥斯达黎加 | ||
42 | + 192, //13; 古巴 | ||
43 | + 212, //14; 多米尼克 | ||
44 | + 214, //15; 多米尼加 | ||
45 | + 222, //16; 萨尔瓦多 | ||
46 | + | ||
47 | + | ||
48 | + 304, //18; 格陵兰(丹麦) | ||
49 | + 308, //19; 格林纳达 | ||
50 | + 312, //20; 瓜德罗普(法国) | ||
51 | + 320, //21; 危地马拉 | ||
52 | + 332, //22; 海地 | ||
53 | + 340, //23; 洪都拉斯 | ||
54 | + 388, //24; 牙买加 | ||
55 | + 474, //25; 马提尼克(法国) | ||
56 | + 484, //26; 墨西哥 | ||
57 | + 500, //27; 蒙特塞拉特(英国) | ||
58 | + 530, //28; 荷属安的列斯 | ||
59 | + 533, //29; 阿鲁巴(荷兰) | ||
60 | + 558, //30; 尼加拉瓜 | ||
61 | + 591, //31; 巴拿马 | ||
62 | + | ||
63 | + 630, //33; 波多黎各(美国) | ||
64 | + 659, //34; 圣基茨和尼维斯 | ||
65 | + 660, //35; 安圭拉(英国) | ||
66 | + 662, //36; 圣卢西亚 | ||
67 | + 666, //37; 圣皮埃尔和密克隆(法国) | ||
68 | + 670, //38; 圣文森特和格林纳丁斯 | ||
69 | + 780, //39; 特立尼达和多巴哥 | ||
70 | + 796, //40; 特克斯和凯科斯群岛(英国) | ||
71 | + 840, //41; 美国 | ||
72 | + 850, //42; 美属维尔京群岛 | ||
73 | +}; | ||
74 | + | ||
75 | +//欧洲国家码 | ||
76 | +unsigned int EU[] = | ||
77 | +{ | ||
78 | + 8, //4; 阿尔巴尼亚 | ||
79 | + 20, //5; 安道尔 | ||
80 | + 40, //6; 奥地利 | ||
81 | + 56, //7; 比利时 | ||
82 | + 100, //8; 保加利亚 | ||
83 | + 112, //9; 白俄罗斯 | ||
84 | + 191, //10; 克罗地亚 | ||
85 | + 203, //11; 捷克 | ||
86 | + 208, //12; 丹麦 | ||
87 | + 233, //13; 爱沙尼亚 | ||
88 | + 234, //14; 法罗群岛(丹麦) | ||
89 | + 246, //15; 芬兰 | ||
90 | + 250, //16; 法国 | ||
91 | + 276, //17; 德国 | ||
92 | + 292, //18; 直布罗陀 | ||
93 | + | ||
94 | + 300, //20; 希腊 | ||
95 | + 336, //21; 梵蒂冈 | ||
96 | + 348, //22; 匈牙利 | ||
97 | + 352, //23; 冰岛 | ||
98 | + 372, //24; 爱尔兰 | ||
99 | + 380, //25; 意大利 | ||
100 | + 428, //26; 拉脱维亚 | ||
101 | + 438, //27; 列支敦士登 | ||
102 | + 440, //28; 立陶宛 | ||
103 | + 442, //29; 卢森堡 | ||
104 | + 470, //30; 马耳他 | ||
105 | + 492, //31; 摩纳哥 | ||
106 | + 498, //32; 摩尔多瓦 | ||
107 | + 499, //33; 黑山 | ||
108 | + 528, //34; 荷兰 | ||
109 | + 578, //35; 挪威 | ||
110 | + | ||
111 | + 616, //37; 波兰 | ||
112 | + 620, //38; 葡萄牙 | ||
113 | + 642, //39; 罗马尼亚 | ||
114 | + 643, //40; 俄罗斯联邦 | ||
115 | + 674, //41; 圣马力诺 | ||
116 | + 688, //42; 塞尔维亚 | ||
117 | + 703, //43; 斯洛伐克 | ||
118 | + 705, //44; 斯洛文尼亚 | ||
119 | + 724, //45; 西班牙 | ||
120 | + 752, //46; 瑞典 | ||
121 | + 756, //47; 瑞士 | ||
122 | + 792, //48; 土耳其欧洲部分 | ||
123 | + 804, //49; 乌克兰 | ||
124 | + 826, //50; 英国 | ||
125 | +}; | ||
126 | + | ||
127 | +//非洲地区 | ||
128 | +unsigned int AF[] = | ||
129 | +{ | ||
130 | + | ||
131 | +}; | ||
132 | + | ||
133 | +//大洋洲地区 | ||
134 | +unsigned int OC[] = | ||
135 | +{ | ||
136 | + | ||
137 | +}; | ||
138 | + | ||
139 | +/*____________________________________________________ Country code array module ____________________________________________________*/ | ||
140 | + | ||
141 | + | ||
142 | + | ||
143 | +// 判断国家代码是否有效 | ||
144 | +T_JZsdkReturnCode JZsdk_IsCountryCodeValid(unsigned int CountryCode) | ||
145 | +{ | ||
146 | + //1、获取设备序列号的区域码 | ||
147 | + int OriginRegionNum = FOMAT_Get_FirewareOriginRegion(); | ||
148 | + | ||
149 | + //2、判断国家代码是否存在于目标结构体 | ||
150 | + if(OriginRegionNum == ORIGIN_CN) | ||
151 | + { | ||
152 | + //中国地区 | ||
153 | + for(int i = 0; i < sizeof(CN)/sizeof(CN[0]); i++) | ||
154 | + { | ||
155 | + if(CN[i] == CountryCode) | ||
156 | + { | ||
157 | + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS; | ||
158 | + } | ||
159 | + } | ||
160 | + } | ||
161 | + | ||
162 | + else if(OriginRegionNum == ORIGIN_NA) | ||
163 | + { | ||
164 | + //美洲地区 | ||
165 | + for(int i = 0; i < sizeof(NA)/sizeof(NA[0]); i++) | ||
166 | + { | ||
167 | + if(NA[i] == CountryCode) | ||
168 | + { | ||
169 | + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS; | ||
170 | + } | ||
171 | + } | ||
172 | + } | ||
173 | + | ||
174 | + else if(OriginRegionNum == ORIGIN_EU) | ||
175 | + { | ||
176 | + //欧洲地区 | ||
177 | + for(int i = 0; i < sizeof(EU)/sizeof(EU[0]); i++) | ||
178 | + { | ||
179 | + if(EU[i] == CountryCode) | ||
180 | + { | ||
181 | + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS; | ||
182 | + } | ||
183 | + } | ||
184 | + } | ||
185 | + | ||
186 | + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE; | ||
187 | +} | ||
188 | + | ||
189 | + | ||
190 | +// /*____________________________________________________ Country Code func module ____________________________________________________*/ | ||
191 | +// #if 1 //国家码比对函数模块 | ||
192 | +// /** | ||
193 | +// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1 | ||
194 | +// @Param: code 国家码参数结构体 | ||
195 | +// @Param: CountryCode 国家码 | ||
196 | +// @return:no | ||
197 | +// */ | ||
198 | +// static uint8_t IF_Country_Code(T_country_code_param * code , uint16_t CountryCode) | ||
199 | +// { | ||
200 | +// uint8_t i = 0; | ||
201 | +// uint8_t hundred = 0;//存储传进参数的百位的值 | ||
202 | +// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置 | ||
203 | +// uint8_t number = 0; | ||
204 | + | ||
205 | +// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置 | ||
206 | +// if(hundred <= 2) | ||
207 | +// { | ||
208 | +// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素 | ||
209 | +// }else if(hundred >=3 && hundred <= 5) | ||
210 | +// { | ||
211 | +// hundred = 1; | ||
212 | +// }else if(hundred >=6 && hundred <= 8) | ||
213 | +// { | ||
214 | +// hundred = 2; | ||
215 | +// } | ||
216 | +// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置 | ||
217 | +// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量 | ||
218 | + | ||
219 | +// for(i = 0;i<number;i++) | ||
220 | +// { | ||
221 | +// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致 | ||
222 | +// { | ||
223 | +// return 0;//对比成功,数组中存在该元素 | ||
224 | +// }else | ||
225 | +// { | ||
226 | +// } | ||
227 | +// } | ||
228 | +// return 1;//对比失败,数组中未存在该元素 | ||
229 | +// } | ||
230 | +// /** | ||
231 | +// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1 | ||
232 | +// @Param: CountryCode 国家码 | ||
233 | +// @Param: xarea 序列号中的国家码(地区位) | ||
234 | +// @return:0/1 成功/失败 | ||
235 | +// */ | ||
236 | +// #if 1 //方案二 | ||
237 | +// uint8_t Country_Code_handle(uint16_t CountryCode , char * xarea) | ||
238 | +// { | ||
239 | +// if(strcmp(xarea,country_code_Param[0].name) == 0)//中国地区 | ||
240 | +// { | ||
241 | +// if(CountryCode == country_code_Param[0].name_address[0] | ||
242 | +// || CountryCode == country_code_Param[0].name_address[1] | ||
243 | +// || CountryCode == country_code_Param[0].name_address[2] | ||
244 | +// || CountryCode == country_code_Param[0].name_address[3])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158) | ||
245 | +// { | ||
246 | +// return 0;//返回成功 | ||
247 | +// }else | ||
248 | +// { | ||
249 | +// return 1;//返回不成功 | ||
250 | +// } | ||
251 | +// } | ||
252 | +// else if(strcmp(xarea,country_code_Param[1].name) == 0)//美洲地区 | ||
253 | +// { | ||
254 | +// return IF_Country_Code(&country_code_Param[1],CountryCode); | ||
255 | +// } | ||
256 | +// else if(strcmp(xarea,country_code_Param[2].name) == 0)//欧洲地区 | ||
257 | +// { | ||
258 | +// return IF_Country_Code(&country_code_Param[2],CountryCode); | ||
259 | +// } | ||
260 | +// else | ||
261 | +// { | ||
262 | + | ||
263 | +// } | ||
264 | + | ||
265 | +// return 1;//返回不成功 | ||
266 | +// } | ||
267 | +// #else //方案一 | ||
268 | +// uint8_t Country_Code_handle(uint16_t CountryCode) | ||
269 | +// { | ||
270 | +// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号 | ||
271 | +// char area[3] = {0};//保存序列号中的地区码 | ||
272 | + | ||
273 | +// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号 | ||
274 | +// SN_Code[16] = '\0'; | ||
275 | +// area[0] = SN_Code[4]; | ||
276 | +// area[1] = SN_Code[5]; | ||
277 | +// area[2] = '\0'; | ||
278 | + | ||
279 | +// if(strcmp(area,country_code_Param[0].name) == 0)// | ||
280 | +// { | ||
281 | +// if(CountryCode == country_code_Param[0].name_address[0] | ||
282 | +// || CountryCode == country_code_Param[0].name_address[0] | ||
283 | +// || CountryCode == country_code_Param[0].name_address[0] | ||
284 | +// || CountryCode == country_code_Param[0].name_address[0])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158) | ||
285 | +// { | ||
286 | +// return 0;//返回成功 | ||
287 | +// }else | ||
288 | +// { | ||
289 | +// return 1;//返回不成功 | ||
290 | +// } | ||
291 | +// } | ||
292 | +// else if(strcmp(area,country_code_Param[1].name) == 0) | ||
293 | +// { | ||
294 | +// return IF_Country_Code(&country_code_Param[1],CountryCode); | ||
295 | +// } | ||
296 | +// else if(strcmp(area,country_code_Param[2].name) == 0) | ||
297 | +// { | ||
298 | +// return IF_Country_Code(&country_code_Param[2],CountryCode); | ||
299 | +// } | ||
300 | +// else | ||
301 | +// { | ||
302 | + | ||
303 | +// } | ||
304 | + | ||
305 | +// return 1;//返回不成功 | ||
306 | +// } | ||
307 | +// #endif | ||
308 | +// #endif | ||
309 | +// /*____________________________________________________ Country Code func module ____________________________________________________*/ | ||
310 | + | ||
311 | + | ||
312 | + | ||
313 | +// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/ | ||
314 | +// #if 0 //国家码函数调用例子 | ||
315 | +// static void Country_Code_init(void)//方案二 | ||
316 | +// { | ||
317 | +// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号 | ||
318 | +// char area[3] = {0};//保存序列号中的地区码 | ||
319 | +// uint8_t activate_flag = 0;//激活标志位,该处位局部变量真正工程中需变为全局变量或其它操作 | ||
320 | +// uint8_t Country_Code = 156;//假如从飞机获取的国家码是156,真正工程中需变为全局变量或其它操作 | ||
321 | + | ||
322 | +// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号,需更改为工程的对应的获取序列号的函数 | ||
323 | +// SN_Code[16] = '\0'; | ||
324 | +// area[0] = SN_Code[4]; | ||
325 | +// area[1] = SN_Code[5]; | ||
326 | +// area[2] = '\0'; | ||
327 | + | ||
328 | +// activate_flag = Get_Active_State(); //获取激活状态,需更改为工程的对应的获取激活状态的函数 | ||
329 | + | ||
330 | +// if(activate_flag == 0x01)//激活后才需要判断国家码与序列号的码是否一致,app_activate_flag == 0x01 | ||
331 | +// { | ||
332 | +// USER_LOG_INFO("SN = %s,activate = %x,CountryCode = %d,area = %s\r\n",SN_Code,activate_flag,Country_Code,area);//输出序列号,国家码, | ||
333 | +// activate_flag = Country_Code_handle(Country_Code,area);//获取国家码比对结果。 | ||
334 | +// USER_LOG_INFO("app_country_flag = %d\r\n",activate_flag); | ||
335 | +// if(activate_flag == 0)//国家码与序列号地区码比对一致 | ||
336 | +// { | ||
337 | + | ||
338 | +// }else | ||
339 | +// { | ||
340 | +// activate_flag = 0;//非法地区,禁止使用 | ||
341 | +// } | ||
342 | +// } | ||
343 | +// } | ||
344 | +// #endif | ||
345 | +// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/ | ||
346 | + | ||
347 | + | ||
348 | + | ||
349 | +// /*____________________________________________________ Country code test module ____________________________________________________*/ | ||
350 | +// #if COUNTRY_CODE_TEST //测试国家码是否能对应查找以及对比成功 | ||
351 | +// /** | ||
352 | +// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1 | ||
353 | +// @Param: code 国家码参数结构体 | ||
354 | +// @Param: CountryCode 国家码 | ||
355 | +// @return:no | ||
356 | +// */ | ||
357 | +// uint8_t TEST_IF_Country_Code(T_country_code_param * code , uint16_t CountryCode) | ||
358 | +// { | ||
359 | +// uint8_t i = 0; | ||
360 | +// uint8_t hundred = 0;//存储传进参数的百位的值 | ||
361 | +// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置 | ||
362 | +// uint8_t number = 0; | ||
363 | +// uint8_t state = 1;//返回检查状态 | ||
364 | + | ||
365 | +// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置 | ||
366 | +// if(hundred <= 2) | ||
367 | +// { | ||
368 | +// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素 | ||
369 | +// }else if(hundred >=3 && hundred <= 5) | ||
370 | +// { | ||
371 | +// hundred = 1; | ||
372 | +// }else if(hundred >=6 && hundred <= 8) | ||
373 | +// { | ||
374 | +// hundred = 2; | ||
375 | +// } | ||
376 | +// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置 | ||
377 | +// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量 | ||
378 | + | ||
379 | +// for(i = 0;i<number;i++) | ||
380 | +// { | ||
381 | +// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致 | ||
382 | +// { | ||
383 | +// state = 0; | ||
384 | +// }else | ||
385 | +// { | ||
386 | +// USER_LOG_INFO("CountryCode = %d\n",code->name_address[hundred_address+(1+i)]); //输出 | ||
387 | +// vTaskDelay(pdMS_TO_TICKS(2)); | ||
388 | +// } | ||
389 | +// } | ||
390 | +// return state;//对比成功,数组中存在该元素 | ||
391 | +// } | ||
392 | +// /** | ||
393 | +// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1 | ||
394 | +// @Param: CountryCode 国家码 | ||
395 | +// @Param: xarea 序列号中的国家码(地区位) | ||
396 | +// @return:0/1 成功/失败 | ||
397 | +// */ | ||
398 | +// uint8_t TEST_Country_Code_handle(uint16_t CountryCode , char * xarea) | ||
399 | +// { | ||
400 | +// USER_LOG_INFO("CountryCode = %d,%s\n",CountryCode,xarea); //输出 | ||
401 | + | ||
402 | +// if(strcmp(xarea,country_code_Param[0].name) == 0)// | ||
403 | +// { | ||
404 | +// if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158) | ||
405 | +// { | ||
406 | +// return 0;//返回成功 | ||
407 | +// }else | ||
408 | +// { | ||
409 | +// return 1;//返回不成功 | ||
410 | +// } | ||
411 | +// } | ||
412 | +// else if(strcmp(xarea,country_code_Param[1].name) == 0) | ||
413 | +// { | ||
414 | +// return TEST_IF_Country_Code(&country_code_Param[1],CountryCode); | ||
415 | +// } | ||
416 | +// else if(strcmp(xarea,country_code_Param[2].name) == 0) | ||
417 | +// { | ||
418 | +// return TEST_IF_Country_Code(&country_code_Param[2],CountryCode); | ||
419 | +// } | ||
420 | +// else | ||
421 | +// { | ||
422 | + | ||
423 | +// } | ||
424 | + | ||
425 | +// return 1;//返回不成功 | ||
426 | +// } | ||
427 | +// /** | ||
428 | +// @brief: 测试国家码 | ||
429 | +// @Param: no | ||
430 | +// @return:no | ||
431 | +// */ | ||
432 | +// void TEST_guojiama(void) | ||
433 | +// { | ||
434 | +// char area[5] = {0};//保存序列号中的地区码 | ||
435 | +// uint8_t state = 2; | ||
436 | + | ||
437 | +// area[0] = 'C'; | ||
438 | +// area[1] = 'N'; | ||
439 | +// area[2] = '\0'; | ||
440 | + | ||
441 | +// state = TEST_Country_Code_handle(156,area); | ||
442 | +// USER_LOG_INFO("%d\r\n",state);//国家码比对结果返回 | ||
443 | +// vTaskDelay(pdMS_TO_TICKS(500)); | ||
444 | +// area[0] = 'N'; | ||
445 | +// area[1] = 'A'; | ||
446 | +// area[2] = '\0'; | ||
447 | + | ||
448 | +// state = TEST_Country_Code_handle(8,area); | ||
449 | +// USER_LOG_INFO("%d\r\n",state); | ||
450 | +// vTaskDelay(pdMS_TO_TICKS(500)); | ||
451 | +// area[0] = 'E'; | ||
452 | +// area[1] = 'U'; | ||
453 | +// area[2] = '\0'; | ||
454 | + | ||
455 | +// state = TEST_Country_Code_handle(800,area); | ||
456 | +// USER_LOG_INFO("%d\r\n",state); | ||
457 | +// vTaskDelay(pdMS_TO_TICKS(500)); | ||
458 | +// } | ||
459 | +// #endif | ||
460 | +// /*____________________________________________________ Country code test module ____________________________________________________*/ | ||
461 | + | ||
462 | + | ||
463 | + | ||
464 | + |
@@ -27,9 +27,10 @@ T_JZsdkReturnCode FOMAT_Get_FirewareOriginRegion(); | @@ -27,9 +27,10 @@ T_JZsdkReturnCode FOMAT_Get_FirewareOriginRegion(); | ||
27 | typedef enum OriginRegionPlace | 27 | typedef enum OriginRegionPlace |
28 | { | 28 | { |
29 | ORIGIN_DEFAULT = 0x0000, | 29 | ORIGIN_DEFAULT = 0x0000, |
30 | - ORIGIN_CN = 0x0001, //中区码 | ||
31 | - ORIGIN_EN = 0x0002, //英区码 | ||
32 | - ORIGIN_NA = 0x0003, //南美码 | 30 | + ORIGIN_CN = 0x0001, //中区通用码 |
31 | + ORIGIN_EN = 0x0002, //英区通用码 | ||
32 | + | ||
33 | + ORIGIN_NA = 0x0003, //美洲码 | ||
33 | ORIGIN_EU = 0x0004, //欧洲码 | 34 | ORIGIN_EU = 0x0004, //欧洲码 |
34 | }OriginRegionPlace; | 35 | }OriginRegionPlace; |
35 | 36 |
-
请 注册 或 登录 后发表评论