Skip to main content

Edge Functions

Introduction

Edge Functions allow you to write custom JavaScript code that can be used directly on the edge. This provides additional capabilities for your IoT use case, such as preprocessing data and publishing it to different routes.

Step 1: Setting up an Edge Function

To create an Edge Function, navigate to the "Edge Functions" tab in the top navigation bar. Click on the "+ ADD EDGE FUNCTION" button to add an Edge Function.

In the dialog that opens enter a name for the function and add your custom code in the integrated code editor.

Remember to click "SAVE" when finished.

Step 2: Writing your custom JavaScript Code

The code editor you're using provides helpful features such as code completion and syntax highlighting while you write standard JavaScript code.

You can use the helper buttons to generate template code to assist with your coding.

If you want to subscribe to or publish data on the Edge, you need to use the SDK functions.

Step 3: Assigning the Edge Function

To assign an Edge Function, follow these steps:

  1. Navigate to the "Devices" tab in the top navigation bar.
  2. Choose the device you want to assign the Edge Function to.
  3. Inside the view of your device, open the Edge Functions Tab.
  4. Assign the created function to the device.

Make sure that your function is enabled. After enabling it, the Edge Function will run automatically.

Limits

Edge functions will not be deployed if Vergelink's CPU usage exceeds 75%. Each Edge function has approximately 32 MB of memory, and exceeding this limit will cause your function to encounter an error.

Working with the VergelinkSDK

The VergeLinkSDK is an essential toolkit to access data events and more. To effectively utilize these capabilities, visit the next page to explore our detailed guide and examples.