This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiple connection in mesh net

Hi guys , i'm using nRF mesh library  nRFMeshProvision 2.2.3. I'm trying to connect to multiple mesh nodes and send message to all of them. In provided class NetworkConnection.swift i see next words:

// Find the first connected proxy. This may be modified to find
// the closes one, or, if needed, the message can be sent to all
// connected nodes.



so i implemented my idea like this 

func send(_ data: Data, ofType type: PduType) throws {
    guard supports(type) else {
        throw BearerError.pduTypeNotSupported
    }
    
    proxies.forEach {
        if ($0.isOpen) {
            do {
                try $0.send(data, ofType: type)
            } catch  {
            }
        }
    }

    //***** this is original implementation that send message to the first open node 
    //        guard let proxy = proxies.first(where: { $0.isOpen }) else {
    //            throw BearerError.bearerClosed
    //        }
    //        try proxy.send(data, ofType: type)
}


Is it correct way to achieve my goal? I'm asking because sometimes i get crash



Thank you
Parents Reply Children
No Data
Related