B4X:

```
uint16_t CRC16Calc(uint8_t *data, uint16_t size)
{
#define CRC16 0x8005
uint16_t out = 0;
uint16_t bits_read = 0, bit_flag;
uint16_t idx = 0;
while (size > 0)
{
bit_flag = out >> 15;
out <<= 1;
out |= (data[idx] >> bits_read) & 1;
bits_read++;
if (bits_read > 7)
{
bits_read = 0;
idx++;
size--;
}
if (bit_flag) out ^= CRC16;
}
uint16_t i;
for (i = 0; i < 16; ++i)
{
bit_flag = out >> 15;
out <<= 1;
if (bit_flag) out ^= CRC16;
}
uint16_t crc = 0;
i = 0x8000;
uint16_t j = 0x0001;
for (; i != 0; i >>= 1, j <<= 1)
{
if (i & out) crc |= j;
}
return crc;
}
```

I need to convert it in B4A or Java to embed in test app.

Unfortunately I don't know Java and B4A don't very well.

I think converting this code to java is easier that in B4A.

Someone can help me?

Thanks.