Send USSD APDU

Author: Scruffy bear 2009.09.07
Some operator would implement the Send USSD in the STK, the Card vendor need to construct the Send USSD APDU command, here give out a brief sample about the detail of the this APDU command.
Fetch
      ME --> ICC  : A0 12 00 00 23
      ME <-- ICC  : D0 21 81 03 01 12 00 82 02 81 83 85 0C 53 65 6E 64 69 6E 67 20 55 53 53 44 8A 08 0F AA 9A CD A6 A2 8D 00 90 00
the dissection of the APDU command,
      Command Detail : 81 03 01 12 00
      Device Identities : 82 02 82 81
      alpha identifier : "Sending USSD"  85 0C 53 65 6E 64 69 6E 67 20 55 53 53 44
      USSD String Tag, 8A Data Coding Scheme : 0F  USSD String:  AA 9A CD A6 A2 8D 00,   8A 08 0F AA 9A CD A6 A2 8D 00
For the USSD String, it's a little complicated, please refer GSM03.38 for the detail, below is the detail for this sample.
AA 9A CD A6 A2 8D 00 transfer to bits format:  10101010 10011010 11001101 10100110 10100010 10001101 00000000
do the 7 bit coding transfer, the result is: 0101010 0110101  0110110 0110110  0101010 0110100 0100011, i.e. 2A 35 36 36 2A 34 23
transfer to Ascii code is: *566*4#, yes, this STK command send out the USSD request to the server of '*566*4#'
about the 7bit coding, have to refer to the detail of GSM03.38
let's take this example to do the transform(AA 9A CD A6 A2 8D 00).
10101010 10011010 11001101 10100110 10100010 10001101 00000000
the highest 1 bit of first byte move to the lowest bit of 2nd byte , i.e.
0101010 100110101 11001101 10100110 10100010 10001101 00000000
the highest 2 bits of second byte move to the lowest bit of 3rd byte, i.e.
0101010 0110101 1100110110 10100110 10100010 10001101 00000000
the highest 3 bits of third byte move to the lowest bit of 4th byte, i.e.
0101010 0110101 0110110 10100110110 10100010 10001101 00000000
the highest 4 bits of 4th byte move to the lowest bit of 5th byte, i.e.
0101010 0110101 0110110 0110110 101000101010 10001101 00000000
the highest 5 bits of 5th byte move to the lowest bit of 6th byte, i.e.
0101010 0110101 0110110 0110110 0101010 1000110110100 00000000
the highest 6 bits of 6th byte move to the lowest bit of 7th byte, i.e.
0101010 0110101 0110110 0110110 0101010 0110100 00000000100011
the highest 7 bits of 7th byte move to the lowest bit of 8th byte, i.e.
0101010 0110101 0110110 0110110 0101010 0110100 0100011 0000000
this is the final result: 2A 35 36 36 2A 34 23 00(*566*4#)

你可能感兴趣的:(c,String,server,command,Scheme,byte)