Skip to content

Generic updates#1

Open
hreintke wants to merge 1 commit intoalon24:masterfrom
hreintke:Generic_Updates
Open

Generic updates#1
hreintke wants to merge 1 commit intoalon24:masterfrom
hreintke:Generic_Updates

Conversation

@hreintke
Copy link
Copy Markdown

@alon24 :
This PR is to show you my work in progress. Not at all complete and nicely implemented.
And, as I just noticed, also a number of unwanted updates.
Probably caused by my rusty knowledge of the android studio but I am catching up.

If you want to use the json commands, take the Command_Object branch from SmingRTOS and take a look in the CommandProcessing.md (readme).

In your application you then can do : server.commandProcessing(true,"command","drive");

Then all your websocket messages will be directed to the commandFunction defined for the "drive command"

And processing can be done by :

void processAppCommands(Command inputCommand, CommandOutput* commandOutput)
{
    commandOutput->printf("App : %s\r\n",inputCommand.getCmdString().c_str());

    JsonObject & jsonCommand = inputCommand.getRoot();
    if  (jsonCommand.success())
    {
        if (jsonCommand.containsKey("JSTK"))
        {
            int x = jsonCommand["JSTK"][0];
            int y = jsonCommand["JSTK"][1];
            Serial.printf("JSTK = %d, %d, ",x,y);
        }
        if (jsonCommand.containsKey("BAR"))
        {
            int x = jsonCommand["BAR"][0];
            int y = jsonCommand["BAR"][1];
            Serial.printf("BAR = %d, %d, ",x,y);
        }
        if (jsonCommand.containsKey("BTN"))
        {
            int x = jsonCommand["BTN"][0];
            int y = jsonCommand["BTN"][1];
            Serial.printf("BTN = %d, %d, ",x,y);
        }
        Serial.printf("\r\n");
    }
    else
    {
        Serial.printf("App debug : %s\r\n",inputCommand.getCmdString().c_str() );
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant