what does [0] = 0x6D mean where last two can be any hexadecimal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rupert
    New Member
    • Oct 2012
    • 1

    what does [0] = 0x6D mean where last two can be any hexadecimal

    Hi

    Please could someone help me understand the instructions for obtaining a Pin on the below website. I am a C++ novice.

    http://wiibrew.org/wiki/Wiimote#Bluetoo th_Pairing

    Lets assume the Wiimote has the bluetooth address "00:1E:35:3B:7E :6D". If you want the PIN for bluetooth pairing in a simple string, do the following:

    char pin[6];
    pin[0] = 0x6D;
    pin[1] = 0x7E;
    pin[2] = 0x3B;
    pin[3] = 0x35;
    pin[4] = 0x1E;
    pin[5] = 0x00;

    Now "pin" contains your bluetooth pin that should be used for pairing your devices.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    pin is an array of 6 char integers.

    pin[0] is the first element of the array. pin[5] is the last element of the array.

    A char is an 8 bit integer.

    A hexidecimal digit takes 4 bits:

    1 is 0001 decimal 1
    5 is 0101 decimal 5
    6 is 0110 decimal 6
    A is 1010 decimal 10
    D is 1100 decimal 12
    F is 1111 decimal 15

    So you can get 2 hex digits into one char.

    6D is 01101100

    and that is what is inside pin[0].

    If you display the pin[0] you get 109. So you could have used 109 instead of 0x6D but the 109 is not intuitive in meaning whereas the 0x6D is.

    Comment

    Working...