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