Fixed identify RFID Tag correctly in OCPI
MODIFY
src/server/ocpi/OCPIUtils.ts
src/server/ocpi/OCPIUtils.ts
@@ -183,7 +183,8 @@ export default class OCPIUtils {
public static getOcpiTokenTypeFromID(tagID: string): OCPITokenType {
// Virtual badges handling
- return tagID.length % 8 === 0 ? OCPITokenType.RFID : OCPITokenType.OTHER;
+ return (tagID.length % 8 === 0 || tagID.length === 14) &&
+ Utils.isHexString(tagID) ? OCPITokenType.RFID : OCPITokenType.OTHER;
}
public static buildEmspTokenFromTag(tenant: Tenant, tag: Tag): OCPIToken {

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -1327,6 +1327,11 @@ export default class Utils {
return `'${tenant.name}' ('${tenant.subdomain}')`;
}
+ public static isHexString(hexValue: string): boolean {
+ // eslint-disable-next-line no-useless-escape
+ return /^[0-9A-Fa-f]*$/i.test(hexValue);
+ }
+
public static isChargingStationIDValid(name: string): boolean {
// eslint-disable-next-line no-useless-escape
return /^[A-Za-z0-9_\.\-~]*$/.test(name);

Fixed identify RFID Tag correctly in OCPI