# HTTP Get Request from local

**URL:** <https://community.particle.io/t/http-get-request-from-local/58867>\
**Category:** Firmware\
**Tags:** photon\
**Created:** [December 23, 2020, 2:09pm UTC](https://community.particle.io/t/http-get-request-from-local/58867 "2020-12-23T14:09:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 23, 2020, 2:09pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/1 "2020-12-23T14:09:53Z")

</div>

Hi Everyone, right now im using softAp for my particle photon to setup the wifi configuration it working fine. for now im customizing the code which provided by the particle. right now im facing issue

concept: using softAp im changing the wifi creditinals and also i created a text box using html to get the user data entered data to save locally (inside the particle code to use those data)

issue facing: i can’t able to store those user entered data into the particle code. can i use http GET or is there any idea to store that user entered data into the particle code

please let me know @peekay123 @bko @ScruffR  
thanks in advance

---

<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:** [December 23, 2020, 2:13pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/2 "2020-12-23T14:13:08Z")

</div>

Here I have a post that shows how you'd setup your code to receive url-encoded parameters

> [@Photon SoftAP Inputs](https://community.particle.io/t/photon-softap-inputs/31289/23):
>
> This would be one way to add two extra inputs to the index.html (just replace the original with this) const char index\_html[] = "\<!DOCTYPE html\>" "\<html\>" "\<head\>" " \<meta name='viewport' content='width=device-width, initial-scale=1'\>" " \<title\>Setup your device\</title\>" " \<link rel='stylesheet' type='text/css' href='style.css'\>" "\</head\>" "\<body\>" " \<h1\>Connect me to your WiFi!\</h1\>" " \<h3\>My device ID:\</h3\>" " \<input type=text id='device-id' size='25' value='' disabled /\>" " \<button t…

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 23, 2020, 2:26pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/3 "2020-12-23T14:26:02Z")

</div>

thanks for the reply…

im using 192.168.0.1 while the photon is in listening mode … to setup wifi configuration using softAp  
is that possible to store those user entered data to store that data into the variable for future use? while softAp is running in the listening mode

thanks

---

<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:** [December 23, 2020, 2:29pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/4 "2020-12-23T14:29:28Z")

</div>

Have you read the thread I linked above?

That’s exactly what’s done there.

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 23, 2020, 4:25pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/5 "2020-12-23T16:25:49Z")

</div>

thanks a lot its working now… thanks a lot 😀

but still i need to update more for my project, actually those data will be erased after the board reset. as i read in that theard u have mentioned to use EEPROM to save the data permanently.  
is that any other way to store that data? and another small question is we are writing the data frequently into the photon means it will cause any problem in future?

thanks in advance

---

<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:** [December 23, 2020, 4:29pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/6 "2020-12-23T16:29:55Z")

</div>

