SDK Reference

You can find the latest version of the Soracom Orbit SDK in the Downloads section.

AssemblyScript

The orbit-sdk-assemblyscript module contains the Orbit AssemblyScript SDK. Import the module into your code in order to use the methods.

import {
  log,
  getInputBuffer,
  getInputBufferAsString,
  getTagValue,
  getSourceValue,
  getLocation,
  getTimestamp,
  getUserdata,
  setOutputJSON,
} from "orbit-sdk-assemblyscript";

Function Signatures

Function Returns Description
log(message: string) void Output a string to the log.
getInputBuffer() Uint8Array Get the input data as an array of Uint8.
getInputBufferAsString() string Get the input data as a character string.
getTagValue(name: string) string Get the value of a tag from the data source (SIM). Returns an empty string if the tag name is not found.
getSourceValue(name: string) string Get the value of an attribute from the data source (SIM). Returns an empty string if the attribute is not found.
getLocation() Location: { lat: f64, lon: f64 } Get the Location object when using a plan-KM1 SIM. Returns NaN if the location is not available.
getTimestamp() i64 Get the timestamp when Orbit received input data.
getUserdata() string Get the userdata attribute of the Metadata Service.
setOutputJSON(json: string) void Return JSON data to Orbit as the WASM module output data.

The SDK also includes functions that begin with the orbit_ prefix, which provide lower level functionality. These functions are wrapped in the methods above, which should be sufficient for most cases, however you can access these functions if you want to output in a format other than JSON:

Function Returns Description
orbit_set_output(json: i32, len: i32) void Return the data located in memory indicated by the pointer and length to Orbit as the WASM module output data.
orbit_set_output_content_type(type: i32, len: i32) void Return the data located in memory indicated by the pointer and length to Orbit as the WASM module output Content-Type.

Please refer to the SDK implementation for how to use the setOutputJSON() function.


Rust

The orbit-sdk-rust crate contains the Orbit Rust SDK. Include it in your code in order to use the methods.

use soracom_orbit_sdk as orbit;

Function Signatures

Function Returns Description
log(message: &str) Output a string to the log.
get_input_buffer() Vec<u8> Get the input data as a u8a vector.
get_tag_value(name: &str) String Get the value of a tag from the data source (SIM). Returns an empty string if the tag name is not found.
get_source_value(name: &str) String Get the value of an attribute from the data source (SIM). Returns an empty string if the attribute is not found.
get_location() Option<Location>: { lat: f64, lon: f64 } Get the Location object when using a plan-KM1 SIM. Returns None if the location is not available.
get_timestamp() i64 Get the timestamp when Orbit received input data.
get_userdata() String Get the userdata attribute of the Metadata Service.
set_output_json(jsonstr: &str_) Return JSON data to Orbit as the WASM module output data.

The SDK also includes functions that begin with the orbit_ prefix, which provide lower level functionality. These functions are wrapped in the methods above, which should be sufficient for most cases, however you can access these functions if you want to output in a format other than JSON:

Function Returns Description
orbit_set_output(ptr: i32, len: i32) Return the data located in memory indicated by the pointer and length to Orbit as the WASM module output data.
orbit_set_output_content_type(ptr: i32, len: i32) Return the data located in memory indicated by the pointer and length to Orbit as the WASM module output Content-Type.

Please refer to the SDK implementation for how to use the set_output_json() function.


C/C++

The orbit-sdk-c library contains the Orbit C/C++ SDK. Include it in your code in order to use the methods.

#include "soracom/orbit.h"

Function Signatures

Return Type Function Description
void soracom_log(const char* fmt, ...) Output a string to the log.
int32_t soracom_get_input_buffer_as_string(const char** buf, size_t* siz) Get the input data as a buffer. When you have finished using the input data, release the buffer using soracom_release_input_buffer() with the *buf pointer.
void soracom_release_input_buffer(const char* buf) Frees the memory allocated by soracom_get_input_buffer_as_string().
int32_t soracom_get_tag_value(const char* name, size_t name_len, const char** value, size_t* value_len) Get the value of a tag from the data source (SIM). Returns an empty string if the tag name is not found.
int32_t soracom_get_source_value(const char* name, size_t name_len, const char** value, size_t* value_len) Get the value of an attribute from the data source (SIM). Returns an empty string if the attribute is not found.
int32_t orbit_has_location() Check if the location information of a plan-KM1 SIM can be obtained. Returns 1 if it can be obtained, and 0 if it cannot.
double orbit_get_locatoin_lat() Get the latitude value of the location information. Returns undefined if the location is not available.
double orbit_get_locatoin_lon() Get the longitude value of the location information. Returns undefined if the location is not available.
int64_t orbit_get_timestamp() Get the timestamp when Orbit received input data.
int32_t soracom_get_userdata_as_string(const char** buf, size_t* siz) Get the userdata attribute of the Metadata Service.
void soracom_set_json_output(const char* buf, size_t siz) Return JSON data to Orbit as the WASM module output data.

The SDK also includes functions that begin with the orbit_ prefix, which provide lower level functionality. These functions are wrapped in the methods above, which should be sufficient for most cases, however you can access these functions if you want to output in a format other than JSON:

Return Type Function Description
void orbit_set_output(const char* buf, size_t siz) Return the data located in memory indicated by the pointer and length to Orbit as the WASM module output data.
void orbit_set_output_content_type(const char* buf, size_t siz) Return the data located in memory indicated by the pointer and length to Orbit as the WASM module output Content-Type.

Please refer to the SDK implementation for how to use the soracom_set_json_output() function.


TinyGo

The Orbit TinyGo SDK is provided at soracom/orbit-sdk-tinygo. Import it in your code in order to use the methods.

import sdk github.com/soracom/orbit-sdk-tinygo

Function Signatures

Function Returns Description
Log(msg string) Output a string to the log.
GetInputBuffer() ([]byte, error) Get the input data as a buffer. Returns ErrNoInputBuffer or ErrInvalidInputBufferLength if error occurred.
GetTagValue(name string) ([]byte, error) Get the value of a tag from the data source (SIM). Returns ErrNoTagValue or ErrInvalidTagValueLength if error occurred.
GetSourceValue(name string) ([]byte, error) Get the value of an attribute from the data source (SIM). Returns an empty string if the attribute is not found. Returns ErrNoSourceValue or ErrInvalidSourceValueLength if error occurred.
GetLocation() (*Location, error) Get the Location object when using a plan-KM1 SIM. Location struct should be { Lat: _float64_, Lon: _float64_ }. Returns ErrNoLocationInformation if the location is not available.
GetTimestamp() int64 Get the timestamp when Orbit received input data.
SetOutputJSON(out string)` Return JSON data to Orbit as the WASM module output data.