As in title I need two - client side - AIDL files (service and callback - below) methods to be exposed to B4A.
B4X:
package com.device.n18jsrv;
/// interface to communicate with device
/**
In18Callback.Stub callback = new In18Callback.Stub() {
public void onDisplay(final byte type, final String message) throws RemoteException {
runOnUiThread(new Runnable() {
public void run() {
if (dialog != null)
dialog.dismiss();
if (message != null)
dialog = new AlertDialog.Builder(MainActivity.this)
.setMessage(message)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
try {
binder.sendOK();
} catch (RemoteException e) {
e.printStackTrace();
}
}
})
.setNegativeButton("C", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
try {
binder.sendC();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}).show();
}
});
}
};
*/
interface In18Callback {
/// new screen callback event.
/**
type -- describe type of screen received:
NORMAL(0) -- no information (message == null).
MESSAGE(1) -- Needs confirmation with OK key.
INFORMATION(2) -- Needs confirmation with OK key.
QUESTION(3) -- Question, needs response C(NO) or OK(YES).
CONFIRMATION(4) -- Confirmation, needs response C(NO) or OK(YES).
WARNING(5) -- Warning confirmation with OK key.
ERROR(6) -- Error confirmation with C key.
PAPER_ERROR(7) -- Paper error confirmation with C key.
TEXT(8) -- Text information
BIOS(9) -- Bios error confirmation with C key.
SYSTEM_ERROR(10) -- System error confirmation with C key.
PROGRESS(11) -- Progress info
message -- string contains message
*/
void onDisplay(int type, String message);
}
B4X:
package com.device.n18jsrv;
import com.device.n18jsrv.In18Callback;
/// interface to communicate with device
/**
In18Service binder;
ServiceConnection connection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
binder = In18Service.Stub.asInterface(service);
try {
binder.registerCallback(callback);
} catch (RemoteException e) {
e.printStackTrace();
}
}
public void onServiceDisconnected(ComponentName name) {
binder = null;
}
};
public void onCreate(Bundle savedInstanceState) {
Intent intent = new Intent() {{
setClassName("com.device.n18jsrv", "com.device.n18jsrv.n18JService");
}};
bindService(intent, connection, 0);
}
protected void onDestroy() {
if (binder != null) {
unbindService(connection);
}
*/
interface In18Service {
/// Listener registration.
/**
To receive informations set In18Callback interface to service
*/
void registerCallback(In18Callback callback);
/// Unregistered listener.
/**
It is necessary for proper working of service to unregister unused listener.
*/
void unregisterCallback(In18Callback callback);
/// Send C key
void sendC();
/// Send OK key
void sendOK();
/// set/get port remap
/**
bios_channel -- channel to communicate with device
PC2(12) -- port PC2
PRNMON(13) -- printout monitor
port_number -- port number COM(1-3)
*/
void setPortRemap(int bios_channel, int port_number);
int getPortRemap(int bios_channel);
/// set/get remap options
/**
bios_channel -- channel for communication with device / COM port
COM1(1)
COM2(2)
COM3(3)
PC2(12) -- port PC2
PRNMON(13) --printout monitor
speed :
9600(1)
19200(2)
38400(3)
57600(4)
115200(5)
data_bit :
5(0x10)
7(0x20)
8(0x30)
stop_bit :
1(0x000)
1.5(0x100)
2(0x200)
parity
NONE(0x0000)
ODD(0x1000)
EVEN(0x2000)
*/
int getPortSpeed(int bios_channel);
int getPortDataBit(int bios_channel);
int getPortStopBit(int bios_channel);
int getPortParity(int bios_channel);
void setPortOps(int bios_channel, int speed, int data_bit, int stop_bit, int parity);
/// get/set speaker level
/**
valules range: 0(muted) .. 7(max loudness)
retuned -1 means error.
*/
int getBuzzerVolume();
void setBuzzerVolume(int volume);
void testBuzzerVolume();
/// Selected components update in recovery mode
/*
file -- path to update file in /cache/ or /data/
*/
void recoveryUpgrade(in String file);
/// factory reset
void wipeUserData();
void wipeCache();
void comPower(int com, int on);
}
Last edited: