I am fairly new to java programming and I am trying to develop a Bluetooth Low Energy (4.0) fitness device for Android (4.3+). I bought a bunch of different devices from different hardware manufacturers for testing and one of the instructions for sending values to the device is as follows:
Characteristic Fitness Goals
size: 8 bytes
D0 D1 D2 D3 D4 D5 D6 D7
D0: number of days in month, uint8_t
D1 D2: distance walked , uint16_t
D3 D4: distance ran, uint16_t
D5 D6: steps taken, uint16_t
D7: number of users, uint8_t
Here is the problem:
I have 5 int values that I need to put into a byte array that will be written to the device. Take these values for example:
16 (# days in month)
450 (distance walked)
334 (distance ran)
800 (steps taken)
4 (number of users)
I am not sure how to take these different uint8_t and uint16_t values and put them into one byte array in order to write to the Bluetooth Device. Can anyone please tell me how this can be done?
Thank you!