Post

Replies

Boosts

Views

Activity

Reply to UDP Broadcast on iOS18
Actually the MAUI team has asked for examples of native code. I assume that would be Obj-C or Swift. The probably want to compare it to what they are doing right now. If you have any examples in either Obj-C or Swift, please point me to them.
Jan ’25
Reply to UDP Broadcast on iOS18
We have a hardware device based on the esp32. This device will connect to the user’s wi-fi and then start watching for UDP broadcasts. Our mobile app sends a UDP broadcast. Our device then replies to the broadcast with a specially formatted packet containing its IP address. Our mobile app can then make a TCP/IP connection and go from there.
Jan ’25
Reply to UDP Broadcast on iOS18
I do have one question: Why did this work last summer? At least it seemed to. I had a working app last summer and then didn't work on it for a few months. I then had upgraded my phone's OS and xcode to 16.2 (before I was on 15.x). It quit working around October / November. I thought maybe it was the OS upgrade, but it also didn't work on 17 at that time. Did something change in Xcode 16 or in the iOS SDK maybe?
Jan ’25
Reply to UDP Broadcast on iOS18
I found some Swift code, but when I try to use it I get a different error. In the following code the status goes from preparing to waiting. I have show both the code and the logs in Xcode below. Thoughts? // // ContentView.swift // UDP Broadcast Test // // Created by Tony Pitman on 12/19/24. // import SwiftUI import Network struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Button("UDP Test") { let connection = NWConnection(host: "255.255.255.255", port: 11000, using: .udp) connection.stateUpdateHandler = { (newState) in print("This is stateUpdateHandler:") switch (newState) { case .ready: print("State: Ready\n") self.sendUDP(connection: connection, content: "Polaris Discovery") self.receiveUDP(connection: connection) case .setup: print("State: Setup\n") case .cancelled: print("State: Cancelled\n") case .preparing: print("State: Preparing\n") case .waiting(let error): print("State: Waiting: \(error)\n") default: print("ERROR! State not defined!\n") } } connection.start(queue: .global()) } } .padding() } func sendUDP(connection: NWConnection, content: Data) { connection.send(content: content, completion: NWConnection.SendCompletion.contentProcessed(({ (NWError) in if (NWError == nil) { print("Data was sent to UDP") } else { print("ERROR! Error when data (Type: Data) sending. NWError: \n \(NWError!)") } }))) } func sendUDP(connection: NWConnection, content: String) { let contentToSendUDP = content.data(using: String.Encoding.utf8) connection.send(content: contentToSendUDP, completion: NWConnection.SendCompletion.contentProcessed(({ (NWError) in if (NWError == nil) { print("Data was sent to UDP") } else { print("ERROR! Error when data (Type: Data) sending. NWError: \n \(NWError!)") } }))) } func receiveUDP(connection: NWConnection) { connection.receiveMessage { (data, context, isComplete, error) in if (isComplete) { print("Receive is complete") if (data != nil) { let backToString = String(decoding: data!, as: UTF8.self) print("Received message: \(backToString)") } else { print("Data == nil") } } } } } #Preview { ContentView() } Log output including the waiting error: NSBundle file:///System/Library/PrivateFrameworks/MetalTools.framework/ principal class is nil because all fallbacks have failed This is stateUpdateHandler: This is stateUpdateHandler: State: Preparing This is stateUpdateHandler: State: Waiting: POSIXErrorCode(rawValue: 50): Network is down State: Waiting: POSIXErrorCode(rawValue: 50): Network is down
Dec ’24
Reply to Apple Vision Pro Won't Connect to Xcode Device Manager
The one thing I didn't mention was that I purchased a new MacBook pro. I chose the option to migrate to this new MacBook Pro. It brought over everything else, so I assumed it would bring this over too. That was a bad assumption. I decided to try deleting the Mac on my AVP and pairing again. That worked and now I am in. If anyone knows I am curious why this wasn't brought over during the migration...
Nov ’24