java - Controlling a dweet.io device through local network -


i have iot device made interact through dweet.io works fine. however, wish able control device in absence of internet connection, somehow need create own dweet server.

the dweet.io uses pretty simple tcp protocol string commands. device sends message server responds post message containing commands. device can configured use server ip , can set machine's local ip. want use java control device. code got far

server = new serversocket(9999); while (running) {     socket socket = server.accept();     bufferedreader br = new bufferedreader(             new inputstreamreader(socket.getinputstream()));     bufferedwriter bw = new bufferedwriter(             new outputstreamwriter(socket.getoutputstream()));      string inputline = "", msg = "";     while (!(inputline = br.readline()).equals("")) {         newmsg += inputline;     }     system.out.println(msg);      bw.write(command);     bw.newline();     bw.flush();     bw.close();     br.close();     } server.close(); 

it receives following message device

post /dweet/for/xxxxxxxx_yyyyyyyy?ioa=168&io0=1&io1=0&io2=0&io3=0&io4=0 http/1.1 host: 192.168.0.24 connection: keep-alive accept: */* 

but fails execute commands sent in post message. contacted vendor , told me need respond device's request following post command

post /dweet/for/params_xxxxxxxx_yyyyyyyy/?command=the_command&value=the_value 

where x , y's devices type , unique dweet id. when send post appropriately set values x, y , commands device, disconnects wifi if reboot.

any suggestions welcome.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -