NetBurner 3.5.6
PDF Version
Find My IP Task

Find My IP Application

Overview

The Find My IP application is a C++ embedded system program that demonstrates web client functionality by retrieving and displaying the external IP address of the device. This application creates a separate, higher-priority task that navigates to a web service and retrieves IP address information.

Purpose

This program serves as an example of web client implementation on an embedded system, specifically showcasing how to:

  • Initialize and configure network stack
  • Make HTTP GET requests to external web services
  • Parse JSON responses
  • Handle network errors gracefully
  • Implement task-based architecture with proper priority management

How It Works

  1. Network Initialization: The application initializes the network stack and waits for an active network connection (DHCP address assignment)
  2. Web Client Setup: Configures a web client task with higher priority (MAIN_PRIO - 2) to handle HTTP requests
  3. HTTP Request: Makes a GET request to http://httpbin.org/ip which returns JSON data containing the client's external IP address
  4. JSON Parsing: Parses the JSON response to extract the "origin" field containing the IP address
  5. Display Results: Prints the retrieved IP address to the console
  6. Error Handling: Implements comprehensive error handling with descriptive error messages

Key Features

  • Asynchronous Operation: Uses separate tasks for network operations
  • JSON Support: Built-in JSON parsing capabilities
  • Error Reporting: Comprehensive error handling and reporting system
  • Network Diagnostics: Optional system diagnostics for debugging
  • Configurable Timing: 10-second intervals between operations

Technical Details

Dependencies

Key Functions

  • UserMain(): Main application entry point
  • DoActualClientRequest(): Handles the actual HTTP request and JSON parsing
  • HandleErrorState(): Processes and displays error conditions

Configuration

  • Target URL: http://httpbin.org/ip
  • Application Name: "FindMyIp"
  • Network Timeout: 5 seconds for DHCP acquisition
  • Request Interval: 10 seconds between requests
  • Task Priority: MAIN_PRIO - 2 (higher than main task)

Usage

The application runs continuously once started, making periodic requests to determine the external IP address. This is useful for:

  • Network connectivity testing
  • IP address monitoring
  • Embedded system network diagnostics
  • Learning web client implementation patterns

Output

When successful, the application displays:

Application started
My IP address is [YOUR_EXTERNAL_IP]

Error conditions are reported with descriptive messages including error codes and descriptions.

Notes

  • System diagnostics are enabled by default but should be disabled for production code
  • The application uses standard HTTP (not HTTPS) for simplicity
  • Designed for embedded systems with real-time operating system (RTOS) support
  • Requires active internet connection and DNS resolution capability