Community Blog Buy Now
Blog

Misty Community Forum

Display IP Address On Misty's Face?

How would I go about making a skill that runs on Misty startup, which would display her current IP address on her face? Is this possible? Any direction would be most appreciated!

I’m mostly interested in it to avoid the issue with her constantly changing ip while me and my partners work on her. And unfortunately we don’t have the ability to reconfigure the wireless router because we don’t have access to it (router is our sponsor’s, we can’t touch it).

1 Like

Totally possible! Lots of ways to accomplish this – here’s one option:

  • Register a listener for bump / touch sensor events. Use the event callback to invoke a function that calls the GetDeviceInformation command (which returns a data object with Misty’s IP address). Use this function to show / hide a custom text display layer that you will use for your robot’s IP address.
  • In the callback function for your GetDeviceInformation command, parse the response to get Misty’s IP address, and pass that value into a call on the DisplayText command to write the IP address to your custom text display layer.
  • In the JSON meta file for the skill, add the string "Startup" to the "StartupRules" array, so that Misty knows to run the skill as soon as she boots up.

Here’s some code for an unofficial, tested-only-once sample skill to get you started. When it runs, you can touch Misty’s chin to see her IP address. Touch her chin again to hide the address.


misty.Set("IPLayer", false);

misty.AddReturnProperty("Touched", "sensorName");
misty.AddReturnProperty("Touched", "isContacted");
misty.RegisterEvent("Touched", "TouchSensor", 100, true);

function _Touched(data) {
    if (data.AdditionalResults[1] == true) {
        switch (data.AdditionalResults[0]) {
            case "CapTouch_Chin":
                toggleIPLayer();
                break;
            default:
                return;
        }
    }
}

function toggleIPLayer() {
    if (!misty.Get("IPLayer")) {
        misty.GetDeviceInformation();
        misty.SetTextDisplaySettings("IPLayer", null, null, true);
        misty.SetImageDisplaySettings("DefaultImageLayer", null, null, false);
        misty.Set("IPLayer", true);
    }
    else if (misty.Get("IPLayer")) {
        misty.SetTextDisplaySettings("IPLayer", null, null, false);
        misty.SetImageDisplaySettings("DefaultImageLayer", null, null, true);
        misty.Set("IPLayer", false);
    }
}

function _GetDeviceInformation(data) {
	misty.DisplayText(data.Result.IPAddress, "IPLayer");
	misty.SetTextDisplaySettings("IPLayer", false, false, true, 1, 40, 400, true, "Center", "Center", "Normal", 255, 255, 255, 480, 80, true, "Courier New");
}

And here’s a meta file you can use with that code that demonstrates what the "StartupRules" array should look like:

{
    "Name": "ShowIPAddress",
    "UniqueId": "9a47cc1c-f22d-4705-84ab-338417868575",
    "Description": "My skill is amazing!",
    "StartupRules": [
      "Manual",
      "Robot",
      "Startup"
    ],
    "Language": "javascript",
    "BroadcastMode": "verbose",
    "TimeoutInSeconds": 600,
    "CleanupOnCancel": true,
    "WriteToLog": false,
    "Parameters": {
      "int": 10,
      "double": 20.5,
      "string": "twenty"
    }
  }
4 Likes

Thank you so much for getting back to me so quickly! I’m gonna show this to my partners and get back to you! I’m sure they’re gonna love this as well!! :grin:

1 Like

Good afternoon johnathan,

Just to report back to you about the skill, it works very well so far! Thank you very much for sharing, it has made our lives much easier!

1 Like