Skip to content

Commit

Permalink
fix: add missing transceive options for iOS
Browse files Browse the repository at this point in the history
Related to #31 (comment)
  • Loading branch information
robingenz committed Aug 1, 2024
1 parent c220795 commit 4118c33
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/app/core/services/nfc/nfc/nfc.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import {
Iso15693RequestFlag,
NdefMessage,
NfcTag,
NfcTagTechType,
Expand Down Expand Up @@ -108,6 +109,8 @@ export class NfcService {
public async transceive(
techType: NfcTagTechType,
data: number[],
iso15693RequestFlags?: Iso15693RequestFlag[],
iso15693CommandCode?: number,
): Promise<number[]> {
const isSupported = await this.isSupported();
if (!isSupported) {
Expand All @@ -120,6 +123,8 @@ export class NfcService {
const { response } = await this.capacitorNfcService.transceive({
techType,
data,
iso15693CommandCode,
iso15693RequestFlags,
});
return response;
}
Expand Down
40 changes: 40 additions & 0 deletions src/app/modules/transceive/pages/transceive/transceive.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,46 @@
[(ngModel)]="selectedCommand"
></ion-input>
</ion-item>
@if (isIos && selectedTechType === techType.NfcV) {
<ion-item>
<ion-label position="stacked">ISO 15693 Request Flags</ion-label>
<ion-select
[placeholder]="'Address, CommandSpecificBit8, ...'"
[(ngModel)]="selectedIso15693RequestFlags"
[multiple]="true"
>
<ion-select-option [value]="iso15693RequestFlag.address"
>Address</ion-select-option
>
<ion-select-option [value]="iso15693RequestFlag.commandSpecificBit8"
>CommandSpecificBit8</ion-select-option
>
<ion-select-option [value]="iso15693RequestFlag.dualSubCarriers"
>DualSubCarriers</ion-select-option
>
<ion-select-option [value]="iso15693RequestFlag.highDataRate"
>HighDataRate</ion-select-option
>
<ion-select-option [value]="iso15693RequestFlag.option"
>Option</ion-select-option
>
<ion-select-option [value]="iso15693RequestFlag.protocolExtension"
>ProtocolExtension</ion-select-option
>
<ion-select-option [value]="iso15693RequestFlag.select"
>Select</ion-select-option
>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="stacked">ISO 15693 Command Code</ion-label>
<ion-input
type="number"
[placeholder]="'160'"
[(ngModel)]="selectedIso15693CommandCode"
></ion-input>
</ion-item>
}
<ion-button
expand="block"
(click)="startWriterSession()"
Expand Down
14 changes: 12 additions & 2 deletions src/app/modules/transceive/pages/transceive/transceive.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
TimeoutService,
} from '@app/core';
import { HexToBytesPipe } from '@app/shared/pipes';
import { NfcTagTechType } from '@capawesome-team/capacitor-nfc';
import {
Iso15693RequestFlag,
NfcTagTechType,
} from '@capawesome-team/capacitor-nfc';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Subject, take, takeUntil } from 'rxjs';

Expand All @@ -23,10 +26,15 @@ import { Subject, take, takeUntil } from 'rxjs';
providers: [HexToBytesPipe],
})
export class TransceivePage {
public readonly isAndroid = this.platformService.isAndroid();
public readonly isIos = this.platformService.isIos();
public readonly iso15693RequestFlag = Iso15693RequestFlag;
public readonly techType = NfcTagTechType;

public selectedTechType: NfcTagTechType | undefined;
public selectedCommand: string | undefined;
public selectedIso15693RequestFlags: Iso15693RequestFlag[] | undefined;
public selectedIso15693CommandCode: number | undefined;
public selectedTechType: NfcTagTechType | undefined;
public transceiveResponse: number[] | undefined;

private readonly cancelSubject = new Subject<void>();
Expand Down Expand Up @@ -75,6 +83,8 @@ export class TransceivePage {
this.transceiveResponse = await this.nfcService.transceive(
this.selectedTechType,
data,
this.selectedIso15693RequestFlags,
this.selectedIso15693CommandCode,
);
await this.nfcService.close();
this.changeDetectorRef.detectChanges();
Expand Down

0 comments on commit 4118c33

Please sign in to comment.