-
-
Save RippleAdder/064030a6111fcc4933a15a9db8df37d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// BLENFCTest | |
// | |
// Created by Scott Olson on 2/19/18. | |
// Copyright © 2018 App Data Room. All rights reserved. | |
// | |
#import "ViewController.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController { | |
NSString *_deviceId; | |
} | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
FmConfiguration *defaultConfiguration = [[FmConfiguration alloc] init]; | |
defaultConfiguration.deviceType = kFloBlePlus; // kFloBleEmv for FloBLE Emv | |
//kFlojackMsr, kFlojackBzr for audiojack readers | |
defaultConfiguration.transmitPower = kHighPower; | |
defaultConfiguration.scanSound = @YES; | |
defaultConfiguration.scanPeriod = @1000; | |
defaultConfiguration.powerOperation = kAutoPollingControl; //, kBluetoothConnectionControl for low power usage | |
defaultConfiguration.transmitPower = kHighPower; | |
defaultConfiguration.allowMultiConnect = @NO; | |
defaultConfiguration.specificDeviceUuid = nil; //@"RR330-000120"; | |
flomioMW = [[FmSessionManager flomioMW] initWithConfiguration:defaultConfiguration]; | |
flomioMW.delegate = self; | |
[flomioMW startReaders]; | |
// Stop reader scan when the app becomes inactive | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inactive) name:UIApplicationDidEnterBackgroundNotification object:nil]; | |
// Start reader scan when the app becomes active | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(active) name:UIApplicationDidBecomeActiveNotification object:nil]; | |
} | |
- (void)inactive { | |
NSLog(@"App Inactive"); | |
} | |
- (void)active { | |
NSLog(@"App Active"); | |
} | |
- (void)didFindTag:(FmTag *)tag fromDevice:(NSString *)deviceUuid{ | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
//Use the main queue if the UI must be updated with the tag UUID or the deviceId | |
NSLog(@"Found tag UUID: %@ with ATR: %@ from device:%@",tag.uuid, tag.atr, deviceUuid); | |
}); | |
} | |
- (void)didReceiveReaderError:(NSError *)error { | |
dispatch_async(dispatch_get_main_queue(), ^{ // Second dispatch message to log tag and restore screen | |
NSLog(@"ERROR %@",error); //Reader error | |
}); | |
} | |
- (void)didChangeCardStatus:(CardStatus)status fromDevice:(NSString *)deviceUuid{ | |
NSLog(@"didChangeCardStatus"); | |
} | |
- (IBAction)getConfiguration:(id)sender { | |
FmConfiguration *config = [flomioMW getConfiguration:_deviceId]; | |
NSLog(@"Config: %@", config); | |
} | |
- (void)didChangeStatus:(NSString *)deviceUuid withConfiguration:(FmConfiguration *)configuration andBatteryLevel:(NSNumber *)batteryLevel andCommunicationStatus:(CommunicationStatus)communicationStatus withFirmwareRevision:(NSString *)firmwareRev withHardwareRevision:(NSString *)hardwareRev{ | |
_deviceId = deviceUuid; | |
NSLog(@"didChangeStatus, comm status: %d", (int) (long)communicationStatus); | |
//[flomioMW startReader:deviceUuid]; | |
} | |
- (void)didGetLicenseInfo:(NSString *)deviceUuid withStatus:(BOOL)isRegistered{ | |
NSLog(@"got license info"); | |
} | |
- (IBAction)doTouchButton:(id)sender { | |
// [flomioMW readNdef:_deviceId success:^(NdefMessage *response) { | |
// NSLog(@"hello"); | |
// NSLog(@"Response:%@", response); | |
// }]; | |
// | |
// [flomioMW startReaders]; | |
NSString *adpu =@"FF B0 00 00 10"; | |
[flomioMW sendApdu:adpu toDevice:_deviceId success:^(NSString *response) { | |
if (response.length > 1){ | |
NSString *newLog = [NSString stringWithFormat:@"Sent Command: %@ with Response: %@ from Device:%@", adpu, response, _deviceId]; | |
} | |
}]; | |
} | |
- (void)didReceiveMemoryWarning { | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment