Comments (7)
Did you create LightCTLClientDelegate
object and registered it to a local Element in the app?
The model delegate has to bind a message ID with a type.
Have a look at the example:
where the
GenericOnOffClientDelegate
registers the status message.from ios-nrf-mesh-library.
The delegate is added to local element here:
from ios-nrf-mesh-library.
You will find more info here: https://nordicsemiconductor.github.io/IOS-nRF-Mesh-Library/documentation/nordicmesh/localnode
from ios-nrf-mesh-library.
Yes. I did all these steps. Here are some codes from my project.
extension QBleMesh {
func createNewMeshNetwork() {
let provisioner = Provisioner.init(name: UIDevice.current.name)
_ = meshNetworkManager.createNewMeshNetwork(withName: "bt-control", by: provisioner)
_ = meshNetworkManager.save()
meshNetworkDidChange()
}
func meshNetworkDidChange() {
let meshNetwork = meshNetworkManager.meshNetwork!
let primary: Element = Element(name: "PrimaryElement", location: .first, models: [
Model(sigModelId: .genericOnOffClient, delegate: GenericOnOffClientDelegate(meshNetworkManager, statusManager: self)),
Model(sigModelId: .lightCTLClient, delegate: LightCTLClientDelegate(meshNetworkManager, statusManager: self)),
Model(sigModelId: .genericBatteryClient, delegate: GenericBatteryClientDelegate(meshNetwork, statusManager: self)),
// Model(vendorModelId: .healthModelId, companyId: .companyId, delegate: VendorHealthClientDelegate(meshNetworkManager))
Model(vendorModelId: .timerModelId, companyId: .companyId, delegate: VendorCountdownClientDelegate(meshNetworkManager))
])
meshNetworkManager.localElements = [primary]
setApplicationKey()
setupModelApplicationKeysForLocalNode(meshNetwork.applicationKeys.first!)
print("meshNetwork.nodes \(meshNetwork.nodes)")
print("meshNetwork.groups \(meshNetwork.groups)")
connection = NetworkConnection(to: meshNetwork)
connection?.isConnectionModeAutomatic = true
connection?.dataDelegate = meshNetworkManager
connection?.logger = self
meshNetworkManager.transmitter = connection
connection?.open()
provisioningService = ProvisioningService(meshNetworkManager: meshNetworkManager)
meshNetworkManager.delegate = self
}
}
And here is LightCTLClientDelegate class
import Foundation
import nRFMeshProvision
class LightCTLClientDelegate: ModelDelegate {
let meshNetworkManager: MeshNetworkManager
let statusManager: StatusUpdate
let messageTypes: [UInt32 : MeshMessage.Type]
let isSubscriptionSupported: Bool = true
var publicationMessageComposer: MessageComposer? {
func compose() -> MeshMessage {
return LightCTLSetUnacknowledged(lightness: UInt16(((Double(self.state) / 100.0) * 65535).rounded()), temperature: 10400, deltaUV: 0)
}
let request = compose()
return {
return request
}
}
/// The current state of the Light CTL Client model.
var state = 25 {
didSet {
publish(using: self.meshNetworkManager)
}
}
init(_ meshNetworkManager: MeshNetworkManager, statusManager: StatusUpdate) {
let types: [GenericMessage.Type] = [
LightCTLStatus.self
]
messageTypes = types.toMap()
self.meshNetworkManager = meshNetworkManager
self.statusManager = statusManager
}
// MARK: - Message handlers
func model(_ model: Model, didReceiveAcknowledgedMessage request: AcknowledgedMeshMessage,
from source: Address, sentTo destination: MeshAddress) -> MeshMessage {
fatalError("Not possible")
}
func model(_ model: Model, didReceiveUnacknowledgedMessage message: MeshMessage,from source: Address, sentTo destination: MeshAddress) {
if let status = message as? LightCTLStatus {
let luminosity = UInt16(((Double(status.lightness) / 65535) * 100).rounded())
statusManager.update(unicastAddress: source, onOff: nil, luminosity: luminosity, temperature: status.temperature, powerStatus: nil, onlineStatus: true)
}
}
func model(_ model: Model, didReceiveResponse response: MeshMessage,
toAcknowledgedMessage request: AcknowledgedMeshMessage,
from source: Address) {
if let status = response as? LightCTLStatus {
let luminosity = UInt16(((Double(status.lightness) / 65535) * 100).rounded())
statusManager.update(unicastAddress: source, onOff: nil, luminosity: luminosity, temperature: status.temperature, powerStatus: nil, onlineStatus: true)
}
}
}
from ios-nrf-mesh-library.
In that case I suspect either invalid data, or a bug in the data parser here:
IOS-nRF-Mesh-Library/Library/Mesh Messages/Lighting/LightCTLStatus.swift
Lines 112 to 127 in 6369af8
Your data is FF-3F-9C-63-00-00
, which is 6 bytes. This will fail on the first line. When nil
is returned, the library defaults to UnknownMessage
.
Let's compare with the spec...
from ios-nrf-mesh-library.
Note, that OpCode is not included here, so the data in fact should be 4 or 9 bytes long.
from ios-nrf-mesh-library.
Ok. Thank you very much. I will try to solve the problem using this data. I'll let you know about the results.
from ios-nrf-mesh-library.
Related Issues (20)
- Crash due to belated type conversion (maxElementCount) HOT 4
- Message sequences received out of sync HOT 3
- Proxy change within a network causes the proxy filter not to be set HOT 3
- I updated from version 3.1.5 to version 4.0.1. I need to update many interfaces and the changes are huge. Is there any convenient way? HOT 7
- Zephyr BLE Mesh sample stuck on "Connecting" on iOS only. HOT 2
- How to migrate a custom model from library version 3.2.0 to 4.1.0? HOT 2
- Requirement for Provisioner's Unicast Address to be in its range is not a requirement by spec
- UI/UX improvement
- no
- Send message await forever HOT 11
- ios nfc
- nRFMeshProvision/iOSDFULibrary: "Multiple commands produce PrivacyInfo.bundle" when creating an archive. HOT 4
- Need help with configuring nodes HOT 3
- Why not skipping the 96h between each IV Index change state when testMode is true? HOT 2
- [App] Add option to control Scenes on more than one element HOT 3
- Why is the Bluetooth device json table data in my configuration table sometimes inexplicably cleared? HOT 4
- Health messages not handled HOT 1
- Heartbeat Messages HOT 1
- The composition data features displayed in the mobile app is incorrect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ios-nrf-mesh-library.