Hi LIFX,
I’m trying to get a UDP response from a bulb on my network.
I can see the responses going out of my app and I compared them to the lifx app request with wireshark but I can’t see any response from the bulb for either app.
The docs say the payload doesn’t matter but it’s the only difference in my UDP request and the LIFX app. Although I could have missed something else, I was using the LIFXKit as a reference.
Here’s some code to look at
import Foundation
import CocoaAsyncSocket
class LifxUDPManager : BulbProtocol, GCDAsyncUdpSocketDelegate {
var socket:GCDAsyncUdpSocket!
var connected:Bool = false
func connect(){
if(connected == false) {
var error : NSError?
socket = GCDAsyncUdpSocket(delegate: self, delegateQueue: dispatch_get_main_queue())
socket.bindToPort(56700, error: &error)
socket.beginReceiving(&error)
socket.enableBroadcast(true,error: &error)
connected = true
}
}
func play(lightSequence:LightSequence)
{
let message = “ping”
let data = message.dataUsingEncoding(NSUTF8StringEncoding)
socket.sendData(data, toHost: “255.255.255.255”, port: 56700, withTimeout: -1, tag: 1)
println(“scan”)
}
}
Thanks,
Kate