Skip to content

Commit

Permalink
Release v0.5.0
Browse files Browse the repository at this point in the history
Merge pull request #209 from OZEO-DOOZ/develop
  • Loading branch information
R0m4in-dooz authored Dec 21, 2021
2 parents fe8da36 + 129805b commit 5cdc12e
Show file tree
Hide file tree
Showing 30 changed files with 1,021 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.0

- expose some of the API needed to execute a Key Refresh Procedure on Android using [this](https://github.com/NordicSemiconductor/Android-nRF-Mesh-Library/pull/381) Pull Request as reference
- allow to choose the name of a provisioner when asking to create one using `IMeshNetwork.addProvisioner` method (defaults to `'DooZ Mesh Provisioner'`)

## 0.4.0

- added a new scanning method where a user may choose the BLE services to look for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ class DoozMeshManagerApi(context: Context, binaryMessenger: BinaryMessenger) : S
mMeshManagerApi.createMeshPdu(address, meshMessage)
result.success(null)
}
"keyRefreshPhaseGet" -> {
val address = call.argument<Int>("address")!!
val netKeyIndex = call.argument<Int>("netKeyIndex")!!
val currentMeshNetwork = mMeshManagerApi.meshNetwork!!
val meshMessage: MeshMessage = ConfigKeyRefreshPhaseGet(currentMeshNetwork.netKeys[netKeyIndex])
mMeshManagerApi.createMeshPdu(address, meshMessage)
result.success(null)
}
"keyRefreshPhaseSet" -> {
val address = call.argument<Int>("address")!!
val netKeyIndex = call.argument<Int>("netKeyIndex")!!
val transition = call.argument<Int>("transition")!!
val currentMeshNetwork = mMeshManagerApi.meshNetwork!!
val meshMessage: MeshMessage = ConfigKeyRefreshPhaseSet(currentMeshNetwork.netKeys[netKeyIndex], transition)
mMeshManagerApi.createMeshPdu(address, meshMessage)
result.success(null)
}
"sendConfigModelSubscriptionAdd" -> {
val elementAddress = call.argument<Int>("elementAddress")!!
val subscriptionAddress = call.argument<Int>("subscriptionAddress")!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class DoozMeshNetwork(private val binaryMessenger: BinaryMessenger, var meshNetw
result.success(maxAddress)
}
"addProvisioner" -> {
val name = call.argument<String>("name")!!
val unicastAddressRange = call.argument<Int>("unicastAddressRange")!!
val groupAddressRange = call.argument<Int>("groupAddressRange")!!
val sceneAddressRange = call.argument<Int>("sceneAddressRange")!!
Expand All @@ -199,7 +200,7 @@ class DoozMeshNetwork(private val binaryMessenger: BinaryMessenger, var meshNetw
val unicastRange: AllocatedUnicastRange = meshNetwork.nextAvailableUnicastAddressRange(unicastAddressRange)
val groupRange: AllocatedGroupRange = meshNetwork.nextAvailableGroupAddressRange(groupAddressRange)
val sceneRange: AllocatedSceneRange = meshNetwork.nextAvailableSceneAddressRange(sceneAddressRange)!!
val provisioner: Provisioner = meshNetwork.createProvisioner("DOOZ Mesh Provisioner",
val provisioner: Provisioner = meshNetwork.createProvisioner(name,
unicastRange, groupRange, sceneRange)
val unicastId = provisioner.allocatedUnicastRanges[0].lowAddress

Expand Down Expand Up @@ -291,6 +292,75 @@ class DoozMeshNetwork(private val binaryMessenger: BinaryMessenger, var meshNetw
}
result.success(subscribedAddresses)
}
"generateNetKey" -> {
Log.d(tag, "should generate a NetworkKey and return the associated data")
val netKey = meshNetwork.createNetworkKey()
result.success(mapOf(
"name" to netKey.getName(),
"netKeyIndex" to netKey.getKeyIndex(),
"phase" to netKey.getPhase(),
"phaseDescription" to netKey.getPhaseDescription(),
"isMinSecurity" to netKey.isMinSecurity(),
"netKeyBytes" to netKey.getKey(),
"oldNetKeyBytes" to netKey.getOldKey(),
"txNetworkKey" to netKey.getTxNetworkKey(),
"identityKey" to netKey.getIdentityKey(),
"oldIdentityKey" to netKey.getOldIdentityKey(),
"meshUuid" to netKey.getMeshUuid(),
"timestamp" to netKey.getTimestamp()
))
}
"getNetKey" -> {
val netKeyIndex = call.argument<Int>("netKeyIndex")!!
Log.d(tag, "should get NetworkKey at index " + netKeyIndex.toString())
val netKey = meshNetwork.getNetKey(netKeyIndex)
if(null != netKey) {
result.success(mapOf(
"name" to netKey.getName(),
"netKeyIndex" to netKey.getKeyIndex(),
"phase" to netKey.getPhase(),
"phaseDescription" to netKey.getPhaseDescription(),
"isMinSecurity" to netKey.isMinSecurity(),
"netKeyBytes" to netKey.getKey(),
"oldNetKeyBytes" to netKey.getOldKey(),
"txNetworkKey" to netKey.getTxNetworkKey(),
"identityKey" to netKey.getIdentityKey(),
"oldIdentityKey" to netKey.getOldIdentityKey(),
"meshUuid" to netKey.getMeshUuid(),
"timestamp" to netKey.getTimestamp()
))
} else {
result.error("NOT_FOUND", "No Network Key found", "Please check the given index")
}
}
"removeNetKey" -> {
val netKeyIndex = call.argument<Int>("netKeyIndex")!!
Log.d(tag, "should remove NetworkKey at index " + netKeyIndex.toString())
val netKey = meshNetwork.getNetKey(netKeyIndex)
if(null != netKey) {
result.success(meshNetwork.removeNetKey(netKey))
} else {
result.error("NOT_FOUND", "No Network Key found", "Please check the given index")
}
}
"distributeNetKey" -> {
val netKeyIndex = call.argument<Int>("netKeyIndex")!!
Log.d(tag, "should distribute NetworkKey at index " + netKeyIndex.toString())
val netKey = meshNetwork.getNetKey(netKeyIndex)
if(null != netKey) {
val netKeyBytes = netKey.getKey()
val updatedNetKey = meshNetwork.distributeNetKey(netKey, netKeyBytes)
result.success(mapOf(
"meshUuid" to updatedNetKey.getMeshUuid(),
"name" to updatedNetKey.getName(),
"netKeyIndex" to updatedNetKey.getKeyIndex(),
"oldPhase" to netKey.phase,
"phase" to updatedNetKey.phase
))
} else {
result.error("NOT_FOUND", "No Network Key found", "Please check the given index")
}
}
else -> {
result.notImplemented()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ class DoozMeshStatusCallbacks(var eventSink: EventChannel.EventSink?): MeshStatu
))
}
}
is ConfigKeyRefreshPhaseStatus -> {
Log.d(tag, "received a ConfigKeyRefreshPhaseStatus")
Handler(Looper.getMainLooper()).post {
eventSink?.success(mapOf(
"eventName" to "onConfigKeyRefreshPhaseStatus",
"source" to meshMessage.src,
"destination" to meshMessage.dst,
"statusCode" to meshMessage.statusCode,
"statusCodeName" to meshMessage.statusCodeName,
"netKeyIndex" to meshMessage.netKeyIndex,
"transition" to meshMessage.transition
))
}
}
else -> {
Log.d(tag, "Unknown message received :" + meshMessage.javaClass.toString())
}
Expand Down
1 change: 0 additions & 1 deletion example/lib/src/views/control_module/model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:nordic_nrf_mesh/nordic_nrf_mesh.dart';

class Model extends StatelessWidget {
Expand Down
1 change: 0 additions & 1 deletion example/lib/src/views/control_module/node.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:nordic_nrf_mesh/nordic_nrf_mesh.dart';

import '../../data/board_data.dart';
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.4.0"
version: "0.5.0"
package_config:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion ios/Classes/DoozMeshNetwork/DoozMeshNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,12 @@ private extension DoozMeshNetwork {
do {
let provisionerUUID = UUID()

let name = String(data.name)
let nextAvailableUnicastAddressRange = meshNetwork.nextAvailableUnicastAddressRange(ofSize: UInt16(data.unicastAddressRange))!
let nextAvailableGroupAddressRange = meshNetwork.nextAvailableGroupAddressRange(ofSize: UInt16(data.groupAddressRange))!
let nextAvailableSceneRange = meshNetwork.nextAvailableSceneRange(ofSize: UInt16(data.sceneAddressRange))!

let mProvisioner = Provisioner.init(name: UIDevice.current.name, uuid: provisionerUUID, allocatedUnicastRange: [nextAvailableUnicastAddressRange], allocatedGroupRange: [nextAvailableGroupAddressRange], allocatedSceneRange: [nextAvailableSceneRange])
let mProvisioner = Provisioner.init(name: name, uuid: provisionerUUID, allocatedUnicastRange: [nextAvailableUnicastAddressRange], allocatedGroupRange: [nextAvailableGroupAddressRange], allocatedSceneRange: [nextAvailableSceneRange])

try meshNetwork.add(provisioner: mProvisioner)

Expand Down
2 changes: 0 additions & 2 deletions lib/nordic_nrf_mesh.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export 'src/nrf_mesh.dart';
export 'src/mesh_network.dart' show IMeshNetwork;
export 'src/mesh_manager_api.dart';
export 'src/provisioned_mesh_node.dart';
export 'src/unprovisioned_mesh_node.dart';
export 'src/events/data/event_data.dart';
export 'src/models/models.dart';
export 'src/ble/ble_manager.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/src/ble/ble_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:meta/meta.dart';
import 'package:nordic_nrf_mesh/nordic_nrf_mesh.dart';
import 'package:nordic_nrf_mesh/src/ble/ble_manager_callbacks.dart';

const mtuSizeMax = 517;
const maxPacketSize = 20;
Expand Down
2 changes: 0 additions & 2 deletions lib/src/ble/ble_mesh_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:nordic_nrf_mesh/nordic_nrf_mesh.dart';
import 'package:nordic_nrf_mesh/src/ble/ble_manager.dart';
import 'package:nordic_nrf_mesh/src/ble/ble_mesh_manager_callbacks.dart';
import 'package:retry/retry.dart';

class BleMeshManager<T extends BleMeshManagerCallbacks> extends BleManager<T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'config_key_refresh_phase_status.freezed.dart';
part 'config_key_refresh_phase_status.g.dart';

@freezed
class ConfigKeyRefreshPhaseStatus with _$ConfigKeyRefreshPhaseStatus {
const factory ConfigKeyRefreshPhaseStatus(
int source,
int destination,
int statusCode,
String statusCodeName,
int netKeyIndex,
int transition,
) = _ConfigKeyRefreshPhaseStatus;

factory ConfigKeyRefreshPhaseStatus.fromJson(Map<String, dynamic> json) =>
_$ConfigKeyRefreshPhaseStatusFromJson(json);
}
Loading

0 comments on commit 5cdc12e

Please sign in to comment.