Skip to content

Commit

Permalink
Release 2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
grjanoszsilabs committed Feb 2, 2022
1 parent f3c1ccb commit 3b1eefd
Show file tree
Hide file tree
Showing 36 changed files with 374 additions and 1,800 deletions.
246 changes: 120 additions & 126 deletions SiliconLabsApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions SiliconLabsApp/Categories/Data+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ extension Data {
return value
}

var hexDescription: String {
return reduce("") {$0 + String(format: "%02x", $1)}
}

fileprivate func convertData(data: Data) -> [UInt8] {
return [UInt8](data)
}
Expand All @@ -34,8 +38,4 @@ extension Data {
}
return value
}

var hexDescription: String {
return reduce("") {$0 + String(format: "%02x", $1)}
}
}
36 changes: 36 additions & 0 deletions SiliconLabsApp/Categories/Data+ManufacturerData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SILManufacturerData.swift
// BlueGecko
//
// Created by Grzegorz Janosz on 10/01/2022.
// Copyright © 2022 SiliconLabs. All rights reserved.
//

import Foundation

extension Data {
func checkManufacturerData(manufacturerIdentifier: Int, manufacturerData expected: [UInt8], manufacturerDataMask mask: [UInt8]? = nil) -> Bool {
let length = self.bytes.count
guard length > 2 else {
return false
}
let idBytes = Data(bytes: self.bytes[0...1])
guard idBytes.integerValueFromData() == manufacturerIdentifier else {
return false
}

let data = Data(bytes: self.bytes[2...(length - 1)])
guard data.bytes.count == expected.count else {
return false
}

let mask = mask ?? Array(repeating: 1, count: expected.count)
let zipped = Array(zip(expected, mask))
for (ind, (expectedByte, maskByte)) in zipped.enumerated() {
if maskByte != 0 && data.bytes[ind] != expectedByte {
return false
}
}
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class SILGattConfiguratorServiceHelper: SILGattConfiguratorServiceHelperType {
}

func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveRead request: CBATTRequest) {
if let characteristic = self.characteristicMap[request.characteristic.service.uuid]?[request.characteristic.uuid], let value = characteristic.value {
if let service = request.characteristic.service, let characteristic = self.characteristicMap[service.uuid]?[request.characteristic.uuid], let value = characteristic.value {
if request.offset > characteristic.value?.count ?? 0 {
peripheral.respond(to: request, withResult: .invalidOffset)
return
Expand All @@ -191,7 +191,7 @@ class SILGattConfiguratorServiceHelper: SILGattConfiguratorServiceHelperType {

func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveWrite requests: [CBATTRequest]) {
for request in requests {
if let characteristic = self.characteristicMap[request.characteristic.service.uuid]?[request.characteristic.uuid] {
if let service = request.characteristic.service, let characteristic = self.characteristicMap[service.uuid]?[request.characteristic.uuid] {
if request.offset > characteristic.value?.count ?? 0 {
peripheral.respond(to: request, withResult: .invalidOffset)
return
Expand All @@ -206,7 +206,7 @@ class SILGattConfiguratorServiceHelper: SILGattConfiguratorServiceHelperType {
}

func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic) {
if let characteristic = self.characteristicMap[characteristic.service.uuid]?[characteristic.uuid] {
if let service = characteristic.service, let characteristic = self.characteristicMap[service.uuid]?[characteristic.uuid] {
if let value = characteristic.value {
peripheral.updateValue(value, for: characteristic, onSubscribedCentrals: [central])
}
Expand All @@ -215,7 +215,7 @@ class SILGattConfiguratorServiceHelper: SILGattConfiguratorServiceHelperType {
}

func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didUnsubscribeFrom characteristic: CBCharacteristic) {
if let characteristic = self.characteristicMap[characteristic.service.uuid]?[characteristic.uuid] {
if let service = characteristic.service, let characteristic = self.characteristicMap[service.uuid]?[characteristic.uuid] {
print("Subscribed centrals of characteristic after unsubscription ", characteristic.subscribedCentrals ?? "")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="CEc-ja-5sj">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="CEc-ja-5sj">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
Expand Down Expand Up @@ -116,7 +116,7 @@
<rect key="frame" x="70.5" y="112" width="241" height="251.5"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Press the bulb icon to toggle light" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J33-QP-MD6">
<rect key="frame" x="16" y="387.5" width="350" height="14.5"/>
<rect key="frame" x="16" y="387.5" width="350" height="14"/>
<fontDescription key="fontDescription" name="Roboto-Regular" family="Roboto" pointSize="12"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.34000000000000002" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -188,13 +188,13 @@
<rect key="frame" x="0.0" y="553" width="382" height="76"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Last Event" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yYB-uU-a0f">
<rect key="frame" x="16" y="16" width="65.5" height="16.5"/>
<rect key="frame" x="16" y="16" width="66" height="16.5"/>
<fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="14"/>
<color key="textColor" name="sil_subtleTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Light Off" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ta3-We-sUr">
<rect key="frame" x="16" y="36.5" width="62" height="19"/>
<rect key="frame" x="16" y="36.5" width="61.5" height="19"/>
<fontDescription key="fontDescription" name="Roboto-Regular" family="Roboto" pointSize="16"/>
<color key="textColor" name="sil_primaryTextColor"/>
<nil key="highlightedColor"/>
Expand All @@ -220,13 +220,13 @@
<rect key="frame" x="0.0" y="630" width="382" height="76"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Source" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HA3-KL-8VF">
<rect key="frame" x="16" y="16" width="44" height="16.5"/>
<rect key="frame" x="16" y="16" width="44.5" height="16.5"/>
<fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="14"/>
<color key="textColor" name="sil_subtleTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Source: Unknown" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Shi-Bd-t4j">
<rect key="frame" x="16" y="36.5" width="124" height="19"/>
<rect key="frame" x="16" y="36.5" width="127.5" height="19"/>
<fontDescription key="fontDescription" name="Roboto-Regular" family="Roboto" pointSize="16"/>
<color key="textColor" name="sil_primaryTextColor"/>
<nil key="highlightedColor"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<rect key="frame" x="0.0" y="0.0" width="976" height="244"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Connection Parameters" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1Lx-WQ-zr5" userLabel="Title">
<rect key="frame" x="16" y="8" width="191" height="30"/>
<rect key="frame" x="16" y="8" width="190.5" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="4nE-TP-vR4"/>
</constraints>
Expand Down
Loading

0 comments on commit 3b1eefd

Please sign in to comment.