Blog

Cloud functions for tailored vehicle telematics solutions – with examples

Integrating cloud-based functionalities like Google Cloud Functions or Amazon Lambda offers a leap in efficiency and customization for providers of telematics and fleet management solutions. They allow easily and cost-efficiently create tailored telematics solutions – that’s why more Navixy’s partners using it. This post explores the use of these cloud features to automate specific operations, crafting tailored telematic solutions that align with modern technological trends.

What are Cloud Functions?

At their core, cloud functions are modular pieces of code, executed in a cloud environment. They enable developers to create highly scalable, serverless applications. The appeal for integrators lies in their ability to efficiently handle tasks without the complexity of managing server infrastructure. This leads to reduced operational costs and enhanced scalability.

Using cloud functions in telematics – creating custom solutions

Why cloud functions are effective for integrators:

  1. Flexibility. Cloud functions stand out for their support of widely-used programming languages, including Python for its exceptional ease of use, Node.js for its prowess in handling asynchronous operations efficiently, and Java for its strength in managing large-scale applications. This broad support empowers your development team to work within a familiar environment, ensuring seamless integration with the Navixy platform.
  2. Cost-efficiency. A standout feature of cloud server functionality is its billing model – you're charged only for the compute time your functions actually use, not for idle server time. For instance, if a function like remote vehicle immobilization is used sporadically, the costs could be just a few dollars a month. This pay-as-you-go approach makes cloud functions incredibly economical, especially for operations that don't require continuous server use.
  3. Minimized maintenance. With cloud functions, the cumbersome tasks of server maintenance and updates are a thing of the past. You are freed from routine actions like patching software, upgrading hardware, and ensuring server security. This not only saves time but also reduces the potential for human error, enhancing overall system reliability.
  4. Scalability with ease. Cloud functions excel in scaling with business needs. A recent U.S. project in the construction equipment rental sector is a perfect example. It started with around 30 assets and seamlessly expanded to 1,700 without additional effort. This scalability shows cloud functions' adaptability to business growth, making them ideal for dynamic industries.

Expanding telematics with Cloud Functions

Integrating the Navixy platform with cloud functions equips system integrators with a robust toolkit for developing bespoke telematics solutions. This combination enhances system capabilities, enabling:

PurposeExamples
Custom alerts and notifications
  • Implement automated instant notifications based on a highly specific combination of telematics data
  • Generate customized reports by combining IoT and business data from multiple sources and/or databases
Automating routine tasks
  • Enable remote ignition block functionality to restrict vehicle use outside designated geofences or during specific times
  • Automate record creation in the Incident Management System (IMS) for particular IoT event combinations
Real-time data processing
  • Process data from specialized sensors for display on BI system dashboards
  • Decode data extracted from CAN bus
Data compliance and compatibility
  • Report data to comply with governmental regulations in industries like hazardous goods transportation
  • Efficiently batch telematics data for integration into analytics databases

In a recent mining industry case involving heavy machinery, fuel efficiency metrics were calculated by extracting data from CAN bus PIDs, such as engine RPM, vehicle speed, and fuel rate. This process enabled real-time monitoring and analysis of vehicle performance, identifying opportunities for fuel consumption optimization. Cloud functions facilitated the accurate decoding and collection of this data. Subsequently, the system analyzed these data patterns to recommend optimal driving speeds and engine RPMs for improved fuel efficiency. Additionally, it issued alerts when abnormal readings indicated potential maintenance issues, ensuring timely intervention.

While the aforementioned case demonstrates advanced data processing capabilities, many practical applications are more straightforward. For those new to cloud functions and integrations, a simpler example will illustrate how to effectively utilize these features with Navixy.

Using Cloud Functions for remote GPS tracker management (Python example with Vonage SMS)

There's a frequent need for remote management of vehicles, particularly for preventing unauthorized use during off-hours or outside designated geozones. A typical scenario involves sending SMS commands to GPS trackers to disable the engine. Let’s explore a straightforward example where a cloud function responds to an external trigger from Navixy, such as MQTT or Webhook, by sending a predefined SMS command to the vehicle.

