9
9
import net .kazzz .felica .lib .FeliCaLib .CommandPacket ;
10
10
import net .kazzz .felica .lib .FeliCaLib .IDm ;
11
11
12
+ import com .felicanetworks .mfc .PushIntentSegment ;
12
13
import com .felicanetworks .mfc .PushSegment ;
13
14
14
15
public class PushCommand extends CommandPacket {
15
16
private static final Charset URL_CHARSET = Charset .forName ("iso8859-1" );
16
17
private static final Charset ICC_CHARSET = Charset .forName ("iso8859-1" );
17
- //private static final Charset STARTUP_PARAM_CHARSET = Charset.forName("Shift_JIS");
18
18
public static final byte PUSH = (byte ) 0xb0 ;
19
19
20
20
static {
@@ -33,16 +33,16 @@ private static byte[] packContent(byte[] segments) {
33
33
}
34
34
35
35
private static byte [] packSegment (byte []... segments ) {
36
- int bytes = 3 ; // 個別部数(1byte) + チェックサム(2bytes)
36
+ // command(1byte) + check sum(2bytes)
37
+ int bytes = 3 ;
37
38
for (int i = 0 ; i < segments .length ; ++i )
38
39
bytes += segments [i ].length ;
39
40
40
41
ByteBuffer buffer = ByteBuffer .allocate (bytes );
41
- buffer .put ((byte ) segments .length ); // 個別部数
42
- for (int i = 0 ; i < segments .length ; ++i ) // 個別部
43
- buffer .put (segments [i ]);
42
+ buffer .put ((byte ) segments .length );
43
+ for (int i = 0 ; i < segments .length ; ++i ) buffer .put (segments [i ]);
44
44
45
- int sum = segments .length ; // チェックサム
45
+ int sum = segments .length ;
46
46
for (int i = 0 ; i < segments .length ; ++i ) {
47
47
byte [] e = segments [i ];
48
48
for (int j = 0 ; j < e .length ; ++j ) sum += e [j ];
@@ -54,7 +54,7 @@ private static byte[] packSegment(byte[]... segments) {
54
54
55
55
private static byte [][] buildData (PushSegment segment ) throws FeliCaException {
56
56
try {
57
- return buildPushIntentSegment (1 , "market://details?id=com.main.typograffit" , "ANDR01" );
57
+ return buildPushIntentSegment (1 , (( PushIntentSegment ) segment ). getIntentData (). getData (). toString () , "ANDR01" );
58
58
} catch (UnsupportedEncodingException e ) {
59
59
// TODO Auto-generated catch block
60
60
e .printStackTrace ();
@@ -65,22 +65,16 @@ private static byte[][] buildData(PushSegment segment) throws FeliCaException {
65
65
private static byte [][] buildPushIntentSegment (int type , String url , String icc ) throws UnsupportedEncodingException {
66
66
byte [] urlBytes = url .getBytes (URL_CHARSET );
67
67
byte [] iccBytes = icc .getBytes (ICC_CHARSET );
68
-
69
- // type(1byte) + paramBytesLength(2bytes) + urlBytesLength(2bytes) + iccBytesLength(2bytes)
70
68
int capacity = urlBytes .length + iccBytes .length + 7 ;
71
69
ByteBuffer buffer = ByteBuffer .allocate (capacity );
72
70
73
- // 個別部ヘッダ
74
- buffer .put ((byte ) type ); // 起動制御情報
75
- int paramSize = capacity - 3 ; // 個別部パラメータサイズ: type(1byte) + paramBytesLength(2)
71
+ buffer .put ((byte ) type );
72
+ int paramSize = capacity - 3 ;
76
73
putAsLittleEndian (paramSize , buffer );
77
-
78
- // 個別部パラメータ
79
- putAsLittleEndian (0 , buffer ); // URLサイズ
80
- //buffer.put(urlBytes); // URL
81
- putAsLittleEndian (iccBytes .length , buffer ); // iccサイズ
82
- buffer .put (iccBytes ); // icc
83
- buffer .put (urlBytes ); // (アプリケーション起動パラメータ)
74
+ putAsLittleEndian (0 , buffer );
75
+ putAsLittleEndian (iccBytes .length , buffer );
76
+ buffer .put (iccBytes );
77
+ buffer .put (urlBytes );
84
78
return new byte [][] { buffer .array () };
85
79
}
86
80
0 commit comments