Skip to content

Commit

Permalink
Merge pull request #266 from NordicSemiconductor/develop
Browse files Browse the repository at this point in the history
Version 2.2.2
  • Loading branch information
philips77 authored Apr 28, 2020
2 parents 45e1222 + d59c023 commit cc1c353
Show file tree
Hide file tree
Showing 89 changed files with 1,585 additions and 456 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ profile
DerivedData
*.hmap
*.ipa
*xcshareddata*
# Bundler
.bundle

Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
## Changelog
- **2.2.2**:
- Fixed handling IV Index update.
- Added a flag to enable IV Index Test Mode.
- New method to get next available address from given offset.
- 2 methods added to get and set Element's sequence number. Use on your own risk.
- A Disconnect button added in the sample app, available with Automatic Connection disabled.
- Improvement: Migration to Swift 5.2 and Xcode 11.4.
- Improvement: macOs added to podspec (#240).
- Improvement: Discovering new proxy connection improved.
- Bugfix: Fixed overwriting primary element's name.
- Bugfix: Thread synchronization in `ProxyFilter` and `BaseGattBearer`.

- **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).

Expand Down

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

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

32 changes: 32 additions & 0 deletions Example/Tests/AssigningGroupAddresses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,37 @@ class AssigningGroupAddresses: XCTestCase {

XCTAssertNil(address)
}

func testAssigningGroupAddressRanges_boundaries() {
let meshNetwork = MeshNetwork(name: "Test network")
let provisioner = Provisioner(name: "P0",
allocatedUnicastRange: [AddressRange(0x0001...0x0001)],
allocatedGroupRange: [AddressRange(0xC000...0xC000)],
allocatedSceneRange: [])
XCTAssertNoThrow(try meshNetwork.add(provisioner: provisioner, withAddress: nil))

let newRangeNil = meshNetwork.nextAvailableGroupAddressRange(ofSize: 0)
XCTAssertNil(newRangeNil)

let newRange0 = meshNetwork.nextAvailableGroupAddressRange(ofSize: 1)
XCTAssertNotNil(newRange0)
XCTAssertEqual(newRange0?.lowerBound, 0xC001)
XCTAssertEqual(newRange0?.upperBound, 0xC001)

let newRange1 = meshNetwork.nextAvailableGroupAddressRange(ofSize: 2)
XCTAssertNotNil(newRange1)
XCTAssertEqual(newRange1?.lowerBound, 0xC001)
XCTAssertEqual(newRange1?.upperBound, 0xC002)

let newRange2 = meshNetwork.nextAvailableGroupAddressRange()
XCTAssertNotNil(newRange2)
XCTAssertEqual(newRange2?.lowerBound, 0xC001)
XCTAssertEqual(newRange2?.upperBound, Address.maxGroupAddress)

let newRange3 = meshNetwork.nextAvailableGroupAddressRange(ofSize: 0xFFFF)
XCTAssertNotNil(newRange3)
XCTAssertEqual(newRange3?.lowerBound, 0xC001)
XCTAssertEqual(newRange3?.upperBound, Address.maxGroupAddress)
}

}
83 changes: 81 additions & 2 deletions Example/Tests/AssigningUnicastAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ class AssigningUnicastAddress: XCTestCase {
XCTAssertEqual(address!, 100)
}

func testAssigningUnicastAddress_offset() {
let meshNetwork = MeshNetwork(name: "Test network")
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 0", unicastAddress: 1, elements: 9)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 1", unicastAddress: 10, elements: 9)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 2", unicastAddress: 20, elements: 9)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 3", unicastAddress: 30, elements: 9)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 4", unicastAddress: 115, elements: 2)))

let provisioner = Provisioner(name: "Test provisioner",
allocatedUnicastRange: [
AddressRange(100...200)
],
allocatedGroupRange: [], allocatedSceneRange: [])

let address1 = meshNetwork.nextAvailableUnicastAddress(startingFrom: 110, for: 3, elementsUsing: provisioner)

XCTAssertNotNil(address1)
XCTAssertEqual(address1!, 110)

let address2 = meshNetwork.nextAvailableUnicastAddress(startingFrom: 110, for: 6, elementsUsing: provisioner)

XCTAssertNotNil(address2)
XCTAssertEqual(address2!, 117)
}

