Ranja AZ
-
Content Count
26 -
Joined
-
Last visited
-
Days Won
1
Posts posted by Ranja AZ
-
-
Thank you! The issue is resolved now. following code:
procedure TForm2.Button2Click(Sender: TObject);
var
OpenResult : JMxResult;
begin
OpenResult := TJMxResult.Create;
OpenResult := mSM62K2DriverApi.open(StringToJString('/dev/ttyS0'),115200);
Memo1.Lines.Add(JStringToString(OpenResult.getMsg));
end;procedure TForm2.Button3Click(Sender: TObject);
var
OpenResult : JMxResult;
begin
OpenResult := TJMxResult.Create;
OpenResult := mSM62K2DriverApi.close;
Memo1.Lines.Add(JStringToString(OpenResult.getMsg));
end;procedure TForm2.FormCreate(Sender: TObject);
begin
CanPrint := True;
DeviceEnginex := deviceEngine;
Printerx := deviceEngine.getPrinter();
DeviceInfo := deviceEngine.getDeviceInfo();
POSModel := JStringToString(DeviceInfo.GetModel());
TJGeneralDdi.JavaClass.ddi_device_poweron;
sleep(1000);
mSM62K2DriverApi := TJSM62K2DriverApi.JavaClass.init;
end;Regards.
- 1
-
Here is what I tried:
unit UBio306;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Controls.Presentation,
classes,decoder, JustouchApi, MxAlgShankshake, SM62K2UARTAPI, nexgoSystemService_sdk_71,
Androidapi.JNI.Media, FMX.Helpers.Android,
Androidapi.JNI.JavaTypes,
Androidapi.JNIBridge,
Androidapi.Helpers,
Androidapi.JNI.GraphicsContentViewText, FMX.Memo.Types, FMX.ScrollBox,
FMX.Memo;Type
TForm2 = class(TForm)
ImageControl1: TImageControl;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Déclarations privées }
DeviceEnginex : JDeviceEngine;
FOnPrintListner : JOnPrintListener;
public
{ Déclarations publiques }
DeviceInfo : JDeviceInfo;
POSModel : String;
CanPrint : Boolean;
Printerx : JPrinter1;
mSM62K2DriverApi : JSM62K2DriverApi;
end;TOnPrintListener=class(TJavaLocal, JOnPrintListener)
public
procedure onPrintResult(param0: Integer); cdecl;
end;var
Form2: TForm2;
deviceEngine : JDeviceEngine;implementation
{$R *.fmx}
procedure TOnPrintListener.onPrintResult(param0: Integer);
begin
//
end;procedure TForm2.Button1Click(Sender: TObject);
begin
if FOnPrintListner=Nil then
FOnPrintListner := TOnPrintListener.Create;
Printerx.initPrinter;
Printerx.setTypeface(TJTypeface.JavaClass.DEFAULT);
Printerx.appendPrnStr(StringToJString('Test this ' + FormatDateTime('dd/mm/yy-hh:nn:ss',now) + #13#10 +
#13#10#13#10#13#10#13#10#13#10#13#10),18,TJAlignEnum.JavaClass.LEFT,true);
Printerx.startPrint(false,FOnPrintListner);
end;procedure TForm2.Button2Click(Sender: TObject);
var
OpenResult : JMxResult;
begin
OpenResult := TJMxResult.Create;
OpenResult := mSM62K2DriverApi.open(StringToJString('/dev/ttyS0'),115200);
Memo1.Lines.Add(JStringToString(OpenResult.getMsg));
end;procedure TForm2.Button3Click(Sender: TObject);
var
OpenResult : JMxResult;
begin
OpenResult := TJMxResult.Create;
OpenResult := mSM62K2DriverApi.close;
Memo1.Lines.Add(JStringToString(OpenResult.getMsg));
end;procedure TForm2.FormCreate(Sender: TObject);
begin
CanPrint := True;
DeviceEnginex := deviceEngine;
Printerx := deviceEngine.getPrinter();
DeviceInfo := deviceEngine.getDeviceInfo();
POSModel := JStringToString(DeviceInfo.GetModel());
TJGeneralDdi.JavaClass.ddi_device_poweron;
sleep(1000);
end;end.
When I click on Button2 I get the access violation error.
-
What I don't understand is the creation of the App class (public class App extends Application) for opening the serial port with the instructions below:
MxResult<?> open = App.getInstance().getSM62K2DriverApi().open(com, baudRate);
showLog(open.getMsg(), true);
MxResult<?> init = App.getInstance().getSM62K2DriverApi().AlgHandshakeInit();Is it not possible to directly create an mSM62K2DriverApi object?
Regards.
-
The code is in Java. I don't know the Java language. So I want to do it in Delphi.
Thanks!
-
Hello everybody!
I have a NEXGO android POS with an integrated biometric reader. I have already converted the SDKs to delphi for the biometrics reader.
I also have a sample application but it's in Java (see attached).
Can someone help me translate the following program lines?SM62K2UARTAPI.pas file is SDK library.
app.java:
package com.miaxis;
import android.app.Application;
import com.miaxis.alg.MxFingerAlgAPI;
import com.miaxis.data.AppDataBase;
import com.miaxis.finger.api.SM62K2DriverApi;
import com.miaxis.utils.FileUtils;import java.io.File;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;/**
* @author Tank
* @date 2021/12/11 5:40 下午
* @des
* @updateAuthor
* @updateDes
*/
public class App extends Application {private final Executor executor = Executors.newSingleThreadExecutor();
private final SM62K2DriverApi mSM62K2DriverApi = new SM62K2DriverApi();
private final MxFingerAlgAPI mMxFingerAlgAPI = new MxFingerAlgAPI();private static final String LicenseName = "license.txt";
public static final int RequestCode = 1001;private static App context;
@Override
public void onCreate() {
super.onCreate();
context = this;
AppDataBase.getInstance().init(this);
}public String getLicenseFilePath(){
return new File(FileUtils.getPrivateDirectory(this), App.LicenseName).getAbsolutePath();
}public static App getInstance() {
return context;
}public SM62K2DriverApi getSM62K2DriverApi() {
return this.mSM62K2DriverApi;
}public MxFingerAlgAPI getMxFingerAlg() {
return this.mMxFingerAlgAPI;
}public Executor getExecutor() {
return executor;
}
}
in MainActivity.java: (What I want to convert in Delphi)
private void open() {
showLog(getString(R.string.text_open));
mMainViewModel.busy.postValue(true);
mMainViewModel.opened.postValue(true);
GeneralDdi.ddi_device_poweron();
SystemClock.sleep(500);
try {
String com = binding.etCom.getText().toString();
int baudRate = Integer.parseInt(binding.etBaudRate.getText().toString());
MxResult<?> open = App.getInstance().getSM62K2DriverApi().open(com, baudRate);
showLog(open.getMsg(), true);
MxResult<?> init = App.getInstance().getSM62K2DriverApi().AlgHandshakeInit();
showLog(getString(R.string.text_Alg_Handshake_Init) + "\n" + init.getMsg(), true);
mMainViewModel.opened.postValue(open.isSuccess());
} catch (Exception e) {
e.printStackTrace();
showLog(getString(R.string.button_open) + "\n" + e);
mMainViewModel.opened.postValue(false);
}
mMainViewModel.busy.postValue(false);
}Thank you!
-
Hello everyone!
Following all your instructions, everything is OK now.
Many thanks to all of you! -
-
-
You are right about Authorization!
-
Before calling "payments" API, I called another API using the same token access: token work fine!
-
by adding the following lines
request.Params.AddItem;
request.Params[3].Name := 'Content-Type';
request.Params[3].Value := 'application/json';
request.Params[3].Kind := pkHTTPHEADER;result is the same: status 401
-
Uwe Raabe,
Thank you so much! It's work!
After Authorization, I have to execute payment with the following cURL:
curl --location --request POST 'https://<API server host>/merchant/v1/payments/'
--header 'Content-Type: application/json'
--header 'Authorization: bearer koeQidreesddfzsbxOXKjccccccc' \
--header 'X-Country: MG'
--header 'X-Currency: MGA'
--data-raw '{
"reference": "Testing API",
"subscriber": {
"country": "MG",
"currency": "MGA",
"msisdn": 331170348
},
"transaction": {
"amount": 1000,
"country":"MG",
"currency": "MGA",
"id": "242EB08E-0ACD-445C-8FF7-320FFD85B4A4"
}
}'With Postman it's work with status 200. But with following code status is always 401
var client := TRESTClient.Create('https://<API server host>/merchant/v1/payments/');
try
var request := TRESTRequest.Create(nil);
try
request.Client := client;
request.Method := TRESTRequestMethod.rmPOST;
request.Accept := '*/*';request.Params.AddItem;
request.Params[0].Name := 'Autorization';
request.Params[0].Value := 'bearer koeQidreesddfzsbxOXKjccccccc';
request.Params[0].Kind := pkHTTPHEADER;request.Params.AddItem;
request.Params[1].Name := 'X-Country';
request.Params[1].Value := 'MG';
request.Params[1].Kind := pkHTTPHEADER;request.Params.AddItem;
request.Params[2].Name := 'X-Currency';
request.Params[2].Value := 'MGA';
request.Params[2].Kind := pkHTTPHEADER;request.AddBody('{"reference": "Testing API","subscriber": {"country": "MG", "currency": "MGA", "msisdn": 331170348}, "transaction": {"amount": 1000, "country":"MG", "currency": "MGA", "id": "FE9833FE-D5A3-4450-9786-90735F75EBFB"}}', TRESTContentType.ctAPPLICATION_JSON);
request.Execute;
var response := request.Response;Is there error in my code?
Regard!
-
-
Hello everyone,
Can someone help me to transform the following cURL request with use of TRESTClient and TRESTRequest:
curl --location --request POST 'https://<API server host>/auth/oauth2/token'
-H 'Content-Type: application/json'-H 'Accepte: */*'
--data-raw '{
"client_id": "013C1A93-3D33-4986-8A7C-773D02C26214",
"client_secret": "FE8FBA46-6ABF-4DF1-8D5E-31345DAAD194",
"grant_type": "client_credentials"
}'Regards.
-
Dave Nottage, thanks you again for your response!
I'll try it!
Regard
-
I need to intercepte USSD response in Android. Following link https://newbedev.com/prevent-ussd-dialog-and-read-ussd-response example written by Java, I need to create the same in Delphi but I have no idea.
Else, Is there anyone who has experience on using TelephonyManager.UssdResponseCallback. (https://developer.android.com/reference/android/telephony/TelephonyManager.UssdResponseCallback)?
Can help?
Thanks
-
Hello!
Please, I need help about sending and receiving USSD: how will my program intercept the returned string.
Here is the code I am using for sending first USSD code:
unit UTestPhoneDialer;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Platform, FMX.PhoneDialer, FMX.StdCtrls, FMX.Controls.Presentation,
FMX.Edit, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo;type
TForm1 = class(TForm)
lblCarrierName: TLabel;
lblISOCountryCode: TLabel;
btnGetCarrierInfo: TButton;
lblTelephoneNumber: TLabel;
edtTelephoneNumber: TEdit;
btnMakeCall: TButton;
Memo1: TMemo;
procedure btnGetCarrierInfoClick(Sender: TObject);
procedure btnMakeCallClick(Sender: TObject);
private
{ Déclarations privées }
PhoneDialerService: IFMXPhoneDialerService;
public
{ Déclarations publiques }
constructor Create(AOwner: TComponent); override;
end;var
Form1: TForm1;implementation
{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}procedure TForm1.btnGetCarrierInfoClick(Sender: TObject);
begin
{ test whether the PhoneDialer services are supported on your device }
if Assigned(PhoneDialerService) then
begin
{ if yes, then update the labels with the retrieved information }
lblCarrierName.Text := 'Carrier Name: ' + PhoneDialerService.GetCarrier.GetCarrierName;
lblISOCountryCode.Text := 'ISO Country Code: ' + PhoneDialerService.GetCarrier.GetIsoCountryCode;
end;
end;procedure TForm1.btnMakeCallClick(Sender: TObject);
begin
{ test whether the PhoneDialer services are supported on your device }
if Assigned(PhoneDialerService) then
begin
{ if the Telephone Number is entered in the edit box then make the call, else
display an error message }
if edtTelephoneNumber.Text <> '' then
PhoneDialerService.Call(edtTelephoneNumber.Text)
else
begin
ShowMessage('Please type-in a telephone number.');
edtTelephoneNumber.SetFocus;
end;
end;
end;constructor TForm1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService));
end;end.
After first calling, Then I would have to respond to the different USSD information. How do I do?
Regard!
-
I have the following instruction in Java:
HashSet<CardSlotTypeEnum> slotTypes = new HashSet<>();
How do I write this in Delphi?
TJHashSet is in unit Androidapi.JNI.JavaTypes.
-
exmailx45: I can't use TDBEDIT for android, how do I do?
- 1
-
Good morning all,
Thank you for your help!
I agree with Roll62's idea: just improve TEdit. In the meantime, I will try the currency edit program and also the simple emailx45 casting.
Thanks a lot guys!
-
I need a component like TEdit to enter amounts like $ 23,000.00. I see that TMaskEdit does not exist for FMX. What componant can I use?
Regard.
-
Thank you Dave!
Your explanation is very clear. Now printing is OK now. Thank you so much.
Regard
-
I want to convert java code to delphi code.
My problem is the call to new OnPrintListener () in the parameter.
Regard
-
Thank you for your reply!
I have a java file (attached file) and I have java4delphi, can I convert this java file to .pas file with this tools? Please How to do that?
Regard.
Open HFSQL WINDEV Table error
in Databases
Posted
My objective is to access the tables of a database named GMAO of a WINDEV HFSQL (Hyperfile SQL) server. I try to use ODBC.
Here is my source:
procedure TForm1.Button1Click(Sender: TObject);
var
FDConnectionODBCHFSQL: TFDConnection;
TableODBC:TFDTable;
begin
TableODBC := TFDTable.Create(nil);
FDConnectionODBCHFSQL := TFDConnection.Create(nil);
try
FDConnectionODBCHFSQL.Params.Clear;
FDConnectionODBCHFSQL.DriverName := 'ODBC';
FDConnectionODBCHFSQL.Params.Add('ODBCDriver=HFSQL');
FDConnectionODBCHFSQL.Params.Add('Database=GMAO');
FDConnectionODBCHFSQL.Params.Add('User_Name=admin');
FDConnectionODBCHFSQL.Params.Add('ExtendedMetadata=True');
FDConnectionODBCHFSQL.Params.Add('ODBCAdvanced=Server Name=DESKHOLY-PC;Server Port=4900;IntegrityCheck=1');
FDConnectionODBCHFSQL.Open;
TableODBC.Connection := FDConnectionODBCHFSQL;
TableODBC.TableName := 'appartenance';
try
TableODBC.Open;
ShowMessage('Table is open!');
except
on E: Exception do
begin
ShowMessage('Open Table error : ' + E.Message);
exit;
end;
end;
except
on E: Exception do
begin
ShowMessage('Connection Error: ' + E.Message);
exit;
end;
end;
end;
The connection goes through, but when I try to open a table there is always an error:
Error opening Table: [FireDAC][Phys][ODBC][Microsoft][ODBC Driver Manager] The driver does not support this function.
Please, can anyone help me to resolve this issue?
Regards!