Skip to content

Commit

Permalink
Release 2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasyl Haievyi committed Jul 22, 2021
1 parent b9b42f1 commit 532a906
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 50 deletions.
8 changes: 4 additions & 4 deletions SiliconLabsApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5614,7 +5614,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 37;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 52444FG85C;
DISPLAY_NAME = "EFR Connect";
Expand All @@ -5624,7 +5624,7 @@
INFOPLIST_FILE = "$(SRCROOT)/SiliconLabsApp/SupportingFiles/BlueGecko/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.3.0;
MARKETING_VERSION = 2.3.1;
PRODUCT_BUNDLE_IDENTIFIER = com.silabs.BlueGeckoDemoApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Blue Gecko Development";
Expand All @@ -5648,7 +5648,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 37;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 52444FG85C;
DISPLAY_NAME = "EFR Connect";
Expand All @@ -5657,7 +5657,7 @@
INFOPLIST_FILE = "$(SRCROOT)/SiliconLabsApp/SupportingFiles/BlueGecko/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.3.0;
MARKETING_VERSION = 2.3.1;
PRODUCT_BUNDLE_IDENTIFIER = com.silabs.BlueGeckoDemoApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Blue Gecko Development";
Expand Down
9 changes: 4 additions & 5 deletions SiliconLabsApp/Models/SILThroughputPeripheralDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ protocol SILThroughputPeripheralDelegateType: class {
func subscribeGATT()
func readConnectionParameters()
func stopTesting()
func getMTU(for writeType: CBCharacteristicWriteType) -> Int
func phoneToEFRStatusChanged(isTesting: Bool)
}

Expand All @@ -36,6 +35,7 @@ class SILThroughputPeripheralDelegate : NSObject, SILThroughputPeripheralDelegat
private var throughputCountInBits = 0
private var currentTestType = SILThroughputTestType.none
private var throughputReleaseTimer: Timer?
private var packetReceivedCount = 0

private var peripheral: CBPeripheral
private var throughputPeripheralReferences: SILThroughputPeripheralGATTReferences
Expand Down Expand Up @@ -102,10 +102,6 @@ class SILThroughputPeripheralDelegate : NSObject, SILThroughputPeripheralDelegat
throughputReleaseTimer = nil
}

func getMTU(for writeType: CBCharacteristicWriteType) -> Int {
return peripheral.maximumWriteValueLength(for: writeType)
}

