Development

When Orbit processes data, it will call the uplink() or downlink() function of a WASM module whenever a device sends data to the Unified Endpoint, or a server or cloud service sends a response to the device, respectively.

These functions do not take any arguments. Instead, use the getInput (or equivalent) functions provided by each SDK to read the incoming value, and the setOutput (or equivalent) functions to define the transformed outgoing value.

These functions should return an integer (i32) value indicating whether the function succeeded (returning 0 or positive value) or failed (returning a negative value).

When you develop a WASM module, keep in mind:

Please note that WebAssembly System Interface (WASI) is not supported, so system calls such as file system operations or network access cannot be implemented in a Soralet module. The external interface for reading input data and setting output data is defined in the Orbit SDK. Refer to the SDK Reference for details.

If Binary Parser is also enabled, Binary Parser will execute first, and the results will be passed into the WASM module as the input data.

Development Notes


AssemblyScript

The Orbit AssemblyScript SDK includes a template script located at assembly/index.ts. You can edit this file to implement your data processing code.

Your code should export an uplink() function, a downlink() function, or both.

// For processing uplink (Device to Soracom)
export function uplink(): i32 {
  /* code  */
}

// For processing downlink (Soracom to Device)
export function downlink(): i32 {
  /* code */
}

When you have finished editing assembly/index.ts, compile it into a WASM module using one of the following methods in VS Code:

The compiled WASM module will be saved to build/soralet.wasm.


Rust

The Orbit Rust SDK includes a template script located at src/lib.rs. You can edit this file to implement your data processing code.

Your code should define a public uplink() function, a public downlink() function, or both. Ensure that you include the #[no_mangle] attribute in order to prevent symbol names from being mangled during compile, so that Orbit can correctly reference the functions.

// For processing uplink (Device to Soracom)
#[no_mangle]
pub fn uplink() -> i32 {
  /* code */
}

// For processing downlink (Soracom to Device)
#[no_mangle]
pub fn downlink() -> i32 {
  /* code */
}

When you have finished editing src/lib.rs, compile it into a WASM module using one of the following methods in VS Code:

The compiled WASM module will be saved to target/wasm32-unknown-unknown/debug/soralet.wasm.


C/C++

The Orbit C/C++ SDK includes a template source code file located at src/main.cpp. You can edit this file to implement your data processing code.

Your code should export either an uplink() function, a downlink() function, or both. Ensure that you include the EMSCRIPTEN_KEEPALIVE macro in order to supress compiler optimization so that Orbit can correctly reference the functions.

If using C++, ensure that you enclose these functions in extern "C" { ... } in order to supress mangled function names.

// For processing uplink (UE to SORACOM)
EMSCRIPTEN_KEEPALIVE
int32_t uplink()
{
    /* code */
    return 0;
}

// For processing downlink (SORACOM to UE)
EMSCRIPTEN_KEEPALIVE
int32_t downlink()
{
    /* code */
    return 0;
}

When you have finished editing src/main.cpp, compile it into a WASM module using one of the following methods in VS Code:

The compiled WASM module will be saved to build/soralet.wasm.

When building, you may see warnings that certain functions (beginning with an orbit_ prefix, such as orbit_log and orbit_get_input_buffer) are undefined. These functions are provided directly by Orbit during runtime, so you can safely ignore these warnings.