BSB Developer Docs
Loading...
Searching...
No Matches
intercom.h File Reference

Chip-to-chip intercommunication via U(S)ART service. More...

#include <furi.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define RECORD_INTERCOM   "intercom"
 Intercom FURI record identifier.
 

Typedefs

typedef struct Intercom Intercom
 Opaque Intercom type declaration.
 
typedef struct IntercomChannel IntercomChannel
 Opaque channel handle.
 
typedef void(* IntercomRxCallback) (const void *data, size_t data_size, void *context)
 Receive callback function type.
 

Enumerations

enum  IntercomStatus {
  IntercomStatusOk , IntercomStatusUnknown , IntercomStatusErrorSync , IntercomStatusErrorFraming ,
  IntercomStatusErrorTimeout
}
 Enumeration of possible Intercom statuses. More...
 
enum  IntercomChannelId {
  IntercomChannelIdInput , IntercomChannelIdWifiControl , IntercomChannelIdWifiData , IntercomChannelIdStatusLights ,
  IntercomChannelIdCli , IntercomChannelIdBle , IntercomChannelIdCryptoBackup , IntercomChannelIdTlsCrypto ,
  IntercomChannelIdMatter , IntercomChannelIdSlInfo , IntercomChannelIdDebug , IntercomChannelIdMax
}
 Enumeration of available channel identifiers. More...
 

Functions

const char * intercom_get_version_string (void)
 Get the intercom version string.
 
FuriState * intercom_get_state (const Intercom *instance)
 Get the state object that supports change notifications.
 
IntercomChannel * intercom_channel_open (Intercom *instance, IntercomChannelId channel_id, IntercomRxCallback rx_callback, void *context)
 Open an Intercom channel.
 
size_t intercom_tx (IntercomChannel *channel, const void *data, size_t data_size, uint32_t timeout)
 Transmit data through Intercom.
 

Detailed Description

Chip-to-chip intercommunication via U(S)ART service.

Typedef Documentation

◆ IntercomRxCallback

typedef void(* IntercomRxCallback) (const void *data, size_t data_size, void *context)

Receive callback function type.

Parameters
[in]dataPointer to the received data
[in]data_sizeNumber of bytes received
[in,out]contextPointer to a user-specified context object

Enumeration Type Documentation

◆ IntercomChannelId

Enumeration of available channel identifiers.

Enumerator
IntercomChannelIdInput 

Input handling.

IntercomChannelIdWifiControl 

Wireless network control handling.

IntercomChannelIdWifiData 

Wireless network data handling.

IntercomChannelIdStatusLights 

Status lights handling.

IntercomChannelIdCli 

Command line interface handling.

IntercomChannelIdBle 

BLE handling.

IntercomChannelIdCryptoBackup 

Crypto backup handling.

IntercomChannelIdTlsCrypto 

TLS Crypto handling.

IntercomChannelIdMatter 

Matter smart home protocol.

IntercomChannelIdSlInfo 

Wireless co-processor info channel.

IntercomChannelIdDebug 

Testing, debugging, etc.

IntercomChannelIdMax 

Special value for internal use.

◆ IntercomStatus

Enumeration of possible Intercom statuses.

Enumerator
IntercomStatusOk 

Other side in sync, normal operation.

IntercomStatusUnknown 

Default status on startup before sync.

IntercomStatusErrorSync 

Sync failed (other side not responding)

IntercomStatusErrorFraming 

Corrupted frame received from other side.

IntercomStatusErrorTimeout 

Transmission timed out (no ack from other side)

Function Documentation

◆ intercom_channel_open()

IntercomChannel * intercom_channel_open ( Intercom * instance,
IntercomChannelId channel_id,
IntercomRxCallback rx_callback,
void * context )

Open an Intercom channel.

Signals to the other chip that you are ready to accept messages on the specified channel.

You may pass NULL as rx_callback, meaning you don't expect any data to arrive from the other side. If the other side does end up sending data to you, the system will crash with a clear message.

Blocks until the Intercom status becomes IntercomStatusOk.

Warning
You must not call this function from multiple threads on the same chip.
Parameters
[in]instanceIntercom instance
[in]channel_idChannel identifier from IntercomChannelId
[in]rx_callbackData reception callback. May be NULL.
[in]contextContext for provided callback. May be NULL.
Returns
Pointer to the respective IntercomChannel instance

◆ intercom_get_state()

FuriState * intercom_get_state ( const Intercom * instance)

Get the state object that supports change notifications.

The received FuriState object will have an underlying type of IntercomStatus. Use furi_state_subscribe() to get notifications about changes in the current state.

This function never blocks.

Parameters
[in,out]instancepointer to the Intercom instance
Returns
pointer to the FuriState object

◆ intercom_get_version_string()

const char * intercom_get_version_string ( void )

Get the intercom version string.

Returns the version string used for the chip-to-chip handshake. By default this is the firmware git hash; if INTERCOM_FORCE_VERSION is defined at build time, it is that value; if INTERCOM_DISABLE_VERSION_CHECK is defined, it is "intercom".

Returns
Version string.

◆ intercom_tx()

size_t intercom_tx ( IntercomChannel * channel,
const void * data,
size_t data_size,
uint32_t timeout )

Transmit data through Intercom.

Precondition
intercom_channel_open() needs to be called first.

The data will be automatically split into frames and sent asynchronously.

Blocks until the other chip signals that it's ready to accept messages on this channel.

Parameters
[in]channelPointer to the acquired IntercomChannel instance
[in]dataPointer to the data to send
[in]data_sizeNumber of bytes to send
[in]timeoutTime to wait for the transmission to complete, in milliseconds
Returns
number of bytes that were actually transmitted before timeout