Skip to content

Commit

Permalink
Merge pull request #236 from NordicSemiconductor/develop
Browse files Browse the repository at this point in the history
Version 2.2.1
  • Loading branch information
philips77 authored Dec 17, 2019
2 parents 10acde1 + 61e387a commit 45e1222
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 55 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Changelog
- **2.2.1**:
- API related to "compatible models" removed, as the client and server models do not need to have model IDs differing by 1 (#225).

- **2.2.0**:
- Scene messages added.
- Lightness, CTL and HSL messages added.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/nRFMeshProvision.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
LINK_WITH_STANDARD_LIBRARIES = YES;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MODULE_NAME = ExampleApp;
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -1213,7 +1213,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
LINK_WITH_STANDARD_LIBRARIES = YES;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MODULE_NAME = ExampleApp;
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ class ModelViewController: ProgressViewController {
let thisNode = thisElement.parentNode!
let otherNodes = network.nodes.filter { $0 != thisNode }
let elementsWithCompatibleModels = otherNodes.flatMap {
$0.elements.filter({ $0.contains(modelCompatibleWith: self.model, boundTo: applicationKey)})
$0.elements.filter({ $0.contains(modelBoundTo: applicationKey)})
}
let compatibleModels = elementsWithCompatibleModels.flatMap {
$0.models.filter({ $0.isCompatible(to: self.model) && $0.boundApplicationKeys.contains(applicationKey) })
$0.models.filter({ $0.isBoundTo(applicationKey) })
}
let boundKeyUsedByOtherNodes = compatibleModels.contains {
$0.publish?.publicationAddress.address == thisElement.unicastAddress &&
$0.publish?.index == applicationKey.index
$0.publish?.publicationAddress.address == thisElement.unicastAddress &&
$0.publish?.index == applicationKey.index
}

if boundKeyUsedInPublication || boundKeyUsedByOtherNodes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ class SetPublicationDestinationsViewController: UITableViewController {
var selectedApplicationKey: ApplicationKey?
var selectedDestination: MeshAddress?

/// List of Elements containing a compatible Model. For example,
/// for Generic On/Off Server this list will contain all Elements
/// with Genetic On/Off Client.
/// List of Elements containing Model bound to selected Application Key.
private var compatibleElements: [Element]!
private let specialGroups: [(title: String, address: Address)] = [
("All Proxies", Address.allProxies),
Expand Down Expand Up @@ -212,10 +210,10 @@ private extension SetPublicationDestinationsViewController {
rows.append(indexPath)
selectedKeyIndexPath = indexPath

// The list of Elements contains Elements with compatible models, that are bound
// The list of Elements contains Elements with models, that are bound
// to the selected key. Changing the key will cause the Elements list to reload.
// If an Element was selected, it may happen that it also is bound to the
// new key, or not. We have either to update the selected index path, or
// new key, or not. We either have to update the selected index path, or
// clear the selection.
var selectedElementIndex: UInt8?
if !initial, let indexPath = selectedIndexPath, indexPath.isElementsSection {
Expand All @@ -226,7 +224,7 @@ private extension SetPublicationDestinationsViewController {
let meshNetwork = MeshNetworkManager.instance.meshNetwork!
compatibleElements = meshNetwork.nodes
.flatMap({ $0.elements })
.filter({ $0.contains(modelCompatibleWith: model, boundTo: key) })
.filter({ $0.contains(modelBoundTo: key) })

if let selectedElementIndex = selectedElementIndex {
if let newRow = compatibleElements.firstIndex(where: { $0.index == selectedElementIndex }) {
Expand Down
2 changes: 1 addition & 1 deletion nRFMeshProvision.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'nRFMeshProvision'
s.version = '2.2.0'
s.version = '2.2.1'
s.summary = 'A Bluetooth Mesh library'
s.description = <<-DESC
nRF Mesh is a Bluetooth Mesh compliant library that has many features such as provisioning, configuration and control of Bluetooth Mesh compliant nodes.
Expand Down
12 changes: 4 additions & 8 deletions nRFMeshProvision/Classes/Mesh API/Element+Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,14 @@ public extension Element {
return models.contains(model)
}

/// Returns `true` if the Element contains a Model compatible
/// with given one. Compatible Models make a pair of Client - Server.
/// Returns `true` if the Element contains a Model bound to the
/// given Application Key.
///
/// For example, a compatible Model to Generic On/Off Server is
/// Generic On/Off Client, and vice versa.
///
/// - parameter model: The Model, which pair is required.
/// - parameter applicationKey: The Application Key which the Model
/// must be bound to.
/// - returns: `True`, if the Element has the matching Model.
func contains(modelCompatibleWith model: Model, boundTo applicationKey: ApplicationKey) -> Bool {
return models.contains { $0.isCompatible(to: model) && $0.bind.contains(applicationKey.index) }
func contains(modelBoundTo applicationKey: ApplicationKey) -> Bool {
return models.contains { $0.bind.contains(applicationKey.index) }
}

/// Returns whether the Element contains any Models that are
Expand Down
1 change: 1 addition & 0 deletions nRFMeshProvision/Classes/Mesh API/Model+Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ public extension Model {
func isBoundTo(_ applicationKey: ApplicationKey) -> Bool {
return bind.contains(applicationKey.index)
}

}
14 changes: 0 additions & 14 deletions nRFMeshProvision/Classes/Mesh API/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ import Foundation

public extension Model {

/// Returns whether the given Model is compatible with the one.
///
/// A compatible Models create a Client-Server pair. I.e., the
/// Generic On/Off Client is compatible to Generic On/Off Server,
/// and vice versa. The rule is that the Server Model has an even
/// Model ID and the Client Model has Model ID greater by 1.
///
/// - parameter model: The Model to compare to.
/// - returns: `True`, if the Models are compatible, `false` otherwise.
func isCompatible(to model: Model) -> Bool {
let compatibleModelId = (modelId % 2 == 0) ? modelId + 1 : modelId - 1
return model.modelId == compatibleModelId
}

/// Returns whether the Model is subscribed to the given Group.
///
/// This method may also return `true` if the Group is not known
Expand Down

0 comments on commit 45e1222

Please sign in to comment.