Calling functions over network

(sorry, noob here) I’ve had a big look around and keep getting lost. Can anyone put simply if I can control my Spark over a local network.

So far:

  • I have been able to call functions to control LEDs using a Java app that calls the “curl…” commands over the Spark cloud.
  • Created a simple Java server with help of this here to send a string to the serial monitor of the Spark over a local network.

I plan to have sliders to control the colour of the LEDs but continuously calling the functions over the internet is very slow.
If there is a way to speed things up I’d love to implement local control otherwise I would have to stick to a button that sends the slider data all at once.

Is there a way to translate a string from the serial monitor to call a function? or is this a silly question?

Hi @StudBeefpile

Have you checked out the Tutorial category here in the forum yet? There is a lot there, including this that might help you:

I would call this near-real-time since you can’t quite move the slider with abandon.

1 Like

Thanks for replying! If there isn’t a way to call a function locally I guess I could go back to calling over the cloud. I’ll have to set up some clever way of contacting the cloud at set intervals but keep a smooth flowing slider.

@StudBeefpile, you could setup a local cloud for better performance. However, are you looking for the color to change as you slide or could you send the change when you stop sliding (eg. release the mouse button or remove touch)? That way only when you stop changing the slider does it call the function. You could also program a transition into the core so if the slider value changes by a lot, the Core would smoothly transition to the new value. Just some ideas.

You could also consider using VoodooSpark which allows direct control of the Spark I/O via TCP :smile:

I shall definitely look into this! If I can get it to work locally it would be fantastic though I am still very new to network programming so will need to see how easy it may be. If not your idea of a smooth transition to a new value sounds pretty appetising.

Am I right into thinking even if I implement the VoodooSpark I would still not be able to disconnect the Core from Spark Cloud completely? I only ask for if I was to ever use the project in an environment with no internet access. (FYI my project is a WiFi light bulb if internet cuts out it would be preferable to continue to use light controls).
I understand this may be a completely different topic though.

@StudBeefpile, I believe that VoodooSpark does not need the cloud to function. The code was written before some big changes were made to the Core firmware including disabling cloud connectiving and such. The only use of the cloud is to get the Core’s IP. After that, the cloud is not needed.

BTW, you could program many different transitions in the Core and have those selectable when you set your sliders and hit the desired transition button. Again, just throwing mud on the wall :stuck_out_tongue:

@peekay123, This changes everything, I will want this implemented as I will need to present my final project in an area where the wifi is not accessible to the Core. Thus I would need to set up a local network with a router not connected to the internet.
Thank you for suggesting this, I will start looking into it when I next have the time!