i am developing an Android application and I am having some issues with adding bytes to compose a data packet. I have created a method to get the MAC Address of the client and the return value is a string (MACAdd).
private String getMACAddress() {
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
MACAdd= info.getMacAddress();
return MACAdd;
}
I have declared MACAddrs as a static String and have done the following assignment in createPackect() method. MACAddrs = getMACAddress(); byte [] MACAddres = MACAddrs.getBytes();
In the same createPacket() method, I have declared following data as well.
byte Node = (byte)0x3039;
byte Cost = (byte)0x1;
byte MaxMsgSize = (byte) 0x100000;
byte KeepAlivePiriod = (byte)0x2710;
byte NetworkID = (byte)0x1;
I need to add these bytes into a single array to compose the data packet.
byte[] BroadcastPacket = new byte[Node + Cost + SerialNumber + MaxMsgSize + KeepAlivePiriod + NetworkID + MACAddres + IPAddress];
as I am adding two different byte types, I am having a error. Please advise me how to solve this issue......
0 comments:
Post a Comment