mirror of
https://github.com/djhackersdev/minime.git
synced 2026-07-13 14:42:53 -05:00
chuni: add new felica lookup mode
This commit is contained in:
parent
7854f9f3df
commit
e90068f325
|
|
@ -31,6 +31,15 @@ function readFeliCaLookupRequest(msg: Buffer): Request.FeliCaLookupRequest {
|
|||
};
|
||||
}
|
||||
|
||||
function readFeliCaLookupRequest2(msg: Buffer): Request.FeliCaLookup2Request {
|
||||
return {
|
||||
...begin(msg),
|
||||
type: "felica_lookup2",
|
||||
idm: msg.slice(0x0030, 0x0038).toString("hex"),
|
||||
pmm: msg.slice(0x0038, 0x0040).toString("hex"),
|
||||
};
|
||||
}
|
||||
|
||||
function readLogRequest(msg: Buffer): Request.LogRequest {
|
||||
// idk what any of this stuff means yet
|
||||
// field20 and field28 appear to be an aime id but that is all.
|
||||
|
|
@ -98,6 +107,7 @@ readers.set(0x0009, readLogRequest);
|
|||
readers.set(0x000b, readCampaignRequest);
|
||||
readers.set(0x000d, readRegisterRequest);
|
||||
readers.set(0x000f, readLookupRequest2);
|
||||
readers.set(0x0011, readFeliCaLookupRequest2);
|
||||
readers.set(0x0064, readHelloRequest);
|
||||
readers.set(0x0066, readGoodbyeRequest);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ registerLevels.set("segaid", 2);
|
|||
function begin(length: number) {
|
||||
const buf = Buffer.alloc(length);
|
||||
|
||||
buf.writeUInt16LE(0xa13e, 0x0000); // Magic?
|
||||
buf.writeUInt16LE(0xa13e, 0x0000); // Magic: aime
|
||||
buf.writeUInt16LE(0x3087, 0x0002); // ???
|
||||
buf.writeUInt16LE(length, 0x0006);
|
||||
|
||||
|
|
@ -43,6 +43,18 @@ export class Encoder extends Transform {
|
|||
|
||||
break;
|
||||
|
||||
case "felica_lookup2":
|
||||
buf = begin(0x0140);
|
||||
buf.writeUInt16LE(0x0012, 0x0004); // cmd code
|
||||
buf.writeUInt16LE(msg.status, 0x0008);
|
||||
buf.writeInt32LE(msg.aimeId || -1, 0x0020);
|
||||
buf.writeUInt32LE(0xffffffff, 0x0024); // FF
|
||||
buf.writeUInt32LE(0xffffffff, 0x0028); // FF
|
||||
buf.write(msg.accessCode, 0x002c, "hex");
|
||||
buf.writeUInt16LE(0x0001, 0x0037); // 00 01
|
||||
|
||||
break;
|
||||
|
||||
case "hello":
|
||||
buf = begin(0x0020);
|
||||
buf.writeUInt16LE(0x0065, 0x0004); // cmd code
|
||||
|
|
|
|||
|
|
@ -46,6 +46,28 @@ function feliCaLookup(
|
|||
return { type: req.type, status: 1, accessCode };
|
||||
}
|
||||
|
||||
async function feliCaLookup2(
|
||||
rep: Repositories,
|
||||
req: Req.FeliCaLookup2Request,
|
||||
now: Date
|
||||
): Promise<Res.FeliCaLookup2Response> {
|
||||
debug("FeliCa access code lookup");
|
||||
|
||||
const num = BigInt("0x" + req.idm);
|
||||
let accessCode = num.toString();
|
||||
|
||||
while (accessCode.length < 20) {
|
||||
accessCode = "0" + accessCode;
|
||||
}
|
||||
|
||||
return {
|
||||
type: req.type,
|
||||
status: 1,
|
||||
accessCode,
|
||||
aimeId: await rep.cards().lookup(accessCode, now),
|
||||
};
|
||||
}
|
||||
|
||||
async function lookup(
|
||||
rep: Repositories,
|
||||
req: Req.LookupRequest,
|
||||
|
|
@ -115,6 +137,9 @@ export async function dispatch(
|
|||
case "felica_lookup":
|
||||
return feliCaLookup(rep, req, now);
|
||||
|
||||
case "felica_lookup2":
|
||||
return feliCaLookup2(rep, req, now);
|
||||
|
||||
case "lookup":
|
||||
return lookup(rep, req, now);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,12 @@ export interface FeliCaLookupRequest extends AimeRequestBase {
|
|||
pmm: string;
|
||||
}
|
||||
|
||||
export interface FeliCaLookup2Request extends AimeRequestBase {
|
||||
type: "felica_lookup2";
|
||||
idm: string;
|
||||
pmm: string;
|
||||
}
|
||||
|
||||
export interface RegisterRequest extends AimeRequestBase {
|
||||
type: "register";
|
||||
luid: string;
|
||||
|
|
@ -50,6 +56,7 @@ export interface GoodbyeRequest {
|
|||
|
||||
export type AimeRequest =
|
||||
| FeliCaLookupRequest
|
||||
| FeliCaLookup2Request
|
||||
| CampaignRequest
|
||||
| GoodbyeRequest
|
||||
| HelloRequest
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ export interface FeliCaLookupResponse extends AimeResponseBase {
|
|||
accessCode: string;
|
||||
}
|
||||
|
||||
export interface FeliCaLookup2Response extends AimeResponseBase {
|
||||
type: "felica_lookup2";
|
||||
accessCode: string;
|
||||
aimeId?: AimeId;
|
||||
}
|
||||
|
||||
export interface CampaignResponse extends AimeResponseBase {
|
||||
type: "campaign";
|
||||
}
|
||||
|
|
@ -44,6 +50,7 @@ export interface RegisterResponse extends AimeResponseBase {
|
|||
|
||||
export type AimeResponse =
|
||||
| FeliCaLookupResponse
|
||||
| FeliCaLookup2Response
|
||||
| CampaignResponse
|
||||
| HelloResponse
|
||||
| LogResponse
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user