From 574a1e890fe4a5946dbe58a3f9e2affa52f096bf Mon Sep 17 00:00:00 2001 From: dshalaby Date: Wed, 2 Dec 2020 21:03:29 -0500 Subject: [PATCH] Updates to allow new cmd families with public access --- TCMP/ApplicationErrorMessage.swift | 2 +- TCMP/MessageResolver.swift | 2 +- TCMPTappy.podspec | 2 +- TappyBle/TappyBleCommunicator.swift | 5 ++--- TappyBle/TappyBleDevice.swift | 2 +- TappyBle/TappyBleDeviceDefinition.swift | 12 ++++++++++++ TappyBle/TappyBleScanner.swift | 2 +- TappyReader/TappyStatus.swift | 2 +- 8 files changed, 20 insertions(+), 9 deletions(-) diff --git a/TCMP/ApplicationErrorMessage.swift b/TCMP/ApplicationErrorMessage.swift index 2fe400c..6bc35c5 100644 --- a/TCMP/ApplicationErrorMessage.swift +++ b/TCMP/ApplicationErrorMessage.swift @@ -23,7 +23,7 @@ import Foundation @objc -protocol TCMPApplicationErrorMessage{ +public protocol TCMPApplicationErrorMessage{ var appErrorCode : UInt8 {get} var internalErrorCode : UInt8 {get} var readerStatusCode : UInt8 {get} diff --git a/TCMP/MessageResolver.swift b/TCMP/MessageResolver.swift index f3adf68..48e7a59 100644 --- a/TCMP/MessageResolver.swift +++ b/TCMP/MessageResolver.swift @@ -22,7 +22,7 @@ */ import Foundation @objc -protocol MessageResolver{ +public protocol MessageResolver{ static func resolveCommand(message : TCMPMessage) throws -> TCMPMessage static func resolveResponse(message : TCMPMessage) throws -> TCMPMessage } diff --git a/TCMPTappy.podspec b/TCMPTappy.podspec index 34d1080..5609f46 100644 --- a/TCMPTappy.podspec +++ b/TCMPTappy.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'TCMPTappy' - s.version = '1.1.0' + s.version = '1.2.0' s.summary = 'SDK for using TapTrack Tappy NFC Readers such as the TappyBLE.' # This description is used to generate tags and improve search results. diff --git a/TappyBle/TappyBleCommunicator.swift b/TappyBle/TappyBleCommunicator.swift index bf05791..b4d2824 100644 --- a/TappyBle/TappyBleCommunicator.swift +++ b/TappyBle/TappyBleCommunicator.swift @@ -92,7 +92,7 @@ public class TappyBleCommunicator : NSObject, CBPeripheralDelegate, CBCentralMan return } NSLog("TappyBleCommunicator: CB Central Manager connected to the tappyPeripheral which is a TappyBle, attempting to discover serial service") - tappyPeripheral.discoverServices([TappyBleDeviceDefinition.getSerialServiceUuid(), TappyBleDeviceDefinition.getSerialServiceUuidV5()]) + tappyPeripheral.discoverServices(TappyBleDeviceDefinition.getSerialServiceUuids()) changeStateAndNotify(newState: TappyStatus.STATUS_CONNECTING) }else{ NSLog("TappyBleCommunicator: CB Central Manager connected to an unrecognized peripheral.") @@ -124,7 +124,6 @@ public class TappyBleCommunicator : NSObject, CBPeripheralDelegate, CBCentralMan } } - //MARK : CBPeripheralDelegate @objc public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { @@ -354,7 +353,7 @@ public class TappyBleCommunicator : NSObject, CBPeripheralDelegate, CBCentralMan state = TappyStatus.STATUS_NOT_READY_TO_CONNECT }else if(centralManager.state == .poweredOn){ NSLog("TappyBleCommunicator: BLE is powered on") - if centralManager.retrieveConnectedPeripherals(withServices : [TappyBleDeviceDefinition.getSerialServiceUuid(), TappyBleDeviceDefinition.getSerialServiceUuidV5()]).count != 0 { + if centralManager.retrieveConnectedPeripherals(withServices : TappyBleDeviceDefinition.getSerialServiceUuids()).count != 0 { state = TappyStatus.STATUS_READY }else{ state = TappyStatus.STATUS_DISCONNECTED diff --git a/TappyBle/TappyBleDevice.swift b/TappyBle/TappyBleDevice.swift index 5e1f5f1..80cda86 100644 --- a/TappyBle/TappyBleDevice.swift +++ b/TappyBle/TappyBleDevice.swift @@ -25,7 +25,7 @@ import Foundation @objc public class TappyBleDevice : NSObject { - var deviceName : String + public var deviceName : String @objc public var deviceId : UUID = UUID() @objc public init(name : String, deviceId : UUID){ diff --git a/TappyBle/TappyBleDeviceDefinition.swift b/TappyBle/TappyBleDeviceDefinition.swift index d296838..f7d86dd 100644 --- a/TappyBle/TappyBleDeviceDefinition.swift +++ b/TappyBle/TappyBleDeviceDefinition.swift @@ -56,6 +56,18 @@ import CoreBluetooth return CHARACTERISTIC_TRUCONNECT_PERIPHERAL_RX_UUID } + @objc static public func getSerialServiceUuids() -> [CBUUID]{ + return [getSerialServiceUuid(),getSerialServiceUuidV5()] + } + + @objc static public func getTxCharacteristicUuids() -> [CBUUID]{ + return [getTxCharacteristicUuid(),getTxCharacteristicUuidV5()] + } + + @objc static public func getRxCharacteristicUuids() -> [CBUUID]{ + return [getRxCharacteristicUuid(),getRxCharacteristicUuidV5()] + } + @objc static public func isTappyDeviceName(device : CBPeripheral) -> Bool{ if let peripheralName = device.name{ let upperPName = peripheralName.uppercased() diff --git a/TappyBle/TappyBleScanner.swift b/TappyBle/TappyBleScanner.swift index 5f974c6..f874814 100644 --- a/TappyBle/TappyBleScanner.swift +++ b/TappyBle/TappyBleScanner.swift @@ -72,7 +72,7 @@ public class TappyBleScanner : NSObject, CBCentralManagerDelegate{ @objc public func startScan() -> Bool{ if state == TappyBleScannerStatus.STATUS_POWERED_ON{ - centralManager.scanForPeripherals(withServices: [TappyBleDeviceDefinition.getSerialServiceUuid(), TappyBleDeviceDefinition.getSerialServiceUuidV5()], options: nil) + centralManager.scanForPeripherals(withServices: TappyBleDeviceDefinition.getSerialServiceUuids(), options: nil) changeStateAndNotify(newState: TappyBleScannerStatus.STATUS_SCANNING) return true } diff --git a/TappyReader/TappyStatus.swift b/TappyReader/TappyStatus.swift index 81fded6..9776548 100644 --- a/TappyReader/TappyStatus.swift +++ b/TappyReader/TappyStatus.swift @@ -33,7 +33,7 @@ import Foundation case STATUS_NOT_READY_TO_CONNECT = 7 case STATUS_COMMUNICATOR_ERROR = 8 - func getString() -> String{ + public func getString() -> String{ switch self { case .STATUS_DISCONNECTED: return "STATUS_DISCONNECTED"