Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command to send commands to MiFare tags #4

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions RxCoreNFC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
E6A6ACC624C1D4C10069F67B /* RxNFCFeliCaRequestSystemCodeResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A6ACC524C1D4C10069F67B /* RxNFCFeliCaRequestSystemCodeResult.swift */; };
E6A6ACC824C1D5450069F67B /* RxNFCFeliCaResetModeResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A6ACC724C1D5450069F67B /* RxNFCFeliCaResetModeResult.swift */; };
E6A6ADD824C46CFA0069F67B /* RxNFCFeliCaSendFeliCaCommandResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A6ADD724C46CFA0069F67B /* RxNFCFeliCaSendFeliCaCommandResult.swift */; };
E6A6AE1024C5E1B60069F67B /* RxNFCMiFareSendMiFareCommandResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A6AE0F24C5E1B60069F67B /* RxNFCMiFareSendMiFareCommandResult.swift */; };
E6BF06EC249C9D82007E84D3 /* RxCoreNFC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E6BF06E2249C9D82007E84D3 /* RxCoreNFC.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -75,6 +76,7 @@
E6A6ACC524C1D4C10069F67B /* RxNFCFeliCaRequestSystemCodeResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxNFCFeliCaRequestSystemCodeResult.swift; sourceTree = "<group>"; };
E6A6ACC724C1D5450069F67B /* RxNFCFeliCaResetModeResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxNFCFeliCaResetModeResult.swift; sourceTree = "<group>"; };
E6A6ADD724C46CFA0069F67B /* RxNFCFeliCaSendFeliCaCommandResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxNFCFeliCaSendFeliCaCommandResult.swift; sourceTree = "<group>"; };
E6A6AE0F24C5E1B60069F67B /* RxNFCMiFareSendMiFareCommandResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxNFCMiFareSendMiFareCommandResult.swift; sourceTree = "<group>"; };
E6BF06E2249C9D82007E84D3 /* RxCoreNFC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxCoreNFC.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E6BF06EB249C9D82007E84D3 /* RxCoreNFCTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RxCoreNFCTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -218,6 +220,7 @@
E6A6ADD524C302F80069F67B /* NFCMiFareTag */ = {
isa = PBXGroup;
children = (
E6A6AE0E24C5E1990069F67B /* Entity */,
E6A2A61B24A631B400282503 /* NFCMiFareTag+Rx.swift */,
);
path = NFCMiFareTag;
Expand All @@ -231,6 +234,14 @@
path = NFCTag;
sourceTree = "<group>";
};
E6A6AE0E24C5E1990069F67B /* Entity */ = {
isa = PBXGroup;
children = (
E6A6AE0F24C5E1B60069F67B /* RxNFCMiFareSendMiFareCommandResult.swift */,
);
path = Entity;
sourceTree = "<group>";
};
E6BF06D8249C9D82007E84D3 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -378,6 +389,7 @@
E6A2A61624A6275500282503 /* NFCISO7816Tag+Rx.swift in Sources */,
E6A6ADD824C46CFA0069F67B /* RxNFCFeliCaSendFeliCaCommandResult.swift in Sources */,
E6A2A60E24A377A300282503 /* RxNFCTagReaderSessionEvent.swift in Sources */,
E6A6AE1024C5E1B60069F67B /* RxNFCMiFareSendMiFareCommandResult.swift in Sources */,
E6A2A7F824C1646000282503 /* RxNFCFeliCaRequestServiceV2Result.swift in Sources */,
E6A2A61A24A62D5400282503 /* RxNFCReaderError.swift in Sources */,
E6A6ACC824C1D5450069F67B /* RxNFCFeliCaResetModeResult.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// RxNFCMiFareSendMiFareCommandResult.swift
// RxCoreNFC
//
// Created by Karibash on 2020/07/20.
// Copyright © 2020 Karibash. All rights reserved.
//

import Foundation

@available(iOS 13.0, *)
public struct RxNFCMiFareSendMiFareCommandResult {
let data: Data
}
24 changes: 24 additions & 0 deletions Sources/NFCMiFareTag/NFCMiFareTag+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,28 @@ import RxSwift

@available(iOS 13.0, *)
extension ObservableType where Element == NFCMiFareTag {

// MARK: - Commands -

/// Sends a native MiFare command to the tag.
/// - Important: For NFCMiFareFamily.ultralight commands, you must calculate a 2-byte CRC value and append it to the end of the command data.
/// - Parameter commandPacket: A MiFare command.
/// - Returns: An NSData object containing the tag's response data for the command.
public func sendMiFareCommand(commandPacket: Data) -> Observable<RxNFCMiFareSendMiFareCommandResult> {
flatMap { tag in
Single.create { observer in
tag.sendMiFareCommand(commandPacket: commandPacket) { data, error in
if error != nil {
observer(.error(error!))
} else {
observer(.success(RxNFCMiFareSendMiFareCommandResult(
data: data
)))
}
}
return Disposables.create()
}
}
}

}