作者 ookk303

国家码小改动

... ... @@ -721,7 +721,7 @@ T_JZsdkReturnCode HalSend_type1Send_Reply_TTS_tone(int Uartport ,int tone)
//发送语速
T_JZsdkReturnCode HalSend_type1Send_Reply_TTS_speed(int Uartport ,int speed)
{
printf("发送音色\n");
printf("发送语速\n");
unsigned char sendbuf[256];
int send_buf_len;
... ...
// /**
// 方案一:调用该文件中的对外函数输入参数国家码,可能需要更改获取序列号中地区码的部分代码,等待返回值即可,返回值:0 表明国家码与地区码一致。
// 方案二:调用该文件中的对外函数输入参数国家码、序列号中的地区码,等待返回值即可。
// */
// #include "FreeRTOS.h"
// #include "task.h"
// #include "Country_Code.h"
// #include "myflash.h"
// #include "dji_logger.h"
// /*____________________________________________________ Country code array module ____________________________________________________*/
// #if 1 //国家码
// //4个有效数据
// uint16_t CN[] = { //中国
// 156, //中国大陆
// 344, //香港
// 446, //澳门
// 158, //台湾
// };
// //37个有效数据(国家码)
// uint16_t NA[] = { //美洲
// 3, //0; 国家码的百位为0~2的数据的位置<_*_*_>
// 17, //1; 国家码的百位为3~5的数据的位置<_*_*_>
// 32, //2; 国家码的百位为6~8的数据的位置<_*_*_>
// 13, //3; 国家码的百位为0~2的数据的数量<_*_*_>
// 28, //4; 安提瓜和巴布达
// 44, //5; 巴哈马
// 52, //6; 巴巴多斯
// 60, //7; 百慕大(英国)
// 84, //8; 伯利兹
// 92, //9; 英属维尔京群岛
// 124, //10; 加拿大
// 136, //11; 开曼群岛(英国)
// 188, //12; 哥斯达黎加
// 192, //13; 古巴
// 212, //14; 多米尼克
// 214, //15; 多米尼加
// 222, //16; 萨尔瓦多
// 14, //17; 国家码的百位为3~4的数据的数量<_*_*_>
// 304, //18; 格陵兰(丹麦)
// 308, //19; 格林纳达
// 312, //20; 瓜德罗普(法国)
// 320, //21; 危地马拉
// 332, //22; 海地
// 340, //23; 洪都拉斯
// 388, //24; 牙买加
// 474, //25; 马提尼克(法国)
// 484, //26; 墨西哥
// 500, //27; 蒙特塞拉特(英国)
// 530, //28; 荷属安的列斯
// 533, //29; 阿鲁巴(荷兰)
// 558, //30; 尼加拉瓜
// 591, //31; 巴拿马
// 10, //32; 国家码的百位为6~8的数据的数量<_*_*_>
// 630, //33; 波多黎各(美国)
// 659, //34; 圣基茨和尼维斯
// 660, //35; 安圭拉(英国)
// 662, //36; 圣卢西亚
// 666, //37; 圣皮埃尔和密克隆(法国)
// 670, //38; 圣文森特和格林纳丁斯
// 780, //39; 特立尼达和多巴哥
// 796, //40; 特克斯和凯科斯群岛(英国)
// 840, //41; 美国
// 850, //42; 美属维尔京群岛
// };
// //45个数据
// uint16_t EU[] = { //欧洲
// 3, //0; 国家码的百位为0~2的数据的位置<_*_*_>
// 19, //1; 国家码的百位为3~5的数据的位置<_*_*_>
// 36, //2; 国家码的百位为6~8的数据的位置<_*_*_>
// 15, //3; 国家码的百位为0~2的数据的数量<_*_*_>
// 8, //4; 阿尔巴尼亚
// 20, //5; 安道尔
// 40, //6; 奥地利
// 56, //7; 比利时
// 100, //8; 保加利亚
// 112, //9; 白俄罗斯
// 191, //10; 克罗地亚
// 203, //11; 捷克
// 208, //12; 丹麦
// 233, //13; 爱沙尼亚
// 234, //14; 法罗群岛(丹麦)
// 246, //15; 芬兰
// 250, //16; 法国
// 276, //17; 德国
// 292, //18; 直布罗陀
// 16, //19; 国家码的百位为3~5的数据的数量<_*_*_>
// 300, //20; 希腊
// 336, //21; 梵蒂冈
// 348, //22; 匈牙利
// 352, //23; 冰岛
// 372, //24; 爱尔兰
// 380, //25; 意大利
// 428, //26; 拉脱维亚
// 438, //27; 列支敦士登
// 440, //28; 立陶宛
// 442, //29; 卢森堡
// 470, //30; 马耳他
// 492, //31; 摩纳哥
// 498, //32; 摩尔多瓦
// 499, //33; 黑山
// 528, //34; 荷兰
// 578, //35; 挪威
// 14, //36; 国家码的百位为6~8的数据的数量<_*_*_>
// 616, //37; 波兰
// 620, //38; 葡萄牙
// 642, //39; 罗马尼亚
// 643, //40; 俄罗斯联邦
// 674, //41; 圣马力诺
// 688, //42; 塞尔维亚
// 703, //43; 斯洛伐克
// 705, //44; 斯洛文尼亚
// 724, //45; 西班牙
// 752, //46; 瑞典
// 756, //47; 瑞士
// 792, //48; 土耳其欧洲部分
// 804, //49; 乌克兰
// 826, //50; 英国
// };
// /*
// uint16_t AF[] = { //非洲
// };
// uint16_t OC[] = { //大洋洲
// };
// */
// #endif
// /*____________________________________________________ Country code array module ____________________________________________________*/
// //变量定义
// T_country_code_param country_code_Param[] = {
// {.name = "CN", .name_address = CN,},
// {.name = "NA", .name_address = NA,},
// {.name = "EU", .name_address = EU,},//新增区域时,在此处新增对应的区域名字符串,以及对应的国家码数组
// };
// /*____________________________________________________ Country Code func module ____________________________________________________*/
// #if 1 //国家码比对函数模块
// /**
// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1
// @Param: code 国家码参数结构体
// @Param: CountryCode 国家码
// @return:no
// */
// static uint8_t IF_Country_Code(T_country_code_param * code , uint16_t CountryCode)
// {
// uint8_t i = 0;
// uint8_t hundred = 0;//存储传进参数的百位的值
// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置
// uint8_t number = 0;
// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置
// if(hundred <= 2)
// {
// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素
// }else if(hundred >=3 && hundred <= 5)
// {
// hundred = 1;
// }else if(hundred >=6 && hundred <= 8)
// {
// hundred = 2;
// }
// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置
// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量
// for(i = 0;i<number;i++)
// {
// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致
// {
// return 0;//对比成功,数组中存在该元素
// }else
// {
// }
// }
// return 1;//对比失败,数组中未存在该元素
// }
// /**
// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1
// @Param: CountryCode 国家码
// @Param: xarea 序列号中的国家码(地区位)
// @return:0/1 成功/失败
// */
// #if 1 //方案二
// uint8_t Country_Code_handle(uint16_t CountryCode , char * xarea)
// {
// if(strcmp(xarea,country_code_Param[0].name) == 0)//中国地区
// {
// if(CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[1]
// || CountryCode == country_code_Param[0].name_address[2]
// || CountryCode == country_code_Param[0].name_address[3])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158)
// {
// return 0;//返回成功
// }else
// {
// return 1;//返回不成功
// }
// }
// else if(strcmp(xarea,country_code_Param[1].name) == 0)//美洲地区
// {
// return IF_Country_Code(&country_code_Param[1],CountryCode);
// }
// else if(strcmp(xarea,country_code_Param[2].name) == 0)//欧洲地区
// {
// return IF_Country_Code(&country_code_Param[2],CountryCode);
// }
// else
// {
// }
// return 1;//返回不成功
// }
// #else //方案一
// uint8_t Country_Code_handle(uint16_t CountryCode)
// {
// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号
// char area[3] = {0};//保存序列号中的地区码
// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号
// SN_Code[16] = '\0';
// area[0] = SN_Code[4];
// area[1] = SN_Code[5];
// area[2] = '\0';
// if(strcmp(area,country_code_Param[0].name) == 0)//
// {
// if(CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[0])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158)
// {
// return 0;//返回成功
// }else
// {
// return 1;//返回不成功
// }
// }
// else if(strcmp(area,country_code_Param[1].name) == 0)
// {
// return IF_Country_Code(&country_code_Param[1],CountryCode);
// }
// else if(strcmp(area,country_code_Param[2].name) == 0)
// {
// return IF_Country_Code(&country_code_Param[2],CountryCode);
// }
// else
// {
// }
// return 1;//返回不成功
// }
// #endif
// #endif
// /*____________________________________________________ Country Code func module ____________________________________________________*/
// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/
// #if 0 //国家码函数调用例子
// static void Country_Code_init(void)//方案二
// {
// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号
// char area[3] = {0};//保存序列号中的地区码
// uint8_t activate_flag = 0;//激活标志位,该处位局部变量真正工程中需变为全局变量或其它操作
// uint8_t Country_Code = 156;//假如从飞机获取的国家码是156,真正工程中需变为全局变量或其它操作
// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号,需更改为工程的对应的获取序列号的函数
// SN_Code[16] = '\0';
// area[0] = SN_Code[4];
// area[1] = SN_Code[5];
// area[2] = '\0';
// activate_flag = Get_Active_State(); //获取激活状态,需更改为工程的对应的获取激活状态的函数
// if(activate_flag == 0x01)//激活后才需要判断国家码与序列号的码是否一致,app_activate_flag == 0x01
// {
// USER_LOG_INFO("SN = %s,activate = %x,CountryCode = %d,area = %s\r\n",SN_Code,activate_flag,Country_Code,area);//输出序列号,国家码,
// activate_flag = Country_Code_handle(Country_Code,area);//获取国家码比对结果。
// USER_LOG_INFO("app_country_flag = %d\r\n",activate_flag);
// if(activate_flag == 0)//国家码与序列号地区码比对一致
// {
// }else
// {
// activate_flag = 0;//非法地区,禁止使用
// }
// }
// }
// #endif
// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/
// /*____________________________________________________ Country code test module ____________________________________________________*/
// #if COUNTRY_CODE_TEST //测试国家码是否能对应查找以及对比成功
// /**
// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1
// @Param: code 国家码参数结构体
// @Param: CountryCode 国家码
// @return:no
// */
// uint8_t TEST_IF_Country_Code(T_country_code_param * code , uint16_t CountryCode)
// {
// uint8_t i = 0;
// uint8_t hundred = 0;//存储传进参数的百位的值
// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置
// uint8_t number = 0;
// uint8_t state = 1;//返回检查状态
// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置
// if(hundred <= 2)
// {
// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素
// }else if(hundred >=3 && hundred <= 5)
// {
// hundred = 1;
// }else if(hundred >=6 && hundred <= 8)
// {
// hundred = 2;
// }
// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置
// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量
// for(i = 0;i<number;i++)
// {
// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致
// {
// state = 0;
// }else
// {
// USER_LOG_INFO("CountryCode = %d\n",code->name_address[hundred_address+(1+i)]); //输出
// vTaskDelay(pdMS_TO_TICKS(2));
// }
// }
// return state;//对比成功,数组中存在该元素
// }
// /**
// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1
// @Param: CountryCode 国家码
// @Param: xarea 序列号中的国家码(地区位)
// @return:0/1 成功/失败
// */
// uint8_t TEST_Country_Code_handle(uint16_t CountryCode , char * xarea)
// {
// USER_LOG_INFO("CountryCode = %d,%s\n",CountryCode,xarea); //输出
// if(strcmp(xarea,country_code_Param[0].name) == 0)//
// {
// if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158)
// {
// return 0;//返回成功
// }else
// {
// return 1;//返回不成功
// }
// }
// else if(strcmp(xarea,country_code_Param[1].name) == 0)
// {
// return TEST_IF_Country_Code(&country_code_Param[1],CountryCode);
// }
// else if(strcmp(xarea,country_code_Param[2].name) == 0)
// {
// return TEST_IF_Country_Code(&country_code_Param[2],CountryCode);
// }
// else
// {
// }
// return 1;//返回不成功
// }
// /**
// @brief: 测试国家码
// @Param: no
// @return:no
// */
// void TEST_guojiama(void)
// {
// char area[5] = {0};//保存序列号中的地区码
// uint8_t state = 2;
// area[0] = 'C';
// area[1] = 'N';
// area[2] = '\0';
// state = TEST_Country_Code_handle(156,area);
// USER_LOG_INFO("%d\r\n",state);//国家码比对结果返回
// vTaskDelay(pdMS_TO_TICKS(500));
// area[0] = 'N';
// area[1] = 'A';
// area[2] = '\0';
// state = TEST_Country_Code_handle(8,area);
// USER_LOG_INFO("%d\r\n",state);
// vTaskDelay(pdMS_TO_TICKS(500));
// area[0] = 'E';
// area[1] = 'U';
// area[2] = '\0';
// state = TEST_Country_Code_handle(800,area);
// USER_LOG_INFO("%d\r\n",state);
// vTaskDelay(pdMS_TO_TICKS(500));
// }
// #endif
// /*____________________________________________________ Country code test module ____________________________________________________*/
// /**
// 方案一:调用该文件中的对外函数输入参数国家码,可能需要更改获取序列号中地区码的部分代码,等待返回值即可,返回值:0 表明国家码与地区码一致。
// 方案二:调用该文件中的对外函数输入参数国家码、序列号中的地区码,等待返回值即可。
// */
// #include "FreeRTOS.h"
// #include "task.h"
// #include "Country_Code.h"
// #include "myflash.h"
// #include "dji_logger.h"
#include "JZsdkLib.h"
#include "DeviceInfo/SerialNumberProc/FirewareOriginMAT/FirewareOriginMAT.h"
/*____________________________________________________ Country code array module ____________________________________________________*/
//中国国家码
unsigned int CN[] =
{
156, //中国大陆
344, //香港
446, //澳门
158, //台湾
};
//美洲美洲
unsigned int NA[] =
{
28, //4; 安提瓜和巴布达
44, //5; 巴哈马
52, //6; 巴巴多斯
60, //7; 百慕大(英国)
84, //8; 伯利兹
92, //9; 英属维尔京群岛
124, //10; 加拿大
136, //11; 开曼群岛(英国)
188, //12; 哥斯达黎加
192, //13; 古巴
212, //14; 多米尼克
214, //15; 多米尼加
222, //16; 萨尔瓦多
304, //18; 格陵兰(丹麦)
308, //19; 格林纳达
312, //20; 瓜德罗普(法国)
320, //21; 危地马拉
332, //22; 海地
340, //23; 洪都拉斯
388, //24; 牙买加
474, //25; 马提尼克(法国)
484, //26; 墨西哥
500, //27; 蒙特塞拉特(英国)
530, //28; 荷属安的列斯
533, //29; 阿鲁巴(荷兰)
558, //30; 尼加拉瓜
591, //31; 巴拿马
630, //33; 波多黎各(美国)
659, //34; 圣基茨和尼维斯
660, //35; 安圭拉(英国)
662, //36; 圣卢西亚
666, //37; 圣皮埃尔和密克隆(法国)
670, //38; 圣文森特和格林纳丁斯
780, //39; 特立尼达和多巴哥
796, //40; 特克斯和凯科斯群岛(英国)
840, //41; 美国
850, //42; 美属维尔京群岛
};
//欧洲国家码
unsigned int EU[] =
{
8, //4; 阿尔巴尼亚
20, //5; 安道尔
40, //6; 奥地利
56, //7; 比利时
100, //8; 保加利亚
112, //9; 白俄罗斯
191, //10; 克罗地亚
203, //11; 捷克
208, //12; 丹麦
233, //13; 爱沙尼亚
234, //14; 法罗群岛(丹麦)
246, //15; 芬兰
250, //16; 法国
276, //17; 德国
292, //18; 直布罗陀
300, //20; 希腊
336, //21; 梵蒂冈
348, //22; 匈牙利
352, //23; 冰岛
372, //24; 爱尔兰
380, //25; 意大利
428, //26; 拉脱维亚
438, //27; 列支敦士登
440, //28; 立陶宛
442, //29; 卢森堡
470, //30; 马耳他
492, //31; 摩纳哥
498, //32; 摩尔多瓦
499, //33; 黑山
528, //34; 荷兰
578, //35; 挪威
616, //37; 波兰
620, //38; 葡萄牙
642, //39; 罗马尼亚
643, //40; 俄罗斯联邦
674, //41; 圣马力诺
688, //42; 塞尔维亚
703, //43; 斯洛伐克
705, //44; 斯洛文尼亚
724, //45; 西班牙
752, //46; 瑞典
756, //47; 瑞士
792, //48; 土耳其欧洲部分
804, //49; 乌克兰
826, //50; 英国
};
//非洲地区
unsigned int AF[] =
{
};
//大洋洲地区
unsigned int OC[] =
{
};
/*____________________________________________________ Country code array module ____________________________________________________*/
// 判断国家代码是否有效
T_JZsdkReturnCode JZsdk_IsCountryCodeValid(unsigned int CountryCode)
{
//1、获取设备序列号的区域码
int OriginRegionNum = FOMAT_Get_FirewareOriginRegion();
//2、判断国家代码是否存在于目标结构体
if(OriginRegionNum == ORIGIN_CN)
{
//中国地区
for(int i = 0; i < sizeof(CN)/sizeof(CN[0]); i++)
{
if(CN[i] == CountryCode)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
}
}
else if(OriginRegionNum == ORIGIN_NA)
{
//美洲地区
for(int i = 0; i < sizeof(NA)/sizeof(NA[0]); i++)
{
if(NA[i] == CountryCode)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
}
}
else if(OriginRegionNum == ORIGIN_EU)
{
//欧洲地区
for(int i = 0; i < sizeof(EU)/sizeof(EU[0]); i++)
{
if(EU[i] == CountryCode)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
}
}
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
// /*____________________________________________________ Country Code func module ____________________________________________________*/
// #if 1 //国家码比对函数模块
// /**
// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1
// @Param: code 国家码参数结构体
// @Param: CountryCode 国家码
// @return:no
// */
// static uint8_t IF_Country_Code(T_country_code_param * code , uint16_t CountryCode)
// {
// uint8_t i = 0;
// uint8_t hundred = 0;//存储传进参数的百位的值
// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置
// uint8_t number = 0;
// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置
// if(hundred <= 2)
// {
// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素
// }else if(hundred >=3 && hundred <= 5)
// {
// hundred = 1;
// }else if(hundred >=6 && hundred <= 8)
// {
// hundred = 2;
// }
// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置
// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量
// for(i = 0;i<number;i++)
// {
// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致
// {
// return 0;//对比成功,数组中存在该元素
// }else
// {
// }
// }
// return 1;//对比失败,数组中未存在该元素
// }
// /**
// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1
// @Param: CountryCode 国家码
// @Param: xarea 序列号中的国家码(地区位)
// @return:0/1 成功/失败
// */
// #if 1 //方案二
// uint8_t Country_Code_handle(uint16_t CountryCode , char * xarea)
// {
// if(strcmp(xarea,country_code_Param[0].name) == 0)//中国地区
// {
// if(CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[1]
// || CountryCode == country_code_Param[0].name_address[2]
// || CountryCode == country_code_Param[0].name_address[3])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158)
// {
// return 0;//返回成功
// }else
// {
// return 1;//返回不成功
// }
// }
// else if(strcmp(xarea,country_code_Param[1].name) == 0)//美洲地区
// {
// return IF_Country_Code(&country_code_Param[1],CountryCode);
// }
// else if(strcmp(xarea,country_code_Param[2].name) == 0)//欧洲地区
// {
// return IF_Country_Code(&country_code_Param[2],CountryCode);
// }
// else
// {
// }
// return 1;//返回不成功
// }
// #else //方案一
// uint8_t Country_Code_handle(uint16_t CountryCode)
// {
// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号
// char area[3] = {0};//保存序列号中的地区码
// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号
// SN_Code[16] = '\0';
// area[0] = SN_Code[4];
// area[1] = SN_Code[5];
// area[2] = '\0';
// if(strcmp(area,country_code_Param[0].name) == 0)//
// {
// if(CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[0]
// || CountryCode == country_code_Param[0].name_address[0])//if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158)
// {
// return 0;//返回成功
// }else
// {
// return 1;//返回不成功
// }
// }
// else if(strcmp(area,country_code_Param[1].name) == 0)
// {
// return IF_Country_Code(&country_code_Param[1],CountryCode);
// }
// else if(strcmp(area,country_code_Param[2].name) == 0)
// {
// return IF_Country_Code(&country_code_Param[2],CountryCode);
// }
// else
// {
// }
// return 1;//返回不成功
// }
// #endif
// #endif
// /*____________________________________________________ Country Code func module ____________________________________________________*/
// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/
// #if 0 //国家码函数调用例子
// static void Country_Code_init(void)//方案二
// {
// uint8_t SN_Code[SN_LEN+2] = {0}; //暂时存储序列号
// char area[3] = {0};//保存序列号中的地区码
// uint8_t activate_flag = 0;//激活标志位,该处位局部变量真正工程中需变为全局变量或其它操作
// uint8_t Country_Code = 156;//假如从飞机获取的国家码是156,真正工程中需变为全局变量或其它操作
// Read_SN_FromFlash(SN_Code,SN_LEN); //获取序列号,需更改为工程的对应的获取序列号的函数
// SN_Code[16] = '\0';
// area[0] = SN_Code[4];
// area[1] = SN_Code[5];
// area[2] = '\0';
// activate_flag = Get_Active_State(); //获取激活状态,需更改为工程的对应的获取激活状态的函数
// if(activate_flag == 0x01)//激活后才需要判断国家码与序列号的码是否一致,app_activate_flag == 0x01
// {
// USER_LOG_INFO("SN = %s,activate = %x,CountryCode = %d,area = %s\r\n",SN_Code,activate_flag,Country_Code,area);//输出序列号,国家码,
// activate_flag = Country_Code_handle(Country_Code,area);//获取国家码比对结果。
// USER_LOG_INFO("app_country_flag = %d\r\n",activate_flag);
// if(activate_flag == 0)//国家码与序列号地区码比对一致
// {
// }else
// {
// activate_flag = 0;//非法地区,禁止使用
// }
// }
// }
// #endif
// /*____________________________________________________ "Country_Code_handle()" External call module ____________________________________________________*/
// /*____________________________________________________ Country code test module ____________________________________________________*/
// #if COUNTRY_CODE_TEST //测试国家码是否能对应查找以及对比成功
// /**
// @brief: 传入国家码结构体,判断是否与传入的国家码一致(返回0),不一致返回1
// @Param: code 国家码参数结构体
// @Param: CountryCode 国家码
// @return:no
// */
// uint8_t TEST_IF_Country_Code(T_country_code_param * code , uint16_t CountryCode)
// {
// uint8_t i = 0;
// uint8_t hundred = 0;//存储传进参数的百位的值
// uint8_t hundred_address = 0;//存储传进参数的百位处在第X个元素的位置
// uint8_t number = 0;
// uint8_t state = 1;//返回检查状态
// hundred = CountryCode / 100;//取传进参数的百位在数组中的位置
// if(hundred <= 2)
// {
// hundred = 0;//存放国家码百位为0~2的数据所在位置的数组的第X个元素
// }else if(hundred >=3 && hundred <= 5)
// {
// hundred = 1;
// }else if(hundred >=6 && hundred <= 8)
// {
// hundred = 2;
// }
// hundred_address = code->name_address[hundred];//取国家码百位在X~X+2的数据的位置
// number = code->name_address[hundred_address];//取国家码百位在X~X+2的数据的数量
// for(i = 0;i<number;i++)
// {
// if(CountryCode == code->name_address[hundred_address+(1+i)])//判断这些数据是否与传进参数一致
// {
// state = 0;
// }else
// {
// USER_LOG_INFO("CountryCode = %d\n",code->name_address[hundred_address+(1+i)]); //输出
// vTaskDelay(pdMS_TO_TICKS(2));
// }
// }
// return state;//对比成功,数组中存在该元素
// }
// /**
// @brief: 输入的国家码与序列号中的地区码相同即返回0;否返回1
// @Param: CountryCode 国家码
// @Param: xarea 序列号中的国家码(地区位)
// @return:0/1 成功/失败
// */
// uint8_t TEST_Country_Code_handle(uint16_t CountryCode , char * xarea)
// {
// USER_LOG_INFO("CountryCode = %d,%s\n",CountryCode,xarea); //输出
// if(strcmp(xarea,country_code_Param[0].name) == 0)//
// {
// if(CountryCode == 156 || CountryCode == 344 || CountryCode == 446 || CountryCode == 158)
// {
// return 0;//返回成功
// }else
// {
// return 1;//返回不成功
// }
// }
// else if(strcmp(xarea,country_code_Param[1].name) == 0)
// {
// return TEST_IF_Country_Code(&country_code_Param[1],CountryCode);
// }
// else if(strcmp(xarea,country_code_Param[2].name) == 0)
// {
// return TEST_IF_Country_Code(&country_code_Param[2],CountryCode);
// }
// else
// {
// }
// return 1;//返回不成功
// }
// /**
// @brief: 测试国家码
// @Param: no
// @return:no
// */
// void TEST_guojiama(void)
// {
// char area[5] = {0};//保存序列号中的地区码
// uint8_t state = 2;
// area[0] = 'C';
// area[1] = 'N';
// area[2] = '\0';
// state = TEST_Country_Code_handle(156,area);
// USER_LOG_INFO("%d\r\n",state);//国家码比对结果返回
// vTaskDelay(pdMS_TO_TICKS(500));
// area[0] = 'N';
// area[1] = 'A';
// area[2] = '\0';
// state = TEST_Country_Code_handle(8,area);
// USER_LOG_INFO("%d\r\n",state);
// vTaskDelay(pdMS_TO_TICKS(500));
// area[0] = 'E';
// area[1] = 'U';
// area[2] = '\0';
// state = TEST_Country_Code_handle(800,area);
// USER_LOG_INFO("%d\r\n",state);
// vTaskDelay(pdMS_TO_TICKS(500));
// }
// #endif
// /*____________________________________________________ Country code test module ____________________________________________________*/
... ...
... ... @@ -27,9 +27,10 @@ T_JZsdkReturnCode FOMAT_Get_FirewareOriginRegion();
typedef enum OriginRegionPlace
{
ORIGIN_DEFAULT = 0x0000,
ORIGIN_CN = 0x0001, //中区码
ORIGIN_EN = 0x0002, //英区码
ORIGIN_NA = 0x0003, //南美码
ORIGIN_CN = 0x0001, //中区通用码
ORIGIN_EN = 0x0002, //英区通用码
ORIGIN_NA = 0x0003, //美洲码
ORIGIN_EU = 0x0004, //欧洲码
}OriginRegionPlace;
... ...