feat: change login mount package
This commit is contained in:
parent
d41a162562
commit
99adb1d513
|
@ -5,6 +5,7 @@ import 'package:f_r_e_hub/custom_code/actions/get_dev_u_u_i_d.dart';
|
|||
import 'package:f_r_e_hub/pages/home_page/home_page_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:sqflite/utils/utils.dart';
|
||||
import 'dart:developer' as developer;
|
||||
|
||||
import '/actions/actions.dart' as action_blocks;
|
||||
|
@ -508,52 +509,55 @@ Future changeStatusAction(
|
|||
|
||||
|
||||
Uint8List assembleQRPacket(int direction, String identifier, String password) {
|
||||
Uint8List packet = Uint8List(20);
|
||||
int position = 0;
|
||||
int check = 0;
|
||||
List<int> packet = [direction];
|
||||
|
||||
// Direction
|
||||
packet[position++] = direction;
|
||||
String paddedBadge = identifier.padLeft(30, '0');
|
||||
|
||||
// Identifier
|
||||
Uint8List ide = hexStringToByteArray(("000000000000000000000000000000" + identifier).substring(identifier.length));
|
||||
for (int i = 0; i < ide.length; i++) {
|
||||
packet[position++] = ide[i];
|
||||
developer.log("Badge: $paddedBadge");
|
||||
|
||||
for (var i = 0; i < paddedBadge.length; i += 2) {
|
||||
packet.add(int.parse(paddedBadge.substring(i, i + 2), radix: 16));
|
||||
}
|
||||
|
||||
// Date and time
|
||||
DateTime now = DateTime.now();
|
||||
int day = int.parse(DateFormat('dd').format(now));
|
||||
int month = int.parse(DateFormat('MM').format(now));
|
||||
int year = int.parse(DateFormat('yy').format(now));
|
||||
int hour = int.parse(DateFormat('HH').format(now));
|
||||
int minute = int.parse(DateFormat('mm').format(now));
|
||||
int year = now.year % 100;
|
||||
int month = now.month;
|
||||
int day = now.day;
|
||||
int hour = now.hour;
|
||||
int minute = now.minute;
|
||||
|
||||
int sumDate = year + month + day + hour + minute;
|
||||
packet[position++] = (sumDate == 0x0D || sumDate == 0x0A) ? 0xFF : sumDate;
|
||||
int sum = year + month + day + hour + minute;
|
||||
|
||||
// Log the sumDate
|
||||
developer.log("Soma Data: $sumDate", name: "ROTINAS");
|
||||
|
||||
// Password
|
||||
Uint8List passBytes = hexStringToByteArray(password);
|
||||
packet[position++] = passBytes[0];
|
||||
packet[position++] = passBytes[1];
|
||||
|
||||
// Checksum
|
||||
for (int i = 0; i < packet.length - 1; i++) {
|
||||
check ^= packet[i];
|
||||
if (sum == int.parse('0D', radix: 16) || sum == int.parse('0A', radix: 16)) {
|
||||
packet.add(int.parse('FF', radix: 16));
|
||||
} else {
|
||||
packet.add(sum);
|
||||
}
|
||||
packet[position] = (check == 0x0D || check == 0x0A) ? 0xFF : check;
|
||||
|
||||
// Log the checksum
|
||||
developer.log("Checksum: $check", name: "ROTINAS");
|
||||
String paddedPassword = password.length != 4 ? 'FFFF' : password;
|
||||
|
||||
// Convert packet to hex string and log it
|
||||
String hexPacket = byteToHexa(packet);
|
||||
developer.log("Pacote final: $hexPacket", name: "ROTINAS");
|
||||
for (var i = 0; i < paddedPassword.length; i += 2) {
|
||||
packet.add(int.parse(paddedPassword.substring(i, i + 2), radix: 16));
|
||||
}
|
||||
|
||||
return packet;
|
||||
int check = 0x00;
|
||||
|
||||
for (var b in packet) {
|
||||
check ^= b;
|
||||
}
|
||||
|
||||
if (check == int.parse('0D', radix: 16) || check == int.parse('0A', radix: 16)) {
|
||||
packet.add(int.parse('FF', radix: 16));
|
||||
} else {
|
||||
packet.add(check);
|
||||
}
|
||||
|
||||
var bytes = packet.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join((' '));
|
||||
|
||||
developer.log("Pacote: $packet");
|
||||
developer.log("Bytes: $bytes");
|
||||
|
||||
return Uint8List.fromList(packet);
|
||||
}
|
||||
|
||||
Uint8List hexStringToByteArray(String s) {
|
||||
|
@ -569,12 +573,8 @@ String byteToHexa(List<int> pDados) {
|
|||
return pDados.map((byte) => byte.toRadixString(16).padLeft(2, '0').toUpperCase()).join();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String byteToString(Uint8List bytes) {
|
||||
return utf8.decode(bytes);
|
||||
return utf8.decode(bytes, allowMalformed: true);
|
||||
}
|
||||
|
||||
Widget buildQrCode(
|
||||
|
@ -590,9 +590,6 @@ Widget buildQrCode(
|
|||
required int direction
|
||||
}
|
||||
) {
|
||||
debugPrint('remoteID: ${FFAppState().userDevUUID}');
|
||||
debugPrint('androidId: ${FFAppState().devUUID}');
|
||||
debugPrint('Serial Number: ${FFAppState().serialNumber}');
|
||||
|
||||
try {
|
||||
// Verifica se os dados estão de acordo com as regras de negócio
|
||||
|
@ -608,7 +605,7 @@ Widget buildQrCode(
|
|||
data: byteToString(assembleQRPacket(direction, identifier, pass)),
|
||||
version: version, //QrVersions.auto
|
||||
size: dimension,
|
||||
// errorCorrectionLevel: errorCorrectLevel,
|
||||
errorCorrectionLevel: errorCorrectLevel,
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: foregroundColor,
|
||||
gapless: false, // Ajuste conforme necessário
|
||||
|
|
|
@ -157,7 +157,7 @@ void dispose() {
|
|||
maskPattern: -1,
|
||||
version: QrVersions.auto,
|
||||
identifier: FFAppState().userDevUUID,
|
||||
pass: '12313123',
|
||||
pass: '1234',
|
||||
direction: 5,
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue