Thingstream Client Library  BLD4131-v2.13
Alternative for use with legacy Thingstream_createModemUssdTransport()

Architecture (alternative for legacy USSD modem)

The required stack for communicating with Thingstream infrastructure looks like this

Application
Client (client_api.h)
Protocol layer (thingstream_transport.h)
Base64 codec (base64_codec_transport.h)
* Modem transport (modem_transport.h)
* Line buffer input (line_buffer_transport.h)
* Serial port driver (serial_transport.h)

The layers marked '*' depend on the porting code for the target.

This architecture allows adding additional transport layers, for example to provide log output during development. While testing layers have been implemented, they are not yet part of the SDK, due to platform dependencies.

Example code initializing the stack:

// create the lowest level transport (note that the arguments to
// serial_transport_create(...) are target specific and are defined
// in the target specific file serial_transport.h)
ThingstreamTransport* transport = serial_transport_create("/dev/ttyS0");
ASSERT(transport != NULL);
// wrap data received from the serial port with a line buffer.
// The line buffer can be called from the interrupt service routine of the
// serial driver.
// The buffer size must be at least 290 bytes and be statically allocated.
transport = Thingstream_createLineBufferTransport(transport, line_buf, sizeof(line_buf));
ASSERT(transport != NULL);
// wrap modem to/from serial activity with logger if required
if (logflags != 0)
{
transport = Thingstream_createModemLogger(transport, printf, logflags);
ASSERT(transport != NULL);
}
// wrap it into a modem transport
transport = Thingstream_createModemUssdTransport(transport, 0);
ASSERT(transport != NULL);
// wrap it for base64 encoding
ASSERT(transport != NULL);
// wrap Thingstream protocol implementation
transport = Thingstream_createProtocolTransport(transport, NULL, 0);
ASSERT(transport != NULL);
// wrap client to/from thingstream activity with logger if required
if (logflags != 0)
{
transport = Thingstream_createClientLogger(transport, printf, logflags);
ASSERT(transport != NULL);
}
// create the client utilizing the stack.
ASSERT(client != NULL);
// initialise the client before use
ASSERT(cRes == CLIENT_SUCCESS);

Buffers (alternative for legacy USSD modem)

In order to minimize the memory requirement of the client stack, one single buffer is used for sending and receiving data. This buffer should be reserved by the lowest level transport implementation and passed up via the ThingstreamTransport::get_buffer() function.

An exception to this rule is the Thingstream protocol layer implementation, whose Thingstream_createProtocolTransport() function can optionally be passed a larger buffer to be used for sending and receiving messages that are longer than supported by the underlying transport instances.

Control flow

Return back to main document

ThingstreamClient
struct ThingstreamClient_s ThingstreamClient
Definition: client_api.h:50
Thingstream_createClientLogger
ThingstreamTransport * Thingstream_createClientLogger(ThingstreamTransport *inner, ThingstreamPrintf_t log, uint8_t level_mask)
Thingstream_createBase64CodecTransport
ThingstreamTransport * Thingstream_createBase64CodecTransport(ThingstreamTransport *inner)
Thingstream_createProtocolTransport
ThingstreamTransport * Thingstream_createProtocolTransport(ThingstreamTransport *inner, uint8_t *buffer, uint16_t len)
ThingstreamResult
ThingstreamResult
Definition: thingstream_result.h:34
Thingstream_createClient
ThingstreamClient * Thingstream_createClient(ThingstreamTransport *transport)
CLIENT_SUCCESS
@ CLIENT_SUCCESS
Definition: thingstream_result.h:36
ThingstreamTransport
Definition: transport_api.h:147
Thingstream_Client_init
ThingstreamClientResult Thingstream_Client_init(ThingstreamClient *client)
Thingstream_createModemUssdTransport
ThingstreamTransport * Thingstream_createModemUssdTransport(ThingstreamTransport *inner, uint16_t flags)
Thingstream_createModemLogger
ThingstreamTransport * Thingstream_createModemLogger(ThingstreamTransport *inner, ThingstreamPrintf_t log, uint8_t level_mask)
Thingstream_createLineBufferTransport
ThingstreamTransport * Thingstream_createLineBufferTransport(ThingstreamTransport *inner, uint8_t *data, uint32_t dataSize)