Skip to content

Commit

Permalink
Add FeliCa tag write without encryption commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Karibash committed Jul 14, 2020
1 parent f9e12c8 commit 480f9ce
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Sources/NFCTagReader/NFCFeliCaTag+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public typealias RxNFCFelicaRequestServiceV2Response = (statusFlag1: Int, status
@available(iOS 13.0, *)
public typealias RxNFCFelicaReadWithoutEncryptionResponse = (statusFlag1: Int, statusFlag2: Int, dataList: [Data])

@available(iOS 13.0, *)
public typealias RxNFCFelicaWriteWithoutEncryptionResponse = (statusFlag1: Int, statusFlag2: Int)

@available(iOS 13.0, *)
public typealias RxNFCFelicaRequestSpecificationVersionResponse = (statusFlag1: Int, statusFlag2: Int, basicVersion: Data, optionVersion: Data)

Expand Down Expand Up @@ -108,6 +111,29 @@ extension ObservableType where Element == NFCFeliCaTag {
}
}

public func writeWithoutEncryption(
serviceCodeList: [Data],
blockList: [Data],
blockData: [Data]
) -> Observable<RxNFCFelicaWriteWithoutEncryptionResponse> {
flatMap { tag in
Single.create { observer in
tag.writeWithoutEncryption(
serviceCodeList: serviceCodeList,
blockList: blockList,
blockData: blockData
) { statusFlag1, statusFlag2, error in
if error != nil {
observer(.error(error!))
} else {
observer(.success((statusFlag1, statusFlag2)))
}
}
return Disposables.create()
}
}
}

public func requestResponse() -> Observable<Int> {
flatMap { tag in
Single.create { observer in
Expand Down

0 comments on commit 480f9ce

Please sign in to comment.