func testAssigningUnicastAddress_complex() {
let meshNetwork = MeshNetwork(name: "Test network")
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 0", unicastAddress: 1, elements: 9)))
Expand Down Expand Up @@ -116,6 +141,28 @@ class AssigningUnicastAddress: XCTestCase {
XCTAssertEqual(address!, 78)
}

func testAssigningUnicastAddress_one() {
let meshNetwork = MeshNetwork(name: "Test network")
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 0", unicastAddress: 1, elements: 10)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 1", unicastAddress: 12, elements: 18)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 2", unicastAddress: 30, elements: 11)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 3", unicastAddress: 55, elements: 10)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 4", unicastAddress: 65, elements: 5)))
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 5", unicastAddress: 73, elements: 5)))

let provisioner = Provisioner(name: "Test provisioner",
allocatedUnicastRange: [
AddressRange(8...38),
AddressRange(50...80)
],
allocatedGroupRange: [], allocatedSceneRange: [])

let address = meshNetwork.nextAvailableUnicastAddress(for: 1, elementsUsing: provisioner)

XCTAssertNotNil(address)
XCTAssertEqual(address!, 11)
}

func testAssigningUnicastAddress_none() {
let meshNetwork = MeshNetwork(name: "Test network")
XCTAssertNoThrow(try meshNetwork.add(node: Node(name: "Node 0", unicastAddress: 1, elements: 10)))
Expand All @@ -137,7 +184,7 @@ class AssigningUnicastAddress: XCTestCase {
XCTAssertNil(address)
}

func testAssigningUnicastAdderessRanges() {
func testAssigningUnicastAddressRanges() {
let meshNetwork = MeshNetwork(name: "Test network")
XCTAssertNoThrow(try meshNetwork.add(provisioner:
Provisioner(name: "P0",
Expand Down Expand Up @@ -174,7 +221,7 @@ class AssigningUnicastAddress: XCTestCase {
XCTAssertEqual(newRangeMax?.upperBound, 0x5FFF)
}

func testAssigningUnicastAdderessRanges_none() {
func testAssigningUnicastAddressRanges_none() {
let meshNetwork = MeshNetwork(name: "Test network")
XCTAssertNoThrow(try meshNetwork.add(provisioner:
Provisioner(name: "P0",
Expand All @@ -185,4 +232,36 @@ class AssigningUnicastAddress: XCTestCase {
let newRange0 = meshNetwork.nextAvailableUnicastAddressRange(ofSize: 1)
XCTAssertNil(newRange0)
}

func testAssigningUnicastAddressRanges_boundaries() {
let meshNetwork = MeshNetwork(name: "Test network")
let provisioner = Provisioner(name: "P0",
allocatedUnicastRange: [AddressRange(0x0001...0x0001)],
allocatedGroupRange: [],
allocatedSceneRange: [])
XCTAssertNoThrow(try meshNetwork.add(provisioner: provisioner, withAddress: nil))

let newRangeNil = meshNetwork.nextAvailableUnicastAddressRange(ofSize: 0)
XCTAssertNil(newRangeNil)

let newRange0 = meshNetwork.nextAvailableUnicastAddressRange(ofSize: 1)
XCTAssertNotNil(newRange0)
XCTAssertEqual(newRange0?.lowerBound, 0x0002)
XCTAssertEqual(newRange0?.upperBound, 0x0002)

let newRange1 = meshNetwork.nextAvailableUnicastAddressRange(ofSize: 2)
XCTAssertNotNil(newRange1)
XCTAssertEqual(newRange1?.lowerBound, 0x0002)
XCTAssertEqual(newRange1?.upperBound, 0x0003)

let newRange2 = meshNetwork.nextAvailableUnicastAddressRange()
XCTAssertNotNil(newRange2)
XCTAssertEqual(newRange2?.lowerBound, 0x0002)
XCTAssertEqual(newRange2?.upperBound, Address.maxUnicastAddress)

let newRange3 = meshNetwork.nextAvailableUnicastAddressRange(ofSize: 0xFFFF)
XCTAssertNotNil(newRange3)
XCTAssertEqual(newRange3?.lowerBound, 0x0002)
XCTAssertEqual(newRange3?.upperBound, Address.maxUnicastAddress)
}
}
Loading

0 comments on commit cc1c353

Please sign in to comment.