Convert a number to uint64_t doesn't work

Dear support

I need to pass 128 bits service uuid to discovery process as variable, I have an array of 16 bytes of uuid number, it is divided into five parts as show here

BT_UUID_128_ENCODE(w32, w1, w2, w3, w48)
where w48 is 48 bits number to pass to, so I have to define a uint16_t variable(w48) to hold it,  and convert from my byte array (value[ ]) as show below:
uint64_t w48;
w48 = value[10]<<40 + value[11]<<32;   //this line ends up 0
w48 += value[12]<<24+value[13]<<16;
w48 +=value[14]<<8 + value[15];
But the first line doesn't work, it ends up 0, while the other 2 lines works individually. let me know what I can do please?
Thank you!
Ping
Parents
  • further - to make it more strict, code is like below:

    w48 = (value[10]<<40) & 0xff0000000000 + (value[11]<<32)&0xff00000000;   //this line doesn't work

    w48 += (value[12]<<24)&0xff000000)+(value[13]<<16)&0xff0000);  //this works 
    w48 +=((value[14]<<8)&0xff00) + value[15];  //this works too
    It is just first line when number is over 32 bits have problems, help please!
    Ping
Reply
  • further - to make it more strict, code is like below:

    w48 = (value[10]<<40) & 0xff0000000000 + (value[11]<<32)&0xff00000000;   //this line doesn't work

    w48 += (value[12]<<24)&0xff000000)+(value[13]<<16)&0xff0000);  //this works 
    w48 +=((value[14]<<8)&0xff00) + value[15];  //this works too
    It is just first line when number is over 32 bits have problems, help please!
    Ping
Children
No Data
Related