We'll guide you through setting up a simple Google Cloud Function using Python, with the aim of sending an SMS command to a GPS tracker. We'll use Vonage, a messaging service, for the SMS functionality.

Accessing the Cloud Functions interface

To access the Google Cloud Console, open your web browser and navigate to console.cloud.google.com. Once there, log in using your Google account. If you don’t already have a Google Cloud account, you’ll need to create one by signing up.

Once you're logged in, to navigate to Cloud Functions, locate the navigation menu on the left side of the console:

  • Click on "Cloud Functions" under the "Compute" section. If it's not immediately visible, you may find it under the "More products" section or use the search bar at the top.
  • This will open the Cloud Functions interface where you can create and manage your cloud functions.

In this interface, you'll write and deploy the code described earlier, managing the functions you create for various purposes, such as sending SMS commands to GPS trackers.

Setting up the environment

Start with installing the necessary packages in your requirements.txt file. This includes functions-framework for creating Google Cloud Functions and vonage for sending SMS.

requirements.txt:

functions-framework==3.*
requests
vonage

Writing the function

To create the SMS command function, you'll need to write the following code in main.py:

  • In main.py, import the necessary libraries.
  • Set up a function send_sms_command which will be triggered via an HTTP request.
  • Use environment variables for sensitive information like Vonage API keys and phone numbers. This ensures security and flexibility.
  • The function constructs an SMS message and sends it using Vonage’s services.
  • Handle responses and errors to confirm the message status.

main.py:

import functions_framework
import vonage
import os

@functions_framework.http
def send_sms_command(request):
   # Use environment variables for sensitive information
   client = vonage.Client(key=os.environ.get("VONAGE_API_KEY"), secret=os.environ.get("VONAGE_API_SECRET"))
   sms = vonage.Sms(client)

   # Environment variables for phone numbers and text
   vonage_number = os.environ.get("VONAGE_NUMBER")  # Your Vonage number
   recipient_number = os.environ.get("RECIPIENT_NUMBER")  # Recipient's phone number
   text_message = os.environ.get("TEXT_MESSAGE", "Default command")  # Text message, with a default

   try:
       responseData = sms.send_message({
           "from": vonage_number,
           "to": recipient_number,
           "text": text_message,
       })

       if responseData["messages"][0]["status"] == "0":
           print("Message sent successfully.")
           return 'Message sent successfully.', 200
       else:
           error_text = responseData['messages'][0].get('error-text', 'Unknown error')
           print(f"Message failed with error: {error_text}")
           return f"Message failed with error: {error_text}", 500
   except Exception as e:
       print(f"An error occurred: {e}")
       return f"An error occurred: {e}", 500

To verify the functionality of your Google Cloud Function with two different phone numbers, use the following curl command:

curl -X POST https://us-central1-dn-sandbox-376818.cloudfunctions.net/send-sms-command \
-H "Content-Type: application/json" \
-d '{"recipients": ["Number1", "Number2"]}'

In this command, replace the url with the url pointing to your function, Number1 and Number2 with the actual phone numbers of the SIM cards installed in the GPS devices (for example, 18189399214). This test will ensure that the function is correctly sending SMS commands to the specified numbers.

The path forward with Cloud Functions and Navixy

As we've explored in this post, the integration of cloud-based functionalities like Google Cloud Functions with Navixy's platform opens up a world of efficiency and customization. From complex data processing in heavy machinery to simple SMS commands for remote vehicle immobilization, the versatility of these solutions is evident. They cater not just to advanced requirements but also offer an accessible starting point for those new to cloud integrations.

Navixy is committed to supporting developers in the telematics field with a flexible toolkit that goes beyond just providing IoT data. Our focus is on enabling you to build innovative, tailored solutions that address specific business needs. We encourage you to start building your solutions and invite you to contact our solution engineers for assistance with your projects. We are ready to help you harness the full potential of cloud functions in conjunction with our robust telematics platform, ensuring your success in this dynamic technological landscape.

← Previous articleNext article →
Ready for the most innovative GPS tracking software?
SIGN UP
Recent posts