Jamel  O'Reilly

Jamel O'Reilly

1658767440

Bluetonium: Bluetooth mapping in Swift

Bluetonium is part of the E-sites iOS Suite.

Bluetonium is a Swift Library that makes it easy to communicate with Bluetooth devices.

Features

  •  🎲 Services and characteristics mapping
  •  👓 Default data transformers
  •  🔧 Reading & writing to peripherals
  •  🌔 Background mode
  •  📻 Scanning and connecting to peripherals
  •  🦅 Swift 3 & 4

Requirements

  • iOS 8.0+
  • Xcode 7.2+

Installation

CocoaPods

Add the following to your Podfile:

pod 'Bluetonium'

Make sure that you are integrating your dependencies using frameworks: add use_frameworks! to your Podfile. Then run pod install.

Carthage

Add the following to your Cartfile:

github "e-sites/Bluetonium"

Run carthage update and follow the steps as described in Carthage's README.

Usage

Get devices

The Manager will handle searching for devices and connecting to them.

import Bluetonium

let manager = Manager()
manager.delegate = self
manager.startScanForDevices()

If a device is found you will get notified by the func manager(_ manager: Manager, didFindDevice device: Device) delegate call. You can also get all found devices in the foundDevices array of your manager.

Connect to a device

Connecting to a device is simple.

manager.connect(with: device)

The device is a device form the foundDevices array.

Create and register a ServiceModel

A ServiceModel subclass will represents a Service, all the properties represent the Characteristics.

This example represents the Battery Service

class BatteryServiceModel: ServiceModel {
    enum Characteristic : String {
        case batteryLevel = "2A19"
    }

    var batteryLevel: UInt8 = 0
    
    override var serviceUUID:String {
        return "180F"
    }
    
    override func mapping(_ map: Map) {
        batteryLevel <- map[Characteristic.batteryLevel.rawValue]
    }
    
}

Register a ServiceModel subclass. Make sure you do this before the device is actually connected.

let batteryServiceModel = BatteryServiceModel()

func manager(_ manager: Manager, willConnectToDevice device: Device) {
    device.register(serviceModel: batteryServiceModel)
}

ServiceModel subclass

A ServiceModel subclass will represents a Service, all the properties represent the Characteristics. Interacting with the peripheral is only possible once the characteristic did became available through the func characteristicBecameAvailable(withUUID UUID: String) function.
Or when the serviceReady boolean is set to true.

It's recommended to create a struct containing static properties of the UUID's along with your ServiceModel this way your app doesn't have to hardcode the UUID in different places and prevents errors. (See example: HeartRateServiceModel in project)

Reading

batteryServiceModel.readValue(withUUID: "2A19")

// Or with completion
batteryServiceModel.readValue(withUUID: "2A19") { value in
    print(value)
}

Writing

batteryServiceModel.batteryLevel = 10
batteryServiceModel.writeValue(withUUID: "2A19")

Custom DataTransformers

It is possible that your characteristic has a custom data format or has a data format not yet supported. Then you can create your own custom DataTransformer for that property.

The custom DataTransformer needs to conform to the DataTransformer protocol which has two functions.

class HeartRateDataTransformer: DataTransformer {
    
    func transform(dataToValue data: Data?) -> MapValue {
        // Used when reading from the characteristic.
        // Transform Data to your property MapValue.
    }
    
    func transform(valueToData value: MapValue?) -> Data {
        // Used when writing to the characteristic.
        // Transform your property MapValue to Data.
    }
    
}

To register your custom DataTransform you can add it to the mapping function:

func mapping(_ map: Map) {
    heartRate <- (map["2A37"], HeartRateDataTransformer())
}

Set notifications for a characteristic

The ServiceModel has a function that will let you register for value changes on the peripheral. When you return true for one of you characteristics it will automatically update the property.

func registerNotifyForCharacteristic(withUUID UUID: String) -> Bool

Contributions

Feedback is appreciated and pull requests are always welcome. Let's make this list longer!

Author: e-sites
Source Code: https://github.com/e-sites/Bluetonium
License: MIT license

#ios #swift 

What is GEEK

Buddha Community

Bluetonium: Bluetooth mapping in Swift
Houston  Sipes

Houston Sipes

1600430400

10 Free Online Resources To Learn Swift Language

Swift is a fast and efficient general-purpose programming language that provides real-time feedback and can be seamlessly incorporated into existing Objective-C code. This is why developers are able to write safer, more reliable code while saving time. It aims to be the best language that can be used for various purposes ranging from systems programming to mobile as well as desktop apps and scaling up to cloud services.

Below here, we list down the 10 best online resources to learn Swift language.

(The list is in no particular order)

#developers corner #free online resources to learn swift language #learn swift #learn swift free #learn swift online free #resources to learn swift #swift language #swift programming

Top Swift Development Companies | Top Swift Developers - TopDevelopers.co

A thoroughly researched list of top Swift developers with ratings & reviews to help find the best Swift development companies around the world.

#swift development service providers #best swift development companies #top swift development companies #swift development solutions #top swift developers #swift

Hire Dedicated Swift Developers

Want to create a native iOS application for your Startup?

Hire Dedicated Swift Developers for end-to-end services like development, migration, upgrade, testing, and support & maintenance. Trust HourlyDeveloper.io our Swift development team for iOS device apps that are high on performance and security.

Consult with experts:- https://bit.ly/2C5M6cz

#hire dedicated swift developers #swift developers #swift development company #swift development services #swift development #swift

Wilford  Pagac

Wilford Pagac

1600362000

Bluetooth Bug Opens Devices to Man-in-the-Middle Attacks

A high-severity Bluetooth vulnerability has been uncovered, which could enable an unauthenticated attacker within wireless range to eavesdrop or alter communications between paired devices.

The flaw (CVE-2020-15802), discovered independently by researchers at the École Polytechnique Fédérale de Lausanne (EPFL) and Purdue University, is being referred to as “BLURtooth.” The issue exists in the pairing process for Bluetooth 4.0 through 5.0 implementations. This pairing process is called Cross-Transport Key Derivation (CTKD).

“Devices… using [CTKD] for pairing are vulnerable to key overwrite, which enables an attacker to gain additional access to profiles or services that are not restricted, by reducing the encryption key strength or overwriting an authenticated key with an unauthenticated key,” according to a security advisory on Wednesday by the Carnegie Mellon CERT Coordination Center.

#vulnerabilities #web security #authentication keys #bluetooth #bluetooth 4.0 #bluetooth 5.0 #bluetooth classic #bluetooth low energy #blurtooth #cross-transport key derivation #cve-2020-15802 #man-in-the-middle attacks #mitm

Best Swift App Development Company

Hire an Exceptional Swift App Developer from Mobile App Development India. Maadi has a dedicated Swift App Development team that is superiorly talented and builds highly functional, cost-effective mobile apps with error-free coding.

Contact: https://www.mobile-app-development-india.com/swift-app-development/

#swift ios app development india #hire swift programmer india #swift ios development #apple swift app development #swift mobile app development #swift app development