Skip to content

Instantly share code, notes, and snippets.

@coot
Created August 30, 2016 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coot/b633f461fba5e8f7bdedfd42ffc5ceb5 to your computer and use it in GitHub Desktop.
Save coot/b633f461fba5e8f7bdedfd42ffc5ceb5 to your computer and use it in GitHub Desktop.
const dgram = require("dgram");
const ssdpRequest = `M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 0
ST: urn:schemas-sony-com:service:ScalarWebAPI:1
USER-AGENT: nodejs
`;
function ssdpConnect() {
const sock = dgram.createSocket('udp4');
sock.on('message', (msg, rinfo) => {
console.log(`server received: ${msg} from ${rinfo.address}:${rinfo.port}`);
});
sock.on('error', console.log.bind(null, 'error'));
sock.on('listening', () => console.log(`listening: ${sock.address()}`));
sock.send(Buffer.from(ssdpRequest), 1900, "239.255.255.250", (err) => {if (err) {sock.close(); console.log(err);}});
return sock;
}
module.exports = ssdpConnect;
module.exports.ssdpRequest = ssdpRequest;
@ryango
Copy link

ryango commented Jan 20, 2017

struggling with this api currently. this looks correct, but I never seem to get a response. also building for iOS unsuccessfully. Their demo apps work so it does respond somehow...

@LGstudio
Copy link

LGstudio commented May 7, 2017

I have tried the Android API example but it cannot find the device. I have an A6000 and I have not idea what to set on the camera to make it discovered. Could you please help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment