How to automate dashcam configuration using geofences

The AI-12 and AI-14 dashcams have become essential tools for both safety and security. By integrating these dashcams with a system that automatically adjusts device settings based on geofence triggers, you can enhance their functionality further. This how-to article will guide you through the process of integrating your AI-12 and AI-14 dashcam's API into an application, allowing you to enable or disable device settings when a vehicle equipped with these dashcams enters or exits user-defined geofence areas. These geofences can be stored either on the vehicle's telematics device or in the cloud.

Prerequisites:

  • AI-12 and AI-14 dashcams connected to the Surfsight API's (API endpoint: /devices/{imei}/device-config in the Surfsight cloud)
  • Application with GPS capabilities
  • Basic programming knowledge

Step 1: Setup your dashcam with the Surfsight API's. Ensure that your AI-12 and AI-14 are already setup with the Surfsight API's. You should have access to the API endpoint /devices/{imei}/device-config within the Surfsight cloud to enable or disable device settings on these dashcams.

Step 2: Implement geofence creation Within your application, create a mechanism that allows users to define and manage geofence areas. Users should be able to create, edit, and delete geofences as needed. These geofences will be used to trigger actions on your AI-12 and AI-14 dashcams.

Step 3: Implement the geofence logic To automate device settings based on user-created geofence triggers, create a logic module within your application. This module should continuously monitor the vehicle's GPS position and check if it enters or exits user-defined geofence areas.

Here's a pseudocode example of the logic:

Copy
Copied
# Sample pseudocode for geofence integration
while True:
    current_position = get_vehicle_gps_position()  # Get the current GPS position of the vehicle
    active_geofences = get_active_geofences()  # Get a list of currently active geofences

    # Assume a parameter of the settings are initially enabled
    set_settings = True

    for geofence in active_geofences:
        if is_inside_geofence(current_position, geofence):
            # The vehicle is inside a user-defined geofence, disable settings
            set_settings = False
            break  # No need to check other geofences if one is triggered

    if set_settings:
        # Make a PUT request to the Surfsight cloud API endpoint `/devices/{imei}/device-config` with the following payload
        payload = {
            "privacy": {
                "gpsEnabled": False,  # By changing this parameter config to False, it will disable specific functionality of the dashcam. 
                "mvaiEnabled": False,
                "cameras": [
                    {
                        "cameraId": 1,  # Camera ID can also be 2 or in the range 51 through 54
                        "recordingEnabled": False,
                        "eventsEnabled": False
                    },
                    # Add entries for other cameras as needed
                ]
            }
        }
        send_put_request_to_dashcam_api(payload)
    else:
        # Make a PUT request to the Surfsight cloud API endpoint `/devices/{imei}/device-config` with the following payload
        payload = {
            "privacy": {
                "gpsEnabled": True,
                "mvaiEnabled": True,
                "cameras": [
                    {
                        "cameraId": 1,  # Camera ID can also be 2 or in the range 51 through 54
                        "recordingEnabled": True,
                        "eventsEnabled": True
                    },
                    # Add entries for other cameras as needed
                ]
            }
        }
        send_put_request_to_dashcam_api(payload)

By following these steps, you can automate the configuration settings on your AI-12 and AI-14 dashcams based on user-defined geofence triggers within your application. Geofences can be stored either on the vehicle's telematics device or in the cloud, depending on your preferences and requirements.

Please note that this is a simplified example, and you may need to consider additional factors such as error handling, authentication, and more depending on your specific implementation.