diff --git a/firmware/application/src/ble_main.c b/firmware/application/src/ble_main.c index bcde7e4..c51d87c 100644 --- a/firmware/application/src/ble_main.c +++ b/firmware/application/src/ble_main.c @@ -196,20 +196,20 @@ __INLINE uint32_t map(uint32_t x, uint32_t in_min, uint32_t in_max, uint32_t out return (uint32_t)((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min); } -//电池电压到百分比计算 +//鐢垫睜鐢靛帇鍒扮櫨鍒嗘瘮璁$畻 uint32_t BATVOL2PERCENT(uint16_t VOL) { //100% 4.20V 1 - //90 % 4.06V 80%-100% 白 + //90 % 4.06V 80%-100% 鐧 //80 % 3.98V 1 - //70 % 3.92V 60%-80% 白 + //70 % 3.92V 60%-80% 鐧 //60 % 3.87V 1 - //50 % 3.82V 40%-60% 白 + //50 % 3.82V 40%-60% 鐧 //40 % 3.79V 1 - //30 % 3.77V 20%-40% 白 + //30 % 3.77V 20%-40% 鐧 //20 % 3.74V 1 - //10 % 3.68V 5%-20% 红 - //5 % 3.45V 1 关机 + //10 % 3.68V 5%-20% 绾 + //5 % 3.45V 1 鍏虫満 //0 % 3.00V //#define P100VOL 4200 //#define P80VOL 3980 @@ -219,16 +219,16 @@ uint32_t BATVOL2PERCENT(uint16_t VOL) //#define P5VOL 3450 //100% 4.20V 1 - //90 % 4.00V 80%-100% 白 + //90 % 4.00V 80%-100% 鐧 //80 % 3.89V 1 - //70 % 3.79V 60%-80% 白 + //70 % 3.79V 60%-80% 鐧 //60 % 3.70V 1 - //50 % 3.62V 40%-60% 白 + //50 % 3.62V 40%-60% 鐧 //40 % 3.57V 1 - //30 % 3.53V 20%-40% 白 + //30 % 3.53V 20%-40% 鐧 //20 % 3.51V 1 - //10 % 3.46V 5%-20% 红 - //5 % 3.43V 1 关机 + //10 % 3.46V 5%-20% 绾 + //5 % 3.43V 1 鍏虫満 //0 % 3.00V #define P100VOL 4200 #define P80VOL 3890 @@ -650,12 +650,12 @@ void create_battery_timer(void) { * @brief Function for init ble slave. */ void ble_slave_init(void) { - adc_configure(); // ADC初始化 - create_battery_timer(); // 创建电池电量更新定时器 - ble_stack_init(); // BLE协议栈初始化 - gap_params_init(); // GAP参数初始化 - gatt_init(); // GATT协议初始化 - services_init(); // 服务特征初始化 - advertising_init(); // 广播参数初始化 - conn_params_init(); // 连接参数初始化 + adc_configure(); // ADC鍒濆鍖 + create_battery_timer(); // 鍒涘缓鐢垫睜鐢甸噺鏇存柊瀹氭椂鍣 + ble_stack_init(); // BLE鍗忚鏍堝垵濮嬪寲 + gap_params_init(); // GAP鍙傛暟鍒濆鍖 + gatt_init(); // GATT鍗忚鍒濆鍖 + services_init(); // 鏈嶅姟鐗瑰緛鍒濆鍖 + advertising_init(); // 骞挎挱鍙傛暟鍒濆鍖 + conn_params_init(); // 杩炴帴鍙傛暟鍒濆鍖 } diff --git a/firmware/application/src/rfid/nfctag/tag_base_type.h b/firmware/application/src/rfid/nfctag/tag_base_type.h index 04ef9f7..224b1e2 100644 --- a/firmware/application/src/rfid/nfctag/tag_base_type.h +++ b/firmware/application/src/rfid/nfctag/tag_base_type.h @@ -2,33 +2,33 @@ #define TAG_BASE_TYPE_H -// 场的感应类型 +// 鍦虹殑鎰熷簲绫诲瀷 typedef enum { - // 无场感应 + // 鏃犲満鎰熷簲 TAG_SENSE_NO, - // 低频125khz场感应 + // 浣庨125khz鍦烘劅搴 TAG_SENSE_LF, - // 高频13.56mhz场感应 + // 楂橀13.56mhz鍦烘劅搴 TAG_SENSE_HF, } tag_sense_type_t; /** * - * 所有支持模拟的标签的类型的定义 - * 注意,以下所有定义的标签类型,都是应用层的细化的具体的类型统计 - * 不再区分高低频 + * 鎵鏈夋敮鎸佹ā鎷熺殑鏍囩鐨勭被鍨嬬殑瀹氫箟 + * 娉ㄦ剰锛屼互涓嬫墍鏈夊畾涔夌殑鏍囩绫诲瀷锛岄兘鏄簲鐢ㄥ眰鐨勭粏鍖栫殑鍏蜂綋鐨勭被鍨嬬粺璁 + * 涓嶅啀鍖哄垎楂樹綆棰 */ typedef enum { - // 特定的且必须存在的标志不存在的类型 + // 鐗瑰畾鐨勪笖蹇呴』瀛樺湪鐨勬爣蹇椾笉瀛樺湪鐨勭被鍨 TAG_TYPE_UNKNOWN, - // 125khz(ID卡)系列 + // 125khz锛圛D鍗★級绯诲垪 TAG_TYPE_EM410X, - // Mifare系列 + // Mifare绯诲垪 TAG_TYPE_MIFARE_Mini, TAG_TYPE_MIFARE_1024, TAG_TYPE_MIFARE_2048, TAG_TYPE_MIFARE_4096, - // NTAG系列 + // NTAG绯诲垪 TAG_TYPE_NTAG_213, TAG_TYPE_NTAG_215, TAG_TYPE_NTAG_216, diff --git a/firmware/application/src/rfid/nfctag/tag_persistence.c b/firmware/application/src/rfid/nfctag/tag_persistence.c index 9135202..2bf7a38 100644 --- a/firmware/application/src/rfid/nfctag/tag_persistence.c +++ b/firmware/application/src/rfid/nfctag/tag_persistence.c @@ -28,15 +28,15 @@ void get_fds_map_by_slot_auto_inc_id(uint16_t key, uint16_t id, uint8_t slot, ta /** - * 根据卡槽和卡槽中指定的场类型获得其在FDS中对应的数据的KEY和ID + * 鏍规嵁鍗℃Ы鍜屽崱妲戒腑鎸囧畾鐨勫満绫诲瀷鑾峰緱鍏跺湪FDS涓搴旂殑鏁版嵁鐨凨EY鍜孖D */ void get_fds_map_by_slot_sense_type_for_dump(uint8_t slot, tag_sense_type_t sense_type, fds_slot_record_map_t* map) { - // 根据 @see FDS_SLOT_TAG_DUMP_FILE_KEY 的约定,每个slot以其为起点,每个slot都有其单独的key的record,并且每个slot中独特的场类型也有一个数据的id + // 鏍规嵁 @see FDS_SLOT_TAG_DUMP_FILE_KEY 鐨勭害瀹氾紝姣忎釜slot浠ュ叾涓鸿捣鐐癸紝姣忎釜slot閮芥湁鍏跺崟鐙殑key鐨剅ecord锛屽苟涓旀瘡涓猻lot涓嫭鐗圭殑鍦虹被鍨嬩篃鏈変竴涓暟鎹殑id get_fds_map_by_slot_auto_inc_id(FDS_SLOT_TAG_DUMP_FILE_KEY, FDS_SLOT_TAG_DUMP_FILE_ID, slot, sense_type, map); } /** - * 根据卡槽和卡槽中指定的场类型获得其在FDS中对应的数据的KEY和ID + * 鏍规嵁鍗℃Ы鍜屽崱妲戒腑鎸囧畾鐨勫満绫诲瀷鑾峰緱鍏跺湪FDS涓搴旂殑鏁版嵁鐨凨EY鍜孖D */ void get_fds_map_by_slot_sense_type_for_nick(uint8_t slot, tag_sense_type_t sense_type, fds_slot_record_map_t* map) { get_fds_map_by_slot_auto_inc_id(FDS_SLOT_TAG_NICK_NAME_KEY, FDS_SLOT_TAG_NICK_NAME_ID, slot, sense_type, map); diff --git a/firmware/application/src/rfid/nfctag/tag_persistence.h b/firmware/application/src/rfid/nfctag/tag_persistence.h index bfed46c..d25982e 100644 --- a/firmware/application/src/rfid/nfctag/tag_persistence.h +++ b/firmware/application/src/rfid/nfctag/tag_persistence.h @@ -6,21 +6,21 @@ /* - * 卡槽配置,只有一份,一致即可 + * 鍗℃Ы閰嶇疆锛屽彧鏈変竴浠斤紝涓鑷村嵆鍙 */ #define FDS_CONFIG_RECORD_FILE_KEY 0x1066 #define FDS_CONFIG_RECORD_FILE_ID 0x1066 /* - * 每个卡槽有高低频两种数据,其中key是跟卡槽走的,而id+n就等于数据索引,固定某个索引为指定类型即可 - * 每个slot的file_key都不一样 - * 每个slot有两种类型的卡片,因此有两个数据ID(当前) + * 姣忎釜鍗℃Ы鏈夐珮浣庨涓ょ鏁版嵁锛屽叾涓璳ey鏄窡鍗℃Ы璧扮殑锛岃宨d+n灏辩瓑浜庢暟鎹储寮曪紝鍥哄畾鏌愪釜绱㈠紩涓烘寚瀹氱被鍨嬪嵆鍙 + * 姣忎釜slot鐨刦ile_key閮戒笉涓鏍 + * 姣忎釜slot鏈変袱绉嶇被鍨嬬殑鍗$墖锛屽洜姝ゆ湁涓や釜鏁版嵁ID锛堝綋鍓嶏級 */ #define FDS_SLOT_TAG_DUMP_FILE_KEY 0x1067 #define FDS_SLOT_TAG_DUMP_FILE_ID 0x1067 /* - * 每个卡槽有高低频两种数据,因此卡槽的昵称也要有两种,其中key是跟卡槽走的,而id+n就等于数据索引,固定某个索引为指定类型即可 + * 姣忎釜鍗℃Ы鏈夐珮浣庨涓ょ鏁版嵁锛屽洜姝ゅ崱妲界殑鏄电О涔熻鏈変袱绉嶏紝鍏朵腑key鏄窡鍗℃Ы璧扮殑锛岃宨d+n灏辩瓑浜庢暟鎹储寮曪紝鍥哄畾鏌愪釜绱㈠紩涓烘寚瀹氱被鍨嬪嵆鍙 */ #define FDS_SLOT_TAG_NICK_NAME_KEY 0x1068 #define FDS_SLOT_TAG_NICK_NAME_ID 0x1068 @@ -32,12 +32,12 @@ typedef struct { } fds_slot_record_map_t; /** - * 根据指定的卡槽和卡片场类型,获得其对应的卡片数据的FDS信息的映射对象 + * 鏍规嵁鎸囧畾鐨勫崱妲藉拰鍗$墖鍦虹被鍨嬶紝鑾峰緱鍏跺搴旂殑鍗$墖鏁版嵁鐨凢DS淇℃伅鐨勬槧灏勫璞 */ void get_fds_map_by_slot_sense_type_for_dump(uint8_t slot, tag_sense_type_t sense_type, fds_slot_record_map_t* map); /** - * 根据指定的卡槽和卡片场类型,获得其对应的卡片数据的昵称的FDS信息的映射对象 + * 鏍规嵁鎸囧畾鐨勫崱妲藉拰鍗$墖鍦虹被鍨嬶紝鑾峰緱鍏跺搴旂殑鍗$墖鏁版嵁鐨勬樀绉扮殑FDS淇℃伅鐨勬槧灏勫璞 */ void get_fds_map_by_slot_sense_type_for_nick(uint8_t slot, tag_sense_type_t sense_type, fds_slot_record_map_t* map); diff --git a/firmware/application/src/rfid/reader/hf/mf1_toolbox.h b/firmware/application/src/rfid/reader/hf/mf1_toolbox.h index e5aba00..645bb84 100644 --- a/firmware/application/src/rfid/reader/hf/mf1_toolbox.h +++ b/firmware/application/src/rfid/reader/hf/mf1_toolbox.h @@ -8,8 +8,8 @@ #include -#define SETS_NR 2 // 使用几组随机数探针,至少是2个能确保有两组随机数组合进行交集查询,这个值越大越容易成功 -#define DIST_NR 3 // 越多的距离值越能准确判断当前卡片的通信稳定性 +#define SETS_NR 2 // 浣跨敤鍑犵粍闅忔満鏁版帰閽堬紝鑷冲皯鏄2涓兘纭繚鏈変袱缁勯殢鏈烘暟缁勫悎杩涜浜ら泦鏌ヨ锛岃繖涓艰秺澶ц秺瀹规槗鎴愬姛 +#define DIST_NR 3 // 瓒婂鐨勮窛绂诲艰秺鑳藉噯纭垽鏂綋鍓嶅崱鐗囩殑閫氫俊绋冲畾鎬 // mifare authentication #define CRYPT_NONE 0 @@ -18,16 +18,16 @@ #define AUTH_FIRST 0 #define AUTH_NESTED 2 -typedef struct { // 应答 nested 攻击需要的 距离参数 - uint8_t uid[4]; // 这个距离数据的所属UID的U32部分 - uint8_t distance[4]; // 未经加密的明文随机数 +typedef struct { // 搴旂瓟 nested 鏀诲嚮闇瑕佺殑 璺濈鍙傛暟 + uint8_t uid[4]; // 杩欎釜璺濈鏁版嵁鐨勬墍灞濽ID鐨刄32閮ㄥ垎 + uint8_t distance[4]; // 鏈粡鍔犲瘑鐨勬槑鏂囬殢鏈烘暟 } NestedDist; -typedef struct { // 应答 nested 攻击需要的 随机数参数 - uint8_t nt1[4]; // 未经加密的明文随机数 - uint8_t nt2[4]; // 嵌套验证加密的随机数 - uint8_t par; // 嵌套验证加密的通信过程的奇偶校验位,只用到了 '低3位',也就是右3位 +typedef struct { // 搴旂瓟 nested 鏀诲嚮闇瑕佺殑 闅忔満鏁板弬鏁 + uint8_t nt1[4]; // 鏈粡鍔犲瘑鐨勬槑鏂囬殢鏈烘暟 + uint8_t nt2[4]; // 宓屽楠岃瘉鍔犲瘑鐨勯殢鏈烘暟 + uint8_t par; // 宓屽楠岃瘉鍔犲瘑鐨勯氫俊杩囩▼鐨勫鍋舵牎楠屼綅锛屽彧鐢ㄥ埌浜 '浣3浣'锛屼篃灏辨槸鍙3浣 } NestedCore; typedef struct { diff --git a/firmware/application/src/rfid/reader/lf/data_utils.c b/firmware/application/src/rfid/reader/lf/data_utils.c index 0dfc2ac..4e47fb5 100644 --- a/firmware/application/src/rfid/reader/lf/data_utils.c +++ b/firmware/application/src/rfid/reader/lf/data_utils.c @@ -1,7 +1,7 @@ #include "data_utils.h" #include -//向raw写入2bit数据,datab存0bit,dataa存1bit +//鍚憆aw鍐欏叆2bit鏁版嵁锛宒atab瀛0bit锛宒ataa瀛1bit void writebit(uint8_t *dataa, uint8_t *datab, uint8_t pos, uint8_t adata) { if (adata >= 4) @@ -16,7 +16,7 @@ void writebit(uint8_t *dataa, uint8_t *datab, uint8_t pos, uint8_t adata) getbit(adata, 0) ? setbit(datab[aimbyte], aimbit) : clrbit(datab[aimbyte], aimbit); } -//输出raw的2bit组合数据 +//杈撳嚭raw鐨2bit缁勫悎鏁版嵁 uint8_t readbit(uint8_t *dataa, uint8_t *datab, uint8_t pos) { static uint8_t aimbyte = 0; @@ -28,7 +28,7 @@ uint8_t readbit(uint8_t *dataa, uint8_t *datab, uint8_t pos) (getbit(datab[aimbyte], aimbit))); } -//向raw写入2bit数据(大端方法,每个byte的第8位写数据的第1位),datab存0bit,dataa存1bit +//鍚憆aw鍐欏叆2bit鏁版嵁(澶х鏂规硶锛屾瘡涓猙yte鐨勭8浣嶅啓鏁版嵁鐨勭1浣)锛宒atab瀛0bit锛宒ataa瀛1bit void writebit_msb(uint8_t *dataa, uint8_t *datab, uint8_t pos, uint8_t adata) { if (adata >= 4) @@ -43,7 +43,7 @@ void writebit_msb(uint8_t *dataa, uint8_t *datab, uint8_t pos, uint8_t adata) getbit(adata, 0) ? setbit(datab[aimbyte], aimbit) : clrbit(datab[aimbyte], aimbit); } -//输出raw的2bit组合数据(大端方法,每个byte的第8位读数据的第1位) +//杈撳嚭raw鐨2bit缁勫悎鏁版嵁(澶х鏂规硶锛屾瘡涓猙yte鐨勭8浣嶈鏁版嵁鐨勭1浣) uint8_t readbit_msb(uint8_t *dataa, uint8_t *datab, uint8_t pos) { static uint8_t aimbyte = 0; @@ -55,7 +55,7 @@ uint8_t readbit_msb(uint8_t *dataa, uint8_t *datab, uint8_t pos) (getbit(datab[aimbyte], aimbit))); } -//高低位翻转 +//楂樹綆浣嶇炕杞 uint8_t invert_num(uint8_t num) { uint8_t temp = 0, sh = 0xf; @@ -71,7 +71,7 @@ uint8_t invert_num(uint8_t num) return num; } -//原始数据转换为2倍长度的hex字符数组 +//鍘熷鏁版嵁杞崲涓2鍊嶉暱搴︾殑hex瀛楃鏁扮粍 void ByteToHexStr(uint8_t *source, uint8_t *dest, uint8_t sourceLen) { uint8_t i, highByte, lowByte; diff --git a/firmware/application/src/rfid/reader/lf/lf_reader_data.h b/firmware/application/src/rfid/reader/lf/lf_reader_data.h index 92c575e..9593034 100644 --- a/firmware/application/src/rfid/reader/lf/lf_reader_data.h +++ b/firmware/application/src/rfid/reader/lf/lf_reader_data.h @@ -9,7 +9,7 @@ extern "C" { #endif -typedef void(*RIO_CALLBACK_S)(void); // 调用函数格式 +typedef void(*RIO_CALLBACK_S)(void); // 璋冪敤鍑芥暟鏍煎紡 void register_rio_callback(RIO_CALLBACK_S P); void blank_function(void); diff --git a/firmware/application/src/utils/dataframe.c b/firmware/application/src/utils/dataframe.c index bfe4827..7bc48c8 100644 --- a/firmware/application/src/utils/dataframe.c +++ b/firmware/application/src/utils/dataframe.c @@ -44,11 +44,11 @@ static data_frame_tx_t m_frame_tx_buf_info = { /** - * @brief 数据包创建,将创建之后的数据包放到缓冲区中,等待发送完毕之后设置非busy状态 - * @param cmd: 指令应答 - * @param status: 应答状态 - * @param length: 应答数据长度 - * @param data: 应答数据 + * @brief 鏁版嵁鍖呭垱寤猴紝灏嗗垱寤轰箣鍚庣殑鏁版嵁鍖呮斁鍒扮紦鍐插尯涓紝绛夊緟鍙戦佸畬姣曚箣鍚庤缃潪busy鐘舵 + * @param cmd: 鎸囦护搴旂瓟 + * @param status: 搴旂瓟鐘舵 + * @param length: 搴旂瓟鏁版嵁闀垮害 + * @param data: 搴旂瓟鏁版嵁 */ data_frame_tx_t* data_frame_make(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) { uint8_t lrc_tx = 0x00; @@ -94,9 +94,9 @@ void data_frame_reset(void) { } /** - * @brief 数据包接收,用于接收发送过来的数据包并且进行拼接处理 - * @param data: 接收到的字节数组 - * @param length: 接收到的字节数组的长度 + * @brief 鏁版嵁鍖呮帴鏀讹紝鐢ㄤ簬鎺ユ敹鍙戦佽繃鏉ョ殑鏁版嵁鍖呭苟涓旇繘琛屾嫾鎺ュ鐞 + * @param data: 鎺ユ敹鍒扮殑瀛楄妭鏁扮粍 + * @param length: 鎺ユ敹鍒扮殑瀛楄妭鏁扮粍鐨勯暱搴 */ void data_frame_receive(uint8_t *data, uint16_t length) { // buffer wait process @@ -173,9 +173,9 @@ void data_frame_receive(uint8_t *data, uint16_t length) { } /** - * @brief 数据包处理,当接收到的数据形成了一个完整的帧之后, - * 将会通过此函数分发处理任务,此函数会回调通知数据处理者 - * 如果数据处理是耗时操作,则需要将此函数放在main循环中调用 + * @brief 鏁版嵁鍖呭鐞嗭紝褰撴帴鏀跺埌鐨勬暟鎹舰鎴愪簡涓涓畬鏁寸殑甯т箣鍚庯紝 + * 灏嗕細閫氳繃姝ゅ嚱鏁板垎鍙戝鐞嗕换鍔★紝姝ゅ嚱鏁颁細鍥炶皟閫氱煡鏁版嵁澶勭悊鑰 + * 濡傛灉鏁版嵁澶勭悊鏄楁椂鎿嶄綔锛屽垯闇瑕佸皢姝ゅ嚱鏁版斁鍦╩ain寰幆涓皟鐢 */ void data_frame_process(void) { // check if data frame @@ -191,7 +191,7 @@ void data_frame_process(void) { } /** - * @brief 数据包处理回调注册 + * @brief 鏁版嵁鍖呭鐞嗗洖璋冩敞鍐 */ void on_data_frame_complete(data_frame_cbk_t callback) { m_frame_process_cbk = callback; diff --git a/resource/tools/check_file_encoding.sh b/resource/tools/check_file_encoding.sh new file mode 100755 index 0000000..cf82cee --- /dev/null +++ b/resource/tools/check_file_encoding.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +find . \( -not -path "./firmware/nrf52_sdk/*" -and -not -path "./firmware/objects/*" -and -not -path "./software/script/venv/*" -and -not -path "./software/bin/*" -and -not -path "./software/src/tmp/*" \) -and \( -name "*.[ch]" -or -name "*.py" -or -name "Makefile" -or -name "*.txt" -or -name "*.md" -or -name "*.sh" \) -exec sh -c "cat {} |recode utf8.. >/dev/null || echo {}" \; + +# Chinese encoding: GB18030 extending EUC-CN +# recode GB18030..UTF-8 file.c +# If it fails it could be due to mix of GB18030 & UTF-8 in the same file, check by hand diff --git a/software/src/darkside.c b/software/src/darkside.c index cae89c3..b71c509 100644 --- a/software/src/darkside.c +++ b/software/src/darkside.c @@ -16,12 +16,12 @@ typedef struct { uint64_t ks_list; } DarksideParam; -// 转换字符串为U32类型 +// 杞崲瀛楃涓蹭负U32绫诲瀷 uint64_t atoui(const char* str) { uint64_t result = 0, i = 0; char* tmp = NULL; - for (i = 0; isspace(str[i]) && i < strlen(str); i++)//跳过空白符; + for (i = 0; isspace(str[i]) && i < strlen(str); i++)//璺宠繃绌虹櫧绗; ; tmp = str + i; while (*tmp) @@ -41,7 +41,7 @@ void num_to_bytes(uint64_t n, uint32_t len, uint8_t* dest) } int main(int argc, char* argv[]) { - // 初始化UID + // 鍒濆鍖朥ID uint32_t uid = (uint32_t)atoui(argv[1]); uint32_t count = 0, i = 0; uint32_t keycount = 0; @@ -68,7 +68,7 @@ int main(int argc, char* argv[]) { } for (i = 0; i < count; i++) { - // 初始化NT, NR, AR + // 鍒濆鍖朜T, NR, AR uint32_t nt = dps[i].nt; uint32_t nr = dps[i].nr; uint32_t ar = dps[i].ar; @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) { printf("AR = %"PRIu32"\r\n", ar); */ - // 开始解密 + // 寮濮嬭В瀵 keycount = nonce2key(uid, nt, nr, ar, par_list, ks_list, &keylist); if (keycount == 0) {