Skip to content

bladeX Android API

ximinchao edited this page Nov 29, 2018 · 2 revisions

Android API list

return value PAEW_RET_SUCCESS function success

error code and other value ref https://github.com/extropiescom/bladeX/wiki/Error-Code

com.extropies.common.MiddlewareInterface

1.String getReturnString(final int retValue)

convert return value int type to string

input:int type return value,PAEW_RET_XXX

2.int getDeviceList(Object activity, String strFilter, int scanTimeout, Object enumCallback, String[] devNames, int[] devCount)

get device list

activity Object input:Activity object to connect the device

strFilter String input:string for BLE device enum, format device_name[####device_address], device_name could be part of full string, device_address is the mac address

scanTimeout int input:BLE enum timeout value,ms

enumCallback Object input:BLE enum call back,triggerd when found one device. callback type:com.extropies.common.CommonUtility.enumCallback

devNames String[] output:input data array length = PAEW_MAX_DEV_COUNT,output: device name array

devCount int[] output:input array length = 1,output: data count

3.int initContextWithDevName(Object activity, String devName, Object hearBeatCallback, long[] contextHandle)

init lib with device name

activity Object input:Activity object to connect the device

devName String input:device name to connect, device mac address

hearBeatCallback Object input:triggered when receive heartbeat. callback type:com.extropies.common.CommonUtility.heartBeatCallback

contextHandle long[] output:array length = 1 when as input,devica hanld in array element when as output

4.int initContext(Object activity, String strFilter, int scanTimeout, Object enumCallback, int[] devCount, long[] contextHandle)

init lib

activity Object input:Activity object to connect the device

strFilter String input:string for BLE device enum, format device_name[####device_address], device_name could be part of full string, device_address is the mac address

scanTimeout int input:BLE enum timeout value,ms

enumCallback Object input:BLE enum call back,triggerd when found one device. callback type:com.extropies.common.CommonUtility.enumCallback

devNames String[] output:input data array length = PAEW_MAX_DEV_COUNT,output: device name array

contextHandle long[] output:array length = 1 when as input,devica hanld in array element when as output

5.int freeContext(long contextHandle)

contextHandle long input:device handle

6.int freeContextAndShutDown(long contextHandle)

power off and release lib res

contextHandle long input:device handle

7.int getDevInfo(long contextHandle, int devIndex, int devInfoType, PAEW_DevInfo[] devInfo)

get device info

contextHandle long input:device handle

devIndex int input:device index 0~devcount -1

devInfoType int input:device type info,PAEW_DEV_INFOTYPE_XXX or serval PAEW_DEV_INFOTYPE_XXX

devInfo PAEW_DevInfo[] output:rray length = 1 when as input,devica hanld in array element when as output

8.int getLibraryVersion(byte[] pbVersion, int[] pnVersionLen)

get firmware version

pbVersion byte[] output:array length =4 when as input,firmware version array when as output

pnVersionLen int[] output:array length =1 when as input,firmware version length as output

9.int clearScreen(long contextHandle, int devIndex)

refresh EINK screen

contextHandle long input:device handle

devIndex int input:device index 0~devcount -1

10.int getFPList(long contextHandle, int devIndex, FingerPrintID[] fpList, int[] fpListCount)

get fingerprint template list

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

FingerPrintID FingerPrintID[] output:array length = 3 when as input, fingerprint template list when as output

fpListCount int[] output:array length = 1 when as input,fingerprint template count

11.int enrollFP(long contextHandle, int devIndex, Object enrollCallback)

enroll a new finger to first available position

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

enrollCallback Object input:callback of fingerprint enroll, triggered when get a new enroll status. Interface type:com.extropies.bluetoothlib.BlueToothUtility.fpStateCallback

12.int verifyFP(long contextHandle, int devIndex, Object verifyCallback, FingerPrintID[] fpList, int[] fpListCount)

Fingerprint verification

contextHandle long input:device handle

devIndex int input:device index 0~devcount -1

verifyCallback Object input:callback of fingerprint verify, triggered when get a new verify status. Interface type:com.extropies.bluetoothlib.BlueToothUtility.fpStateCallback

FingerPrintID FingerPrintID[] output:array length = 3 when as input,verified fingerprint list as output

fpListCount int[] output:array length = 1 when as input,verified fingerprint count as output

13.int getFPState(long contextHandle, int devIndex)

get fingerprint stauts

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

14.int abortFP(long contextHandle, int devIndex)

abort fingerprint operation process

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

15.int deleteFP(long contextHandle, int devIndex, FingerPrintID[] pFPList)

delete fingerprint template

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

FingerPrintID FingerPrintID[] input:fingerprint list to delete

16.int calibrateFP(long contextHandle, int devIndex)

calibrate fingerprint sensor

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

17.int initPIN(long contextHandle, int devIndex, String strPIN)

Init PIN

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

strPIN String input: Initial PIN code

18.int verifyPIN(long contextHandle, int devIndex, String strPIN)

verify PIN

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

strPIN String input:PIN code

19.int changePIN(long contextHandle, int devIndex, String strOldPIN, String strNewPIN)

change PIN

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

strOldPIN String input:current PIN

strNewPIN String input:PIN to update

20.int formatDevice(long contextHandle, int devIndex)

format device to clear PIN, fingerprint and all crypto data

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

21.int generateSeed(long contextHandle, int devIndex, int seedLen, byte nN, byte T)

Generate seed

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

seedLen int input:entropy length,between [16, 32] and can be devided by 4

nN int input:db, N

nT int input:db, T

22.int generateSeed_GetMnes(long contextHandle, int devIndex, int seedLen, String[] strMneWord, int[] checkIndex, int[] checkIndexCount)

Generate Mnemonic Phrase and return,as well as the index for test

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

seedLen int input:entropy length,between [16, 32] and can be devided by 4

strMneWord String[] output:input为一个长度为1的数组,output的数组元素即为生成的助记词组

checkIndex int[] output:input为一个长度为PAEW_MNE_INDEX_MAX_COUNT的数组,output的数组元素即为助记词考试的助记词索引

checkIndexCount int[] output:array length = 1 when as input,index count as output

23.int generateSeed_CheckMnes(long contextHandle, int devIndex, String strMneWord)

Mnemonic phrase test result

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

strMneWord String input:Mnemonic phrase string from test,black space between every Mnemonic phrase.

24.int importMne(long contextHandle, int devIndex, String strMneWord)

Import Mnemonic phrase

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

strMneWord String input:Mnemonic phrase string to import,black space between every Mnemonic phrase.

25.int deriveTradeAddress(long contextHandle, int devIndex, byte nCoinType, int[] derivePath)

Derived address

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

nCoinType byte input:coin type

derivePath int[] input derive path

26.int getTradeAddress(long contextHandle, int devIndex, byte nCoinType, String[] strAddress)

Get derived address

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

nCoinType byte input:coin type

strAddress String[] output:array length = 1 when as input,address as output

27.int ETHSign(long contextHandle, int devIndex, Object signCallback, byte[] transaction, byte[] signature, int[] sigLen)

Sign ETH transaction

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

signCallback Object input:callback for sign transaction,user authentication mode should be selected in this function. Waiting for user operation on bladeX done by pulling status from it。Interface type:com.extropies.common.CommonUtility.signCallback

transaction byte[] input:transaction data to be signed

signature byte[] output:An array lengh =PAEW_ETH_SIG_MAX_LEN,signature as output

sigLen int[] output:array length = 1 when as input,signature length as output

28.int EOSSign(long contextHandle, int devIndex, Object signCallback, byte[] transaction, byte[] signature, int[] sigLen)

Sign EOS transaction

contextHandle long input:device handle

devIndex int input:input:device index 0~devcount -1

signCallback Object input:callback for sign transaction,user authentication mode should be selected in this function. Waiting for user operation on bladeX done by pulling status from it。Interface type:com.extropies.common.CommonUtility.signCallback

transaction byte[] input:transaction data to be signed, transaction data is serialized result of a json transaction string, prefixed with chain_id (32 bytes) and tailed with zeros (32 bytes)

signature byte[] output:An array lengh =PAEW_ETH_SIG_MAX_LEN,signature as output

sigLen int[] output:array length = 1 when as input,signature length as output

com.extropies.common.CommonUtility

1.enumCallback

public interface enumCallback { void discoverDevice(String[] strDeviceNames); }

discoverDevice Triggerd when get each device. Function supposed not take too much time.

2.fpStateCallback

public interface fpStateCallback { void pushFingerPrintState(int nFPState); }

pushFingerPrintState Triggered when get a state in fingerprint enrollment and verficaiton. Function supposed not take too much time. nFPState is from PAEW_RET_XXXX

3.signCallback

public interface signCallback { int getAuthResult(); byte getAuthType(); int getPINResult(); String getPIN(); void putSignState(int nSignState); }

This is how sign function works inside:

1) call getAuthResult to get which operation user selected, continue or cancel

2) call getAuthType to get which user authentication mode user selected, PIN or fingerprint.

3) If user authentication mode is PIN, call getPINResult to detect user has input the PIN or click cancel.

4) If user authentication mode is PIN and user has input PIN and click OK, then aquire PIN value in getPIN and call verify PIN. If failed and PIN retry count not 0, go back to step 1

5) If other error detected, abort whole function.

6) If sign function return fail and user authenticate mode is fingerprint, getPINResult will be called to give user another chance to use PIN to finish the transaction.

4.heartBeatCallback

public interface heartBeatCallback { void pushHeartBeatData(byte[] heartBeatData); void pushConnectState(boolean connected); }

pushHeartBeatData This interface is called when get heartbeat packet。Format:0x91 || PowerSource || PowerLevel。

PowerSource 1 byte,0x00: usb charging;0x01:,battery using。PowerLevel 1 byte。Function supposed not take too much time.

pushConnectState This interface is called when device connected, disconnected or get heartbeat packet.

Clone this wiki locally