indexx is a global variable.
There is no use passing it in a function which wants to modify it. Changing the bytereceived function correspondingly.