GithubHelp home page GithubHelp logo

exphat / swiftbluetooth Goto Github PK

View Code? Open in Web Editor NEW
36.0 6.0 7.0 212 KB

📲 CoreBluetooth API's for modern Swift

License: MIT License

Swift 100.00%
async bluetooth bluetooth-low-energy corebluetooth swift ios

swiftbluetooth's People

Contributors

exphat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

swiftbluetooth's Issues

Include advertisement data and RSSI for discovered peripherals

You are currently ignoring the values here:

But those values are useful. For example, the RSSI provided there is the only way to get the RSSI without connecting to a peripheral first.

Maybe add a initialRSSI and advertisementData property to Peripheral.

Would be nice if advertisementData was a struct based on fetching these keys from the original advertisement data: https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/advertisement_data_retrieval_keys

On a sidenote: I think the RSSI should be returned as a Double, not NSNumber.

`fatalError()` not acceptable in production code

There are 8 cases of fatalError() in the non-test code. This is really not acceptable for production code.

There are several remedies:

  1. These really are coding errors. I don't understand the code well enough yet to know, but if that is the case and since these are all related to knownCharacteristics, then the fatalError() message should include the the known characteristics. However, since known characteristics are specific to a device I don't see how this is the correct solution.
  2. Replace fatalError()s with correct error handling code.

Central#connect should respect cancellation

Something like this:

@available(iOS 13, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
@discardableResult
func connect(_ peripheral: Peripheral, options: [String: Any]? = nil) async throws -> Peripheral {
	try await withTaskCancellationHandler {
		try await withCheckedThrowingContinuation { cont in
			self.connect(peripheral, options: options) { result in
				switch result {
				case .success(let peripheral):
					cont.resume(returning: peripheral)
				case .failure(let error):
					cont.resume(throwing: error)
				}
			}
		}
	} onCancel: {
		cancelPeripheralConnection(peripheral)
	}
}

Privacy manifest (PrivacyInfo.xcprivacy) missing

Hi, Apple announced that, starting May 1, they would start enforcing that all new apps and updates must declare approved reasons for using specific APIs in a privacy manifest, preventing uploads to TestFlight if the requirement is not met.

These requirements also apply to 3rd party SDK's: Upcoming third-party SDK requirements:

Starting May 1: You’ll need to include approved reasons for the listed APIs used by your app’s code to upload a new or updated app to App Store Connect. If you’re not using an API for an allowed reason, please find an alternative. And if you add a new third-party SDK that’s on the list of commonly used third-party SDKs, these API, privacy manifest, and signature requirements will apply to that SDK. Make sure to use a version of the SDK that includes its privacy manifest and note that signatures are also required when the SDK is added as a binary dependency.
This functionality is a step forward for all apps and we encourage all SDKs to adopt it to better support the apps that depend on them.

At this moment, since SwiftBluetooth is not included in the list of commonly used libraries, it is not necessary to include the PrivacyInfo.xcprivacy, but in the future it will be.

I suggest this utility that can help to create the manifest: iOS Privacy Manifest Maker.

Even if no data is collected from what I understand the manifest is mandatory and should be used the empty template:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSPrivacyCollectedDataTypes</key>
    <array/>
	<key>NSPrivacyAccessedAPITypes</key>
    <array/>
</dict>
</plist>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.