Skip to content

Commit

Permalink
Merge pull request #1115 from dotintent/ios-monorepo
Browse files Browse the repository at this point in the history
refactor: Move MultiplatformBleAdapter to iOS folder
  • Loading branch information
dominik-czupryna-withintent authored Oct 17, 2023
2 parents 1560d5e + b4f29b1 commit 7382fe4
Show file tree
Hide file tree
Showing 220 changed files with 26,990 additions and 76 deletions.
2 changes: 1 addition & 1 deletion example/ios/BlePlxExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = J8TDRBT8NT;
DEVELOPMENT_TEAM = U72M5MDD87;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = BlePlxExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -734,4 +734,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: e43e14d964b1de567b73b376b4538cddb7c50ca9

COCOAPODS: 1.12.1
COCOAPODS: 1.13.0
4 changes: 4 additions & 0 deletions ios/BlePlx-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

444 changes: 444 additions & 0 deletions ios/BlePlx-Swift.h

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions ios/BlePlx.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// BleClient.h
// BleClient
//
// Created by Przemysław Lenart on 27/07/16.
// Copyright © 2016 Polidea. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
Expand Down
11 changes: 10 additions & 1 deletion ios/BlePlx.mm → ios/BlePlx.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
//
// BleClient.m
// BleClient
//
// Created by Przemysław Lenart on 27/07/16.
// Copyright © 2016 Polidea. All rights reserved.
//

#import "BlePlx.h"
@import MultiplatformBleAdapter;
#import "BlePlx-Swift.h"


@interface BlePlx () <BleClientManagerDelegate>
@property(nonatomic) BleClientManager* manager;
Expand Down
1,112 changes: 1,050 additions & 62 deletions ios/BlePlx.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

228 changes: 228 additions & 0 deletions ios/MultiplatformBleAdapter/BleAdapter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
import Foundation

@objc public protocol BleAdapter {

// MARK: - Properties

var delegate: BleClientManagerDelegate? { get set }

// MARK: - Initializers

init(queue: DispatchQueue, restoreIdentifierKey: String?)
func invalidate()

// MARK: - Functions

func cancelTransaction(_ transactionId: String)

func setLogLevel(_ logLevel: String)

func logLevel(_ resolve: Resolve,
reject: Reject)

func enable(_ transactionId: String,
resolve: Resolve,
reject: Reject)

func disable(_ transactionId: String,
resolve: Resolve,
reject: Reject)

func state(_ resolve: Resolve,
reject: Reject)

func startDeviceScan(_ filteredUUIDs: [String]?,
options:[String:AnyObject]?)

func stopDeviceScan()

func readRSSIForDevice(_ deviceIdentifier: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func requestMTUForDevice(_ deviceIdentifier: String,
mtu: Int,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func requestConnectionPriorityForDevice(_ deviceIdentifier: String,
connectionPriority: Int,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func devices(_ deviceIdentifiers: [String],
resolve: @escaping Resolve,
reject: @escaping Reject)

func connectedDevices(_ serviceUUIDs: [String],
resolve: @escaping Resolve,
reject: @escaping Reject)

func connectToDevice(_ deviceIdentifier: String,
options:[String: AnyObject]?,
resolve: @escaping Resolve,
reject: @escaping Reject)

func cancelDeviceConnection(_ deviceIdentifier: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func isDeviceConnected(_ deviceIdentifier: String,
resolve: Resolve,
reject: Reject)

func discoverAllServicesAndCharacteristicsForDevice(_ deviceIdentifier: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func servicesForDevice(_ deviceIdentifier: String,
resolve: Resolve,
reject: Reject)

func characteristicsForDevice(_ deviceIdentifier: String,
serviceUUID: String,
resolve: Resolve,
reject: Reject)

func characteristicsForService(_ serviceIdentifier: Double,
resolve: Resolve,
reject: Reject)

func descriptorsForDevice(_ deviceIdentifier: String,
serviceUUID: String,
characteristicUUID: String,
resolve: Resolve,
reject: Reject)

func descriptorsForService(_ serviceIdentifier: Double,
characteristicUUID: String,
resolve: Resolve,
reject: Reject)

func descriptorsForCharacteristic(_ characteristicIdentifier: Double,
resolve: Resolve,
reject: Reject)


func readCharacteristicForDevice(_ deviceIdentifier: String,
serviceUUID: String,
characteristicUUID: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func readCharacteristicForService(_ serviceIdentifier: Double,
characteristicUUID: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func readCharacteristic(_ characteristicIdentifier: Double,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func writeCharacteristicForDevice(_ deviceIdentifier: String,
serviceUUID: String,
characteristicUUID: String,
valueBase64: String,
response: Bool,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func writeCharacteristicForService(_ serviceIdentifier: Double,
characteristicUUID: String,
valueBase64: String,
response: Bool,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func writeCharacteristic(_ characteristicIdentifier: Double,
valueBase64: String,
response: Bool,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func monitorCharacteristicForDevice(_ deviceIdentifier: String,
serviceUUID: String,
characteristicUUID: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func monitorCharacteristicForService(_ serviceIdentifier: Double,
characteristicUUID: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func monitorCharacteristic(_ characteristicIdentifier: Double,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func readDescriptorForDevice(_ deviceIdentifier: String,
serviceUUID: String,
characteristicUUID: String,
descriptorUUID: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func readDescriptorForService(_ serviceId: Double,
characteristicUUID: String,
descriptorUUID: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func readDescriptorForCharacteristic(_ characteristicID: Double,
descriptorUUID: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func readDescriptor(_ descriptorID: Double,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func writeDescriptorForDevice(_ deviceIdentifier: String,
serviceUUID: String,
characteristicUUID: String,
descriptorUUID: String,
valueBase64: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func writeDescriptorForService(_ serviceID: Double,
characteristicUUID: String,
descriptorUUID: String,
valueBase64: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func writeDescriptorForCharacteristic(_ characteristicID: Double,
descriptorUUID: String,
valueBase64: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)

func writeDescriptor(_ descriptorID: Double,
valueBase64: String,
transactionId: String,
resolve: @escaping Resolve,
reject: @escaping Reject)
}

extension BleClientManager: BleAdapter { }
24 changes: 24 additions & 0 deletions ios/MultiplatformBleAdapter/BleAdapterFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation

public typealias BleAdapterCreator = (_ queue: DispatchQueue, _ restoreIdentifierKey: String?) -> BleAdapter

// MARK: - BleAdapterFactory

@objc
public class BleAdapterFactory: NSObject {

private static var bleAdapterCreator: BleAdapterCreator = { (queue, restoreIdentifierKey) in
return BleClientManager(queue: queue, restoreIdentifierKey: restoreIdentifierKey)
}

@objc
public static func getNewAdapterWithQueue(_ queue: DispatchQueue, restoreIdentifierKey: String?) -> BleAdapter {
return bleAdapterCreator(queue, restoreIdentifierKey)
}

@objc
public static func setBleAdapterCreator(_ bleAdapterCreator: @escaping BleAdapterCreator) {
self.bleAdapterCreator = bleAdapterCreator
}

}
15 changes: 15 additions & 0 deletions ios/MultiplatformBleAdapter/BleClientManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BleClientManager.h
//
// Created by Przemysław Lenart on 27/07/16.
//

#import <UIKit/UIKit.h>

//! Project version number for BleClientManager.
FOUNDATION_EXPORT double BleClientManagerVersionNumber;

//! Project version string for BleClientManager.
FOUNDATION_EXPORT const unsigned char BleClientManagerVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <BleClientManager/PublicHeader.h>
Loading

0 comments on commit 7382fe4

Please sign in to comment.