English | 简体中文
Example for notepad-android-sdk
- Scan notepad
- Connect notepad
- Claim notepad
- Sync notepen pointer
- Import offline memo
- Get notepad info
- Upgrade firmware
val notepadScanner = NotepadScanner(context)
notepadScanner.callback = object : NotepadScanner.Callback {
override fun onScanResult(result: NotepadScanResult) {
println("onScanResult $result")
}
}
notepadScanner.startScan()
// ...
notepadScanner.stopScan()Connect to result, received from NotepadScanner.Callback#onScanResult
Parameter authToken is optional. [0x00, 0x00, 0x00, 0x01] will be use if missing
NotepadConnector.callback = object : NotepadConnectorCallback {
override fun onConnectionStateChange(notepadClient: NotepadClient, state: ConnectionState) {
println("onConnectionStateChange $state")
}
// ...
}
val authToken = null
NotepadConnector.connect(context, result, authToken)
// ...
NotepadConnector.disconnect()Claim with authToken, the parameter of NotepadConnector#connect
notepadClient.claimAuth({
println("claimAuth complete")
}, {
println("claimAuth error $it")
})
// ...
notepadClient.disclaimAuth({
println("disclaimAuth complete")
}, {
println("disclaimAuth error $it")
})-
NotepadMode.Common
Notepad saves only
NotePenPointerwith positive pressure & accurate timestamp, into offline memo -
NotepadMode.Sync
Notepad notify every
NotePenPointer, positive or not, without timestamp, to connected mobile device
Notepad is always NotepadMode.Common (connected or disconnected), unless setMode after connected
notepadClient.setMode(NotepadMode.Sync, {
println("setMode complete")
}) {
println("setMode error $it")
}Receive NotePenPointers in NotepadMode.Sync
notepadClient.callback = object : NotepadClient.Callback {
override fun handlePointer(list: List<NotePenPointer>) {
println("handlePointer ${list.size}")
}
// ...
}memos are saved during NotepadMode.Common. memo consists of NotePenPointers with positive pressure & accurate timestamp.
memos are saved in a FIFO queue. Usually we collect summary and loop to import each memo.
Get memos' count, used space, .etc
notepadClient.getMemoSummary({
println("getMemoSummary success $it")
}) {
println("getMemoSummary error $it")
}Get the first memo's info from the FIFO queue
notepadClient.getMemoInfo({
println("getMemoInfo success $it")
}) {
println("getMemoInfo error $it")
}Import the first memo from the FIFO queue
notepadClient.importMemo({
println("importMemo progress $it")
}, {
println("importMemo success $it")
}) {
println("importMemo error $it")
}Delete the first memo from the FIFO queue
notepadClient.deleteMemo({
println("deleteMemo complete")
}) {
println("deleteMemo error $it")
}println("W: ${notepadClient.width}, H: ${notepadClient.height}")notepadClient.getDeviceName({
println("getDeviceName success $it")
}) {
println("getDeviceName error $it")
}
notepadClient.setDeviceName("name", {
println("setDeviceName complete")
}) {
println("setDeviceName error $it")
}notepadClient.getBatteryInfo({
println("getBatteryInfo success $it")
}) {
println("getBatteryInfo error $it")
}notepadClient.getDeviceDate({
println("getDeviceDate success $it")
}) {
println("getDeviceDate error $it")
}
notepadClient.setDeviceDate(timestamp, {
println("setDeviceDate complete")
}) {
println("setDeviceDate error $it")
}notepadClient.getAutoLockTime({
println("getAutoLockTime success $it")
}) {
println("getAutoLockTime error $it")
}
notepadClient.setAutoLockTime(duration, {
println("setAutoLockTime complete")
}) {
println("setAutoLockTime error $it")
}Upgrade notepad firmware with *.srec file
notepadClient.upgrade("path", version, {
println("upgrade progress $it")
}, {
println("upgrade complete")
}, {
println("upgrade error $it")
})