Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic updates #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hreintke
Copy link

@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