embassy-rs / nrf-softdevice

Apache License 2.0
259 stars 79 forks source link

set_value & notify_value with i16 and other values? #265

Closed Gibbz closed 1 month ago

Gibbz commented 1 month ago

Im trying to send values to my device from the nrf using set_value(handle: u16, val: &[u8]) and notify_value(conn: &Connection, handle: u16, val: &[u8]) but they both take a u8 object.

How do I set an i16 value? Also I will want to send other values, string etc later too.... Ive tried using a bitshift to split the i16 into 2 u8. But that gives the error Raw(DataSize)

// bitshift a 16 bit number into two 8 bit numbers
pub fn shift_split_u16(short_16: i16) -> [u8; 2] {
    [(short_16 >> 8) as u8, (short_16 & 0xff) as u8]
}
Gibbz commented 1 month ago

For some reason it's working now! Confused I wish for better documentation and examples 👍