# Particle Function max characters

**URL:** <https://community.particle.io/t/particle-function-max-characters/43090>\
**Category:** Cloud\
**Created:** [July 19, 2018, 1:35pm UTC](https://community.particle.io/t/particle-function-max-characters/43090 "2018-07-19T13:35:52Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![gemfarmer](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gemfarmer/32/16833_2.png) [@gemfarmer](https://community.particle.io/u/gemfarmer)\
**Post date:** [July 19, 2018, 1:35pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/1 "2018-07-19T13:35:52Z")

</div>

Hi!

I’m trying to pass JSON data into my [particle function](https://docs.particle.io/reference/firmware/raspberry-pi/#particle-function-) and I am routinely blowing past the 63 character limit for String passed into the function.

I can limit this value in my web app, but it would also be nice to have device-end validation. Right I have something more/less like this:

```auto
Particle.function("do-something", doSomethingHandler)
...
int doSomethingHandler(String response)
{
  Serial.println(response);
  return 1;
}

```

When I send too much data, the `response` that is outputted is that data that was last sent on the device. Even if it was from a separate function. How can I tell that the response is too large so that I can return -1 at the end of the function call?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [July 19, 2018, 1:46pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/2 "2018-07-19T13:46:47Z")

</div>

This doesn’t answer your question, but in [0.8.0-rc.4](https://github.com/particle-iot/firmware/pull/1537) the function argument size was increased from 63 characters to 622 characters, so you’ll have a lot more room for sending JSON data.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [July 19, 2018, 2:10pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/3 "2018-07-19T14:10:53Z")

</div>

I’m pretty sure the cloud won’t send any parameter longer than allowed to the device nor would the Device OS accept (i.e. copy) any longer parameter, so the application will never see a _too long_ `response`.  
If you have a unique terminator character which only can appear at the end of your `response`, then you can check for its existence - if it’s not there, the `response` must have been too long (or you failed to send it - also being an error to report as e.g. `-1` tho’).

---

<div class="post-metadata">

**Author:** ![gemfarmer](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gemfarmer/32/16833_2.png) [@gemfarmer](https://community.particle.io/u/gemfarmer)\
**Post date:** [July 19, 2018, 7:40pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/4 "2018-07-19T19:40:03Z")

</div>

@rickkas7: I'm pumped for [0.8.0-rc.4](https://github.com/particle-iot/firmware/pull/1537)! I'll probably wait for the "stable" release, however. Looking forward to it. In the time being, I can manage the payload size and send a few smaller chunks of data. If we end up sending much larger chunks of code (over 622 chars), then this code will probably be helpful anyway. **Is there any function rate limiting that I should be aware of as I pursue this method?**

@ScruffR I was able to get a helpful response after all – so thanks for encouraging me to continue down that pay.

> I’m pretty sure the cloud won’t send any parameter longer than allowed to the device nor would the Device OS accept (i.e. copy) any longer parameter, so the application will never see a too long response.

The device was never receiving a _too long_ response, but it was sending me data that I had previously seen. Is this a bug? Should I report it?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [July 19, 2018, 7:47pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/5 "2018-07-19T19:47:09Z")

</div>

> [@gemfarmer](#):
>
> The device was never receiving a too long response, but it was sending me data that I had previously seen. Is this a bug? Should I report it?

Where would this response data come from?  
`Particle.function()` only returns integers in response to a function call.

Or do you mean you got the same output from `Serial.println(response);` with only _one_ call of the function?

---

<div class="post-metadata">

**Author:** ![gemfarmer](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gemfarmer/32/16833_2.png) [@gemfarmer](https://community.particle.io/u/gemfarmer)\
**Post date:** [July 23, 2018, 2:26pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/6 "2018-07-23T14:26:23Z")

</div>

@ScruffR sorry for not being clear. In the example that I gave (below), I am referring to the data passed to the function, `response`. When the String data was sufficiently short, the data was passed properly. When it was too long, the function would be triggered, and pass whatever data was previously passed to a function. So if I passed a 60 char string first, the handler would receive that data properly. If I then passed a 70 char string, the handler would receive the first 60 char string. I’ve now determined that I can receive an error on the app side of the function call, but on the device side, there is no error, just incorrect data.

```auto
Particle.function("do-something", doSomethingHandler)
...
int doSomethingHandler(String response)
{
  Serial.println(response);
  return 1;
}

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [July 23, 2018, 2:47pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/7 "2018-07-23T14:47:37Z")

</div>

If this is a reproducable problem, then this should probably be filed as an issue report

> **[particle-iot/firmware](https://github.com/particle-iot/firmware/issues)**
>
> firmware - Device OS (Firmware) for Particle Devices

---

<div class="post-metadata">

**Author:** ![gemfarmer](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gemfarmer/32/16833_2.png) [@gemfarmer](https://community.particle.io/u/gemfarmer)\
**Post date:** [July 23, 2018, 3:08pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/8 "2018-07-23T15:08:15Z")

</div>

@ScruffR ok. Will do that when I get a chance!

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![paulm](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/paulm/32/15528_2.png) [@paulm](https://community.particle.io/u/paulm)\
**Post date:** [July 27, 2018, 10:06am UTC](https://community.particle.io/t/particle-function-max-characters/43090/9 "2018-07-27T10:06:14Z")

</div>

> [@rickkas7](#):
>
> This doesn’t answer your question, but in 0.8.0-rc.4 the function argument size was increased from 63 characters to 622 characters, so you’ll have a lot more room for sending JSON data.

How sure are you that this actually went in?  
I'm running firmware v0.8.0-rc.8 and latest released iOS SDKs and I'm getting:

```auto
Sending: {"tz":600,"dst":false,"off": 0,"sch": 14680071,"pump":3,"clean":6}
Calling func "setConfig" with "{"tz":600,"dst":false,"off": 0,"sch": 14680071,"pump":3,"clean":6}", length: 66
SendState err: Error Domain=ParticleAPIError Code=1000 "Maximum argument length cannot exceed 63" UserInfo={NSLocalizedDescription=Maximum argument length cannot exceed 63}

```

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [July 27, 2018, 10:20am UTC](https://community.particle.io/t/particle-function-max-characters/43090/10 "2018-07-27T10:20:16Z")

</div>

Now that I think about it, I believe for the same reason that you can’t publish 622 bytes from the API yet, you may not be able to send more than 63 bytes in a function call either. Both changes require both a device firmware change and an API change, and the API side change hasn’t been deployed yet.

---

<div class="post-metadata">

**Author:** ![paulm](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/paulm/32/15528_2.png) [@paulm](https://community.particle.io/u/paulm)\
**Post date:** [July 27, 2018, 10:21am UTC](https://community.particle.io/t/particle-function-max-characters/43090/11 "2018-07-27T10:21:48Z")

</div>

So I’m not insane which is nice to know. 😉

Any idea when this is getting rolled out?  
I’m not in a hurry for it, just curious.

Thanks for the reply.

---

<div class="post-metadata">

**Author:** ![Ric](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ric/32/514_2.png) [@Ric](https://community.particle.io/u/Ric)\
**Post date:** [July 27, 2018, 5:24pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/12 "2018-07-27T17:24:36Z")

</div>

Is the data you’re trying to pass, a lot longer than 63 bytes, or only a little longer? If only a little longer, you could send the data in a more compact format than JSON, if that’s an option. JSON is useful in that there are libraries for unpacking it, and it is a standard way to pass data, but it is not very space efficient.

---

<div class="post-metadata">

**Author:** ![paulm](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/paulm/32/15528_2.png) [@paulm](https://community.particle.io/u/paulm)\
**Post date:** [July 27, 2018, 9:18pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/13 "2018-07-27T21:18:35Z")

</div>

Hi Ric.

I’ve alread compressed it down to under the 63 bytes hence why I’m not in a hurry.

However I can see that our data may grow in the future and so I’m curious about the ballpark timeframe for this fix, eg 2 weeks, 2 months, 2 years.

---

<div class="post-metadata">

**Author:** ![paulm](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/paulm/32/15528_2.png) [@paulm](https://community.particle.io/u/paulm)\
**Post date:** [August 8, 2018, 1:07pm UTC](https://community.particle.io/t/particle-function-max-characters/43090/14 "2018-08-08T13:07:39Z")

</div>

> [@rickkas7](#):
>
> the API side change hasn’t been deployed yet.

Is there a plan for when this will be deployed?
