fn transmit(reading: f32) {
    let reading_bytes = reading.to_bits().to_be_bytes();
    let msg = [
        SUCCESS_BYTE,
        reading_bytes[0],
        reading_bytes[1],
        reading_bytes[2],
        reading_bytes[3],
    ];

    // todo: Store this header globally; don't recreate it each time.
    // todo: We can't use a static var due to the function call.
    let esb_header = EsbHeader::build()
        .max_payload(MAX_PAYLOAD_SIZE)
        .pid(0)
        .pipe(0)
        .no_ack(false)
        .check()
        .unwrap();

    // todo: The ability to send fault codes etc.

    free(|cs| {
        access_global!(ESB_APP, esb_app, cs);
        if let Some(response) = esb_app.read_packet() {
            // let rssi = response.get_header().rssi();
            response.release();
        }

        let mut packet = esb_app.grant_packet(esb_header).unwrap();
        let length = msg.len();
        &packet[..length].copy_from_slice(&msg);
        packet.commit(length);
        esb_app.start_tx();
    });
}
/// Transmit a sensor reading over ESB, with our 5-byte message format.
Transmit a sensor reading over ESB, with our 5-byte message format.
Transmit a sensor reading over ESB with our 5 - byte message format .
fn transmit(reading: f32) {
    let reading_bytes = reading.to_bits().to_be_bytes();
    let msg = [
        SUCCESS_BYTE,
        reading_bytes[0],
        reading_bytes[1],
        reading_bytes[2],
        reading_bytes[3],
    ];
    // todo: Store this header globally; don't recreate it each time.
    // todo: We can't use a static var due to the function call.
    let esb_header = EsbHeader::build()
        .max_payload(MAX_PAYLOAD_SIZE)
        .pid(0)
        .pipe(0)
        .no_ack(false)
        .check()
        .unwrap();
    // todo: The ability to send fault codes etc.
    free(|cs| {
        access_global!(ESB_APP, esb_app, cs);
        if let Some(response) = esb_app.read_packet() {
            // let rssi = response.get_header().rssi();
            response.release();
        }
        let mut packet = esb_app.grant_packet(esb_header).unwrap();
        let length = msg.len();
        &packet[..length].copy_from_slice(&msg);
        packet.commit(length);
        esb_app.start_tx();
    });
}
fn transmit ( reading : f32 ) { let reading_bytes = reading . to_bits ( ) . to_be_bytes ( ) ; let msg = [ SUCCESS_BYTE , reading_bytes [ 0 ] , reading_bytes [ 1 ] , reading_bytes [ 2 ] , reading_bytes [ 3 ] , ] ; // todo: Store this header globally; don't recreate it each time. // todo: We can't use a static var due to the function call. let esb_header = EsbHeader :: build ( ) . max_payload ( MAX_PAYLOAD_SIZE ) . pid ( 0 ) . pipe ( 0 ) . no_ack ( false ) . check ( ) . unwrap ( ) ; // todo: The ability to send fault codes etc. free ( | cs | { access_global ! ( ESB_APP esb_app cs ) ; if let Some ( response ) = esb_app . read_packet ( ) { // let rssi = response.get_header().rssi(); response . release ( ) ; } let mut packet = esb_app . grant_packet ( esb_header ) . unwrap ( ) ; let length = msg . len ( ) ; & packet [ .. length ] . copy_from_slice ( & msg ) ; packet . commit ( length ) ; esb_app . start_tx ( ) ; } ) ; }
Transmit a sensor reading over ESB, with our 5-byte message format.
Transmit a sensor reading over ESB with our 5 - byte message format .
reading
f32
reading
f32