โ† Back to Home
Data Format
Algorithms
Protocol
Integration
Test

๐Ÿ“Š Data Format Specification

Define and validate location data structures for pet tracking systems.

GPS Location Format (WGS84)

{
  "location": {
    "latitude": 37.7749,
    "longitude": -122.4194,
    "altitude": 52.3,
    "accuracy": 5.2,
    "timestamp": "2025-12-25T14:30:00Z"
  },
  "device": {
    "id": "PET-TRACKER-12345",
    "batteryLevel": 85,
    "signalStrength": -72
  },
  "pet": {
    "id": "pet_abc123",
    "name": "Max",
    "breed": "Golden Retriever"
  }
}

Geofence Boundary Definition

{
  "geofence": {
    "id": "zone_home_001",
    "name": "Home Safe Zone",
    "type": "circle",
    "center": {
      "latitude": 37.7749,
      "longitude": -122.4194
    },
    "radius": 100,
    "unit": "meters",
    "alerts": {
      "onEnter": true,
      "onExit": true,
      "notificationChannels": ["push", "sms", "email"]
    }
  }
}

Activity Event Schema

{
  "event": {
    "type": "location_update",
    "petId": "pet_abc123",
    "timestamp": "2025-12-25T14:30:00Z",
    "location": {
      "latitude": 37.7749,
      "longitude": -122.4194,
      "accuracy": 5.2
    },
    "activity": {
      "type": "walking",
      "speed": 1.2,
      "distance": 450,
      "duration": 375
    },
    "environment": {
      "indoor": false,
      "temperature": 22.5
    }
  }
}

๐Ÿงฎ Tracking Algorithms

Explore position calculation, geofencing, and battery optimization algorithms.

Position Filtering Algorithm

Kalman filter for smoothing GPS coordinates and removing noise:

function kalmanFilter(measurement, previousEstimate, errorCovariance) {
  const processNoise = 0.01;
  const measurementNoise = 5.0;

  // Prediction
  let predictedEstimate = previousEstimate;
  let predictedCovariance = errorCovariance + processNoise;

  // Update
  const kalmanGain = predictedCovariance /
                     (predictedCovariance + measurementNoise);
  const estimate = predictedEstimate +
                   kalmanGain * (measurement - predictedEstimate);
  const covariance = (1 - kalmanGain) * predictedCovariance;

  return { estimate, covariance };
}

Geofence Detection

Battery Optimization Logic

function optimizeTrackingInterval(batteryLevel, movementSpeed, mode) {
  // Adaptive tracking based on battery and activity
  if (mode === 'power_save') {
    return batteryLevel < 20 ? 600 : 300; // 10min or 5min
  }

  if (movementSpeed > 2.0) { // Fast movement (running/car)
    return 10; // 10 seconds
  } else if (movementSpeed > 0.5) { // Walking
    return 30; // 30 seconds
  } else { // Stationary
    return batteryLevel < 30 ? 120 : 60; // 2min or 1min
  }
}
30s
Current Interval
25 days
Battery Estimate
ยฑ5m
Accuracy

๐Ÿ”Œ Communication Protocols

Real-time location updates and event streaming protocols.

WebSocket Event Streaming

// Client connection
const ws = new WebSocket('wss://api.pettrack.wia.org/v1/stream');

ws.on('connect', () => {
  ws.send(JSON.stringify({
    type: 'subscribe',
    petId: 'pet_abc123',
    events: ['location', 'geofence', 'battery']
  }));
});

ws.on('message', (data) => {
  const event = JSON.parse(data);
  handleLocationUpdate(event);
});

MQTT for IoT Devices

// MQTT Topic Structure
pet/{pet_id}/location        // Location updates
pet/{pet_id}/status          // Device status
pet/{pet_id}/alerts          // Alert notifications
pet/{pet_id}/config          // Configuration updates

// Example publish
mqtt.publish('pet/abc123/location', JSON.stringify({
  lat: 37.7749,
  lng: -122.4194,
  accuracy: 5.2,
  timestamp: Date.now()
}));

RESTful API Endpoints

Method Endpoint Description
GET /v1/pets/{id}/location Get current location
GET /v1/pets/{id}/history Get location history
POST /v1/geofences Create geofence zone
GET /v1/pets/{id}/alerts Get alert notifications
PUT /v1/pets/{id}/mode Update tracking mode

End-to-End Encryption

๐Ÿ”’ Security: All location data is encrypted using AES-256-GCM before transmission. Device authentication uses JWT tokens with RSA-2048 signatures.

๐Ÿ”— System Integration

Integrate pet tracking with mobile apps, smart home, and third-party services.

Mobile App SDK (iOS/Android)

// iOS Swift Example
import WIAPetTracking

let tracker = PetTracker(apiKey: "your_api_key")

tracker.subscribe(petId: "pet_abc123") { location in
    print("Pet location: \(location.latitude), \(location.longitude)")
    updateMapView(location)
}

tracker.createGeofence(
    center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194),
    radius: 100,
    onExit: { alert in
        showNotification("Pet left safe zone!")
    }
)

Smart Home Integration

// Home Assistant Integration
automation:
  - alias: "Pet Arrived Home"
    trigger:
      platform: state
      entity_id: device_tracker.pet_max
      to: 'home'
    action:
      - service: light.turn_on
        entity_id: light.front_door
      - service: notify.mobile_app
        data:
          message: "Max has arrived home!"

Veterinary System Connect

โœ“ Healthcare Integration: Share activity data and location history with veterinary clinics through secure FHIR-compliant APIs for better health monitoring.

Integration Examples

๐Ÿ 
Smart Home
๐Ÿ“ฑ
Mobile Apps
๐Ÿฅ
Vet Systems
๐ŸŒ
Pet Services

Webhook Configuration

๐Ÿงช Live Testing Interface

Simulate real-time pet tracking scenarios and test system behavior.

Pet Tracker Simulator

85%

Live Tracking Map

Recent Events

Waiting for simulation to start...

System Metrics

0
Location Updates
0 km
Distance Traveled
ยฑ5m
Avg Accuracy
Active
Device Status