func phoneToEFRStatusChanged(isTesting: Bool) {
debugPrint("UPDATE PHONE TO EFR TEST STATUS \(isTesting)")

Expand Down Expand Up @@ -271,6 +267,7 @@ class SILThroughputPeripheralDelegate : NSObject, SILThroughputPeripheralDelegat
if characteristic.uuid.uuidString == SILThroughputPeripheralGATTDatabase.ThroughputService.ThroughputNotifications.uuid || characteristic.uuid.uuidString == SILThroughputPeripheralGATTDatabase.ThroughputService.ThroughputIndications.uuid {
if let value = characteristic.value {
throughputCountInBits += value.count * 8
packetReceivedCount += 1

if currentTestType == .none {
if characteristic.uuid.uuidString == SILThroughputPeripheralGATTDatabase.ThroughputService.ThroughputNotifications.uuid {
Expand Down Expand Up @@ -320,6 +317,8 @@ class SILThroughputPeripheralDelegate : NSObject, SILThroughputPeripheralDelegat
private func didUpdateThroughputResult(value: Data?) {
self.throughputResult.value = SILThroughputResult(sender: .EFRToPhone, testType: self.currentTestType, valueInBits: 0)
debugPrint("RELEASE FROM EFR \(self.throughputResult.value.valueInBits)")
debugPrint("CNT: \(packetReceivedCount)")
self.packetReceivedCount = 0
self.throughputCountInBits = 0
self.currentTestType = .none
}
Expand Down
71 changes: 47 additions & 24 deletions SiliconLabsApp/Models/SILThroughputPeripheralManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ protocol SILThroughputPeripheralManagerType {
func startAdveritising()
func stopAdvertising()
func setSubscriber(uuid: String)
func setMtu(mtu: Int, for writeType: CBCharacteristicWriteType)
func setConnectionInterval(in ms: Int)
func startTest(type: SILThroughputTestType)
func stopTest()
Expand All @@ -64,14 +63,15 @@ class SILThroughputPeripheralManager: NSObject, SILThroughputPeripheralManagerTy
private var transmissionOnCharacteristic: CBMutableCharacteristic?

private var connectionInterval: Int = -1
private var mtuWriteResponse: Int = -1
private var mtuWriteNoResponse: Int = -1
private var writeToCharTimer: Timer?
private var releaseTimer: Timer?
private var throughputCountInBits = 0
private var currentTestType = SILThroughputTestType.none

private var packetNumber = 1
private var dataSize = 0
private var checkIfEFRSubscribedTimer: Timer?
private var packetSentCount = 0

override init() {
super.init()
Expand Down Expand Up @@ -102,7 +102,8 @@ class SILThroughputPeripheralManager: NSObject, SILThroughputPeripheralManagerTy
debugPrint("SUBSCRIBER SET TO \(uuid)")
subscriber.connectedPeripheralUUID = uuid

checkIfEFRSubscribedTimer = Timer.scheduledTimer(withTimeInterval: 2.5, repeats: false, block: { timer in
let timeForEFRToSubscribeCharacteristics = TimeInterval(2.5)
checkIfEFRSubscribedTimer = Timer.scheduledTimer(withTimeInterval: timeForEFRToSubscribeCharacteristics, repeats: false, block: { timer in
timer.invalidate()

self.isSubscribed.value = self.subscriber.isSubscribed()
Expand All @@ -114,53 +115,75 @@ class SILThroughputPeripheralManager: NSObject, SILThroughputPeripheralManagerTy
self.connectionInterval = ms
}

func setMtu(mtu: Int, for writeType: CBCharacteristicWriteType) {
debugPrint("SET MTU TO \(mtu) for \(writeType.rawValue)")
if writeType == .withResponse {
self.mtuWriteResponse = mtu
} else {
self.mtuWriteNoResponse = mtu
}
}

// Notifications can be sent without waiting for response, indications can be sent one per 2 * interval
// More information here https://www.silabs.com/community/wireless/bluetooth/knowledge-base.entry.html/2015/08/06/throughput_with_blue-Wybp
func startTest(type: SILThroughputTestType) {
var dataSize = 0
var characteristicToWrite = self.indicationCharacteristic!
var timeInterval: TimeInterval
dataSize = subscriber.subscriber!.maximumUpdateValueLength
if type == .indications {
debugPrint("START INDICATIONS TEST")
characteristicToWrite = self.indicationCharacteristic!
dataSize = self.mtuWriteNoResponse
timeInterval = TimeInterval(Double(self.connectionInterval * 2) / 1000.0)
debugPrint("START INDICATIONS TEST WITH DATA SIZE \(dataSize)")
} else if type == .notifications {
debugPrint("START NOTICATIONS TEST")
characteristicToWrite = self.notificationCharacteristic!
dataSize = self.mtuWriteResponse
timeInterval = TimeInterval(0.005)
debugPrint("START NOTIFICATIONS TEST WITH DATA SIZE \(dataSize)")
} else {
return
}

self.peripheralManager.updateValue(SILThroughputPeripheralGATTDatabase.ThroughputService.TransmissionOn.WriteValues.active, for: transmissionOnCharacteristic!, onSubscribedCentrals: nil)

writeToCharTimer = Timer.scheduledTimer(withTimeInterval: TimeInterval(Double(connectionInterval) / 1000.0), repeats: true, block: { timer in
self.peripheralManager.updateValue(Data(repeating: 0x00, count: dataSize), for: characteristicToWrite, onSubscribedCentrals: nil)
self.throughputCountInBits += dataSize * 8
writeToCharTimer = Timer.scheduledTimer(withTimeInterval: timeInterval, repeats: true, block: { timer in
var dataArray = [UInt8]()
dataArray.append(UInt8(self.packetNumber))

for i in 0..<self.dataSize - 1 {
dataArray.append(self.appendNextLetter(i: i))
}

if self.peripheralManager.updateValue(Data(dataArray), for: characteristicToWrite, onSubscribedCentrals: nil) {
debugPrint("UPDATE - SENT")
self.throughputCountInBits += self.dataSize * 8
self.packetNumber = (self.packetNumber + 1) % 100
self.packetSentCount += 1
} else {
debugPrint("UPDATE - NOT SENT")
}
})

releaseTimer = Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true, block: { timer in
let timeBetweenUIUpdates = TimeInterval(0.2)
releaseTimer = Timer.scheduledTimer(withTimeInterval: timeBetweenUIUpdates, repeats: true, block: { timer in
debugPrint("RELEASE FROM PHONE \(self.throughputCountInBits)")
self.throughputResult.value = SILThroughputResult(sender: .phoneToEFR, testType: type, valueInBits: self.throughputCountInBits * 5)
self.throughputCountInBits = 0
})

throughputResult.value = SILThroughputResult(sender: .phoneToEFR, testType: type, valueInBits: 0)
}

func appendNextLetter(i: Int) -> UInt8 {
return UInt8(97 + (i - 1) % 26)
}

func stopTest() {
writeToCharTimer?.invalidate()
releaseTimer?.invalidate()
throughputCountInBits = 0
packetNumber = 1
dataSize = 0
throughputResult.value = SILThroughputResult(sender: .phoneToEFR, testType: .none, valueInBits: 0)

self.peripheralManager.updateValue(SILThroughputPeripheralGATTDatabase.ThroughputService.TransmissionOn.WriteValues.disable, for: transmissionOnCharacteristic!, onSubscribedCentrals: nil)
debugPrint("CNT: \(self.packetSentCount)")
self.packetSentCount = 0

let timeToEnsureThatDisableMessageIsSentAfterLastDataPacket = TimeInterval(0.2)
_ = Timer.scheduledTimer(withTimeInterval: timeToEnsureThatDisableMessageIsSentAfterLastDataPacket, repeats: false, block: { timer in
timer.invalidate()
debugPrint("SEND DISABLE TEST SIGNAL")
self.peripheralManager.updateValue(SILThroughputPeripheralGATTDatabase.ThroughputService.TransmissionOn.WriteValues.disable, for: self.transmissionOnCharacteristic!, onSubscribedCentrals: nil)
})
}

private func createThroughputService() -> CBMutableService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class SILThroughputViewModel: SILThroughputViewModelType {

private var isSubscribed: Bool = false


init(peripheralManager: SILThroughputPeripheralManager, centralManager: SILCentralManager, connectedPeripheral: CBPeripheral) {
self.peripheralManager = peripheralManager
self.centralManager = centralManager
Expand All @@ -100,8 +99,6 @@ class SILThroughputViewModel: SILThroughputViewModelType {
case .initiated:
weakSelf.peripheralDelegateSubscription?.invalidate()
weakSelf.readConnectionParameters()
weakSelf.peripheralManager.setMtu(mtu: weakSelf.peripheralDelegate.getMTU(for: .withResponse), for: .withResponse)
weakSelf.peripheralManager.setMtu(mtu: weakSelf.peripheralDelegate.getMTU(for: .withoutResponse), for: .withoutResponse)

if weakSelf.isSubscribed == true {
weakSelf.testState.value = .initiatedCorrectly
Expand Down Expand Up @@ -239,7 +236,7 @@ class SILThroughputViewModel: SILThroughputViewModelType {
peripheralManager.stopTest()
}
}

func changePhoneTestModeSelection(newSelection: SILThroughputPhoneTestMode) {
if newSelection != phoneTestModeSelected.value {
phoneTestModeSelected.value = newSelection
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
Loading

0 comments on commit 532a906

Please sign in to comment.