-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192863935819# Change-Id: Id5e0894279cada756afb446076c07cf2bb8fced7
- Loading branch information
1 parent
9668e7f
commit 99c514a
Showing
10 changed files
with
419 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...er-link-android/src/main/java/com/tencent/iot/explorer/link/core/link/entity/BleDevice.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.tencent.iot.explorer.link.core.link.entity | ||
|
||
import android.bluetooth.BluetoothDevice | ||
|
||
class BleDevice { | ||
var url = "" | ||
var productName = "" | ||
var devName = "" | ||
var blueDev : BluetoothDevice? = null | ||
} |
28 changes: 28 additions & 0 deletions
28
...ink-android/src/main/java/com/tencent/iot/explorer/link/core/link/entity/BleDeviceInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.tencent.iot.explorer.link.core.link.entity | ||
|
||
class BleDeviceInfo { | ||
companion object { | ||
|
||
fun byteArr2BleDeviceInfo(byteArray: ByteArray): BleDeviceInfo { | ||
var ret = BleDeviceInfo() | ||
if (byteArray.isEmpty()) return ret | ||
if (byteArray.get(0) != 0x08.toByte()) return ret | ||
|
||
ret.llsyncVersion = byteArray[3].toInt().toString() | ||
ret.mtuFlag = if ((byteArray[4].toInt() and 0x80) == 8) 1 else 0 | ||
ret.mtuSize = (byteArray[4].toInt() and 0x02 shl 8) or (byteArray[5].toInt() and 0xFF) | ||
ret.devNameLen = byteArray[6].toInt() | ||
val nameByteArr = ByteArray(ret.devNameLen) | ||
System.arraycopy(byteArray, 7, nameByteArr, 0, ret.devNameLen) | ||
ret.devName = String(nameByteArr) | ||
|
||
return ret | ||
} | ||
} | ||
|
||
var llsyncVersion = "" // 协议版本号 | ||
var mtuFlag = 0 // 是否设置 mtu 当 mtu flag为 1 时,进行 MTU 设置;当 mtu flag 为 0 时,不设置 MTU | ||
var mtuSize = 0 // mtu 大小 | ||
var devNameLen = 0 | ||
var devName = "" | ||
} |
22 changes: 22 additions & 0 deletions
22
...android/src/main/java/com/tencent/iot/explorer/link/core/link/entity/BleDeviceWifiInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.tencent.iot.explorer.link.core.link.entity | ||
|
||
class BleDeviceWifiInfo { | ||
var ssid = "" | ||
var pwd = "" | ||
|
||
fun formatByteArr(): ByteArray { | ||
if (ssid == null || pwd == null) { | ||
return ByteArray(0) | ||
} | ||
|
||
var byteArr = ByteArray( 5 + ssid.toByteArray().size + pwd.toByteArray().size) | ||
byteArr[0] = 0xE2.toByte() | ||
byteArr[1] = ((byteArr.size - 3) / Math.pow(2.0, 8.0).toInt()).toByte() | ||
byteArr[2] = ((byteArr.size - 3) % Math.pow(2.0, 8.0).toInt()).toByte() | ||
byteArr[3] = ssid.toByteArray().size.toByte() | ||
System.arraycopy(ssid.toByteArray(), 0, byteArr, 4, ssid.toByteArray().size) | ||
byteArr[4 + ssid.toByteArray().size] = pwd.toByteArray().size.toByte() | ||
System.arraycopy(pwd.toByteArray(), 0, byteArr, 5 + ssid.toByteArray().size, pwd.toByteArray().size) | ||
return byteArr | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...android/src/main/java/com/tencent/iot/explorer/link/core/link/entity/BleDeviceWifiMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.tencent.iot.explorer.link.core.link.entity | ||
|
||
enum class BleDeviceWifiMode(var modeValue : Byte) { | ||
NULL(0x00.toByte()), | ||
STA(0x01.toByte()); | ||
|
||
fun getValue(): Byte { | ||
return modeValue | ||
} | ||
|
||
companion object { | ||
fun valueOf(modeValue : Byte) : BleDeviceWifiMode{ | ||
if (modeValue == 0x01.toByte()) { | ||
return STA | ||
} | ||
return NULL | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ndroid/src/main/java/com/tencent/iot/explorer/link/core/link/entity/BleWifiConnectInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.tencent.iot.explorer.link.core.link.entity | ||
|
||
class BleWifiConnectInfo { | ||
var wifiMode: BleDeviceWifiMode = BleDeviceWifiMode.NULL | ||
var connected: Boolean = false | ||
var softAp = false | ||
var ssid = "" | ||
var ssidLen = 0 | ||
|
||
companion object { | ||
fun byteArr2BleWifiConnectInfo(byteArray: ByteArray): BleWifiConnectInfo { | ||
var ret = BleWifiConnectInfo() | ||
if (byteArray.isEmpty()) return ret | ||
if (byteArray.get(0) != 0xE2.toByte()) return ret | ||
|
||
ret.wifiMode = BleDeviceWifiMode.valueOf(byteArray[3].toInt().toByte()) | ||
ret.connected = byteArray[4].toInt() == 0 | ||
ret.ssidLen = byteArray[6].toInt() | ||
val ssidByteArr = ByteArray(ret.ssidLen) | ||
System.arraycopy(byteArray, 7, ssidByteArr, 0, ret.ssidLen) | ||
ret.ssid = String(ssidByteArr) | ||
|
||
return ret | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...main/java/com/tencent/iot/explorer/link/core/link/listener/BleDeviceConnectionListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.tencent.iot.explorer.link.core.link.listener | ||
|
||
import com.tencent.iot.explorer.link.core.link.entity.BleDeviceInfo | ||
import com.tencent.iot.explorer.link.core.link.entity.BleWifiConnectInfo | ||
import com.tencent.iot.explorer.link.core.link.exception.TCLinkException | ||
|
||
interface BleDeviceConnectionListener { | ||
fun onBleDeviceConnected() | ||
fun onBleDeviceDisconnected(exception : TCLinkException) | ||
fun onBleDeviceInfo(bleDeviceInfo: BleDeviceInfo) | ||
fun onBleSetWifiModeResult(success: Boolean) | ||
fun onBleSendWifiInfoResult(success: Boolean) | ||
fun onBleWifiConnectedInfo(wifiConnectInfo: BleWifiConnectInfo) | ||
fun onBlePushTokenResult(success: Boolean) | ||
} |
7 changes: 7 additions & 0 deletions
7
...oid/src/main/java/com/tencent/iot/explorer/link/core/link/listener/BleDeviceScanResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tencent.iot.explorer.link.core.link.listener | ||
|
||
import com.tencent.iot.explorer.link.core.link.entity.BleDevice | ||
|
||
interface BleDeviceScanResult { | ||
fun onBleDeviceFounded(bleDevice: BleDevice) | ||
} |
Oops, something went wrong.