HTTP Get Request from local

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

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

thanks for the reply…

im using 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


Have you read the thread I linked above?

That’s exactly what’s done there.


thanks a lot its working now… thanks a lot :grinning:

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

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.

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 :wink:

1 Like

thanks a lot man :heart_eyes:

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

thanks man

1 Like

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

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.

okay thanks, man

i will try with my photon and let u know,

by the way merry chirstmas :grinning:

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?


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

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

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

Here the code for EEPROM.put in the softAp code

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);
        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);

        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

   char value[4][32];


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

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

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 :wink:

okay fine, thanks

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

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?

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?

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

SerialLogHandler logger(LOG_LEVEL_ALL);