# Hover + Spark = Sonos Remote

**URL:** <https://community.particle.io/t/hover-spark-sonos-remote/8702>\
**Category:** Project Share\
**Created:** [December 10, 2014, 2:08am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702 "2014-12-10T02:08:19Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [December 10, 2014, 2:08am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/1 "2014-12-10T02:08:19Z")

</div>

I finally put my hover board to good use! I modified some code for an arduino IR remote for the Sonos.

Its working intermittently at the moment, but it does work… no red flash or anything, but there are some huge delays when printing to the client and then i need to restart the core to make it work again. i think its to do with the TCPclient slowing down thing… there is currently a function -\>

```
void out(const char *s) {
client.println(s);
#ifdef DEBUG
Serial.println(s);
#endif
}

```

how can i change it to a client.write easily? i don’t understand enough about the cont char\* to work out how to get its length…

My Modified code [here](https://github.com/Hootie81/SonosHoverSpark) (uses hover library)

The original code [here](https://github.com/jpmens/sonospauseIR)

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [December 10, 2014, 3:12am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/2 "2014-12-10T03:12:34Z")

</div>

Try this:

```cpp
void out(const char *s) {
    client.write( (const uint8_t*)s, strlen(s) );
}

```

---

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [December 10, 2014, 4:18am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/3 "2014-12-10T04:18:29Z")

</div>

Thanks @bko, ill give it a go when i get home tonight.

I managed to get it working 99% by adding the magic delays between each client.println but would rather not use that approach!

Edit: decided to give it a quick go… even though i should be packing!

Needed to do a println after as it doesnt have the carriage return any more. and now the carriage return takes forever and doesnt work… any quick way to add a /r/n to “s” before doing the write?

Edit 2: WOW what a difference using write makes! its near instant control…  
not sure where my brain was earlier… maybe trying to pack and programming at the same time isn’t possible by men? im a little embarrassed by the question above… oh well… its working perfect now!

---

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [December 11, 2014, 2:09pm UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/4 "2014-12-11T14:09:50Z")

</div>

Added a display and a big battery today 🙂 now to figure out how to retrieve song title to display on the screen  
 ![](https://sea2.discourse-cdn.com/flex026/uploads/particle/3823/0295b6fc17b7f835.jpg)

---

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [December 16, 2014, 9:10am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/5 "2014-12-16T09:10:06Z")

</div>

Here is a little video showing it working

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [December 16, 2014, 6:24pm UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/6 "2014-12-16T18:24:24Z")

</div>

Awesome! I was hoping to hookup something as a sonos remote at home as well, thanks for sharing! 🙂

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![Steph](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/steph/32/1909_2.png) [@Steph](https://community.particle.io/u/Steph)\
**Post date:** [December 17, 2014, 3:05am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/7 "2014-12-17T03:05:35Z")

</div>

This is so great @Hootie81!

---

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [December 17, 2014, 3:11am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/8 "2014-12-17T03:11:55Z")

</div>

When I get the photon I will try and upgrade to show cover art, song/station name and all the other good bits of info on the digole display.

I have just started breaking the sonos part off into a library so anyone can use it with any type of input… like a touch screen display, buttons or capacitive touch sensors.

just trying to work out how to get now playing info 🙂

---

<div class="post-metadata">

**Author:** ![cms](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cms](https://community.particle.io/u/cms)\
**Post date:** [February 9, 2015, 2:49pm UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/9 "2015-02-09T14:49:47Z")

</div>

Are you able to “Get Favorites” from your Sonos devices (or have you tried). I structured the command properly (tested with Fiddler). But the FV:2 command doesn’t return the entire envelope, only a portion. If you can successfully read the entire returned SOAP message, I’d love to see the code you used to do so.

---

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [February 10, 2015, 5:38am UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/10 "2015-02-10T05:38:22Z")

</div>

I have noticed that some times the response is truncated… ill try and work it out sometime this week.

---

<div class="post-metadata">

**Author:** ![cms](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cms](https://community.particle.io/u/cms)\
**Post date:** [February 10, 2015, 1:43pm UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/11 "2015-02-10T13:43:32Z")

</div>

[Then is it this that is happening?](https://community.spark.io/t/tcpclient-read-data-missed/6904?u=cms)

---

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [February 10, 2015, 9:47pm UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/12 "2015-02-10T21:47:13Z")

</div>

Yep, i cant figure out why, maybe a buffer thing. the first part of the reply comes back but it is truncated so then the code gets confused. ill spend a bit more time on it tomorrow.

---

<div class="post-metadata">

**Author:** ![cms](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cms](https://community.particle.io/u/cms)\
**Post date:** [March 3, 2015, 2:01pm UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/13 "2015-03-03T14:01:40Z")

</div>

Hootie81,

Have you made any progress receiving the longer responses? I believe I’ve tried every solution and example provided for reading data with TCPClient() on these forums. I can not get it to work for the longer messages…

Any suggestions would be appreciated.

CMS

---

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [March 4, 2015, 1:10pm UTC](https://community.particle.io/t/hover-spark-sonos-remote/8702/14 "2015-03-04T13:10:48Z")

</div>

I couldn’t work it out either… I’ll try and have more of a dig in the code next week. I think the cores buffer is filling up and then it gets truncated. I wonder I’d a spark.process just before the call would help clear anything already in the buffer