> [@Siva](#):
>
> is that any other way to store that data?

[EEPROM](https://docs.particle.io/reference/device-os/firmware/photon/#eeprom) is the most convenient and works without any extra hardware and even without cloud connection, but you can of course add an SD card, external flash, ... or store the data in the cloud (once connected) and retrieve it from there.

> [@Siva](#):
>
> writing the data frequently into the photon means it will cause any problem in future?

If you don't intend to rewrite it 100.000-1.000.000 times during the life time of the device you should not need to worry 😉

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 23, 2020, 4:34pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/7 "2020-12-23T16:34:56Z")

</div>

thanks a lot man 😍

i didn’t implemented the eeprom yet, after completion of this task i will let u know the status.

thanks man

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 23, 2020, 5:52pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/8 "2020-12-23T17:52:14Z")

</div>

Suddenly one more doubt raised, is that string or char data can able to write directly to the EEPROM address? Or only int and double datas only

---

<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:** [December 24, 2020, 6:06am UTC](https://community.particle.io/t/http-get-request-from-local/58867/9 "2020-12-24T06:06:06Z")

</div>

You can store strings and even structs in EEPROM via `EEPROM.put()` and retrieve them via `EEPROM.get()` - that’s all documented in the link I provided above.

However, `String` objects are a different kind since their string contents is _not_ stored in the object that gets stored but at a dynamic location which will become invalid.

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 24, 2020, 10:30am UTC](https://community.particle.io/t/http-get-request-from-local/58867/10 "2020-12-24T10:30:28Z")

</div>

okay thanks, man

i will try with my photon and let u know,

by the way merry chirstmas 😀

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 24, 2020, 12:28pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/11 "2020-12-24T12:28:58Z")

</div>

I tired with updating the int data into the EEPROM, that time it works fine, but now when im putting the string data the output will be like this

������������������������������������������������������������������������������������������������@�

what was an issue? can u explain?

thanks

---

<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:** [December 24, 2020, 12:48pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/12 "2020-12-24T12:48:04Z")

</div>

If you show your code (including variable definitions) we'd probably better be able to answer that, but I suspect this is what I was already addressing before with this sentence

> [@ScruffR](#):
>
> However, _ **`String` objects** _ are a different kind since their string contents is _not_ stored in the object that gets stored but at a dynamic location which will become invalid.

You may notice "`String` object" vs. `string` in my earlier statement

> [@ScruffR](#):
>
> You can store _ **strings** _ and even structs

`String` objects are not the same as "normal" C strings (aka `char` arrays).

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 24, 2020, 12:53pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/13 "2020-12-24T12:53:51Z")

</div>

Here the code for EEPROM.put in the softAp code

```cpp
void myPage(const char* url, ResponseCallback* cb, void* cbArg, Reader* body, Writer* result, void* reserved)
{
    char _url[strlen(url)+1];
    char* query;
    char* value;
    
    Log.trace("handling page %s", url);

    strcpy(_url, url);
    if (strtok_r(_url, "?&", &query)) 
    { /
      Log.trace("pre for() - URL: <%s>, *query: <%s>", _url, query);
      while(query) 
      {
        Log.trace("in for() - URL: <%s>, *query: <%s>", _url, query);
        char *token = strtok_r(query, "=", &value);
        Log.trace("*query: <%s>, *value: <%s>, *token: <%s>", query, value, token);

        EEPROM.clear();
        int eeprom_addr[4] = {0,32,96,128};
        if(strcmp(token, "str1") == 0) 
        { 
          char* val = strtok_r(NULL, "?&=", &value);
          strncpy(str[0], val, sizeof(str[0]));
          //str[0][sizeof(str[0]) - 1] = 0;
          EEPROM.put(eeprom_addr[0],(const char*)str[0]);
          Log.trace("String1: <%s>", str[0]);
        }
        else if(strcmp(token, "str2") == 0) 
        { // with a key str2
          char* val = strtok_r(NULL, "?&=", &value);
          strncpy(str[1], val, sizeof(str[1]));
          //str[1][sizeof(str[1]) - 1] = 0;
          EEPROM.put(eeprom_addr[1],(const char*)str[1]);
          Log.trace("String2: <%s>", str[1]);
        }
        else if(strcmp(token, "str3") == 0) 
        { // with a key str2
          char* val = strtok_r(NULL, "?&=", &value);
          strncpy(str[2], val, sizeof(str[2]));
          //str[2][sizeof(str[2]) - 1] = 0;
          EEPROM.put(eeprom_addr[2],(const char*)str[2]);
          Log.trace("String3: <%s>", str[2]);
        }
        else if(strcmp(token, "str4") == 0) 
        { // with a key str2
          char* val = strtok_r(NULL, "?&=", &value);
          strncpy(str[3], val, sizeof(str[3]));
          //str[3][sizeof(str[3]) - 1] = 0;
          EEPROM.put(eeprom_addr[3],(const char*)str[3]);
          Log.trace("String4: <%s>", str[3]);
        }
        //EEPROM.put(0,(const char*)str[0]);
        

        query = value; // continue with the rest
      }
    }

```

here the code for getting those data using EEPROM.get inside the void loop

```cpp
   char value[4][32];
   EEPROM.get(0,value[0]);
   EEPROM.get(32,value[1]);
   EEPROM.get(96,value[2]);
   EEPROM.get(128,value[3]);

   Particle.publish("data_1",value[0]);
   delay(1000);
   Particle.publish("data_2",value[1]);
   delay(1000);
   Particle.publish("data_3",value[3]);
   delay(1000);
   Particle.publish("data_4",value[4]);
   delay(1000);

```

---

<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:** [December 24, 2020, 2:12pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/14 "2020-12-24T14:12:51Z")

</div>

Where and how have you got `str[]` defined?  
What do you get with your `Log.trace()` statements?

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 24, 2020, 2:16pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/15 "2020-12-24T14:16:54Z")

</div>

I’ve declared in global  
char str[4][32]; // global

What do you get with your `Log.trace()` statements?  
for log statements, this will be used for html page content. that statement was already in the softAp code. so i just left as it is

---

<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:** [December 24, 2020, 2:18pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/16 "2020-12-24T14:18:49Z")

</div>

In order to debug the issue you should have a look at the output created by the `Log.trace()` statements over USB Serial.  
That’s what these are for 😉

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 24, 2020, 2:21pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/17 "2020-12-24T14:21:04Z")

</div>

okay fine, thanks

then how about that EEPROM issue? im facing rightnow is that any solution to solve?

---

<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:** [December 24, 2020, 2:22pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/18 "2020-12-24T14:22:29Z")

</div>

That _ **is** _ the issue the logs should help clarify.

BTW, you do have a stray forward slash (`/`) in the code snippet above. Is this there in your actual code too?

---

<div class="post-metadata">

**Author:** ![Siva](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Siva](https://community.particle.io/u/Siva)\
**Post date:** [December 24, 2020, 2:28pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/19 "2020-12-24T14:28:51Z")

</div>

BTW, you do have a stray forward slash ( `/` ) in the code snippet above. Is this there in your actual code too?

that one will be a mistake, there i used to put the command there while copy and paste it came as a mistake…

and how can i get those data over USB serial… is there any software is there?

---

<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:** [December 24, 2020, 2:33pm UTC](https://community.particle.io/t/http-get-request-from-local/58867/20 "2020-12-24T14:33:02Z")

</div>

You could use any serial terminal program available for your computer.  
But Particle CLI offers this command `particle serial monitor --follow` to do that too.

If you haven’t already you may need to add this line in the declaration’s section of your code

```cpp
SerialLogHandler logger(LOG_LEVEL_ALL);

```

[Next page](https://community.particle.io/t/http-get-request-from-local/58867.md?page=2)
