website logo
BlogPlansAbout UsCareersSignup
⌘K
Introduction
Getting started on Bytebeam Cloud
Concepts
Projects
Streams
Device Shadow
Device Metadata
Actions
Module Integration Guides
ESP32
Arduino
Console Guides
Device Management
Dashboards
Streams (Tables)
Actions
Users
Roles
Release Notes
R10 24-May-2023
R9 10-May-2023
R8 26-Apr-2023
R7 05-Apr-2023
R6 22-Mar-2023
R5 08-Mar-2023
R4 22-Feb-2023
R3 10-Feb-2023
R2 01-Feb-2023
R1 19-Jan-2023
Docs powered by archbee 

Pushing data to Bytebeam

2min

You can use ByteBeam Client to push data to Streams. Follow Creating a Stream guide to create streams.

Rust
|
pub fn publish_to_stream(
        &self, // Bytebeam Client
        stream_name: &str,
        sequence: u32,
        payload: impl Serialize,
    ) -> anyhow::Result<u32>


Payload you want to publish must be something that can be Serialized to JSON.

Lets say you have "led_status" stream with field "status". You can create a struct and use serde::Serialize attribute.

Rust
|
#[derive(Serialize)]
struct LedStream {
    // your custom fields!
    status: String,
}

fn main() {
    // ....
    let bytebeam_client = ByteBeamClient::init()?;

    let sequence = 1;
    let message = LedStream {
        status: "ON".into(),
    };

    // You can remove .expect and handle the error
    bytebeam_client
        .publish_to_stream("led_status", sequence, message)
        .expect("published successfully");
    //...
}



NOTE: Every stream has id and timestamp fields as well, we add them internally, so it is recommended to not include them in your custom struct!



Updated 12 Mar 2023
Did this page help you?
Yes
No
PREVIOUS
Setting up Bytebeam ESP-RS SDK
NEXT
Receiving Actions
Docs powered by archbee