Converting int to byte for ArduinoBLE library?

Hello, I am trying to write to write to a bluetooth characteristic using the ArduinoBLE library

exampleCharacteristic.setValue(value);

Here is the signature of the method int BLETypedCharacteristic<byte>::setValue(byte value)
so the type that value must be is a byte, however I’m not exactly sure how to convert an int (range 0->360) to a byte type in Arduino.

Any help is appreciated, thanks!

It depends on what you understand under the term "convert".
You could map your integer to the byte range using the map function. You could also set your integer value to 255, when it is greater than 255.

Regardless of the way you choose, you will never be able to fit the 0-360 range into a single byte.

An int (2 bytes) will not, of course, fit into 1 byte

You could send each of the 2 bytes of the int separately but what is the function supposed to do with each of them as the function is expecting a single byte ?

What does the function actually do ?

Why are you using BLETypedCharacteristic if you want to send integers? If you want to send a value between 0 and 360, use BLETypedCharacteristic<uint16_t> instead.

When sending multi-byte objects between different devices, you have to make sure the byte order is correct. There are Little and Big Endian getters and setters available, use the correct ones for your situation:

Pieter