Android Question [SOLVED]HELP! Convert App to B4X ???

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
Hello everyone!
I am a little worried about not finding a solution for this development that communicates via Bluetooth to an Ingenico Dataphone with PCL communication format. The only thing I have managed to do is connect to the Dataphone via Bluetooth and I have tried to send commands to it and I do not get a response. With all my heart and gratitude, I would like you to help me implement this project that I enclose with all the documentation and Libraries. I am also attaching the project so far and an example of an application that I want to pass to B4A called PclTestApp_1.22.apk.
And I ask you with humility and from the heart to help me and give me a Light.???
Thanks sirs

This is the link:
And below I attach where I started with B4A in which I managed to connect to the Dataphone for the moment.
 

Attachments

  • PCL_Bluetooth_B4A.zip
    11.7 KB · Views: 210

DonManfred

Expert
Licensed User
Longtime User
PclTestApp_1.22.apk
Do you have the sourcecode of this App?
It´ll be easier if you know what the app is doing exactly (which code is used).... To see what needs to be wrapped it is of good help to know the Apps Sourcecode, Manifest, ect.
 
Last edited:
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
¿Tienes el código fuente de esta aplicación?
If here is the code done. She had forgotten.
Thanks @DonManfred from the bottom of my heart, I know how long this development takes, but trust me, I've been trying to develop this app for B4X for more than a week. I am competing with some companies that also want to win that project.
 
Last edited:
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
Thank you @DonManfred from the bottom of my heart.

Thank you from the bottom of my heart, I know I will win because I have a great team that is all the main members of this Forum that support and you will get your donation from me friend.
And also thank the work that @Erel does with these incredible programming platforms.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
I've been trying to develop this app for B4X for more than a week. I am competing with some companies that also want to win that project.

It would have been best if you put some price on it, in the business forum for someone to help develop it for you.
 
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
After looking at the project it seems to be a complex Library to wrap.

To much work to do "just for fun". I´ll not do anything here, sorry. To much work.

I suggest to hire someone who do the Job for you.

Thanks @DonManfred
Where could I start? ? ? ?
I have a desktop application that they gave me showing the entire process, where I highlight the frame that is sent to a Dataphone for card payment.
I have the C# code for this application.

 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Where could I start?
I´ll see if i can give a starting point (not a working solution).
I saw many methods in there. Do you need Signing? (like a signpad)
Or what methods do you need? Do you have an idea of an overview of them?
 
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
If you see in the image that I sent you previously the hexadecimal text, according to the example that I attached with the source code, I copy that text in Extended Data to the App as shown in the video, deleting the amount and enabling the CheckBox (Hex ) by pressing the Run button.
I would like to know how that frame is sent via bluetooth according to the attached libraries or do it the same way in B4X
I´ll see if i can give a starting point (not a working solution).
I saw many methods in there. Do you need Signing? (like a signpad)
Or what methods do you need? Do you have an idea of an overview of them?
Thanks @DonManfred
Where could I start? ? ? ?
I have a desktop application that they gave me showing the entire process, where I highlight the frame that is sent to a Dataphone for card payment.
I have the C# code for this application.
 
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
Here I attach the Java code of the Activity where I copy the frame in the EditTexT Extended Data of the video example.
It is not necessary to use Printer since the device does not have a printer, so everything that has to do with the printer is not necessary, I just need to send that frame to the device via Bluetooth.
Thanks
 

Attachments

  • TestActivity.java
    116 KB · Views: 178
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
I have a desktop application that they gave me showing the entire process, where I highlight the frame that is sent to a Dataphone for card payment.
I have the C# code for this application.

I don't know if what you are looking for is the way to get the frame that appears in the picture, taking the left boxes as an input, or something else.

If what you want to obtain is the frame as in the example, the rules 'seem' simple. You'll have to play a bit with it, but according to the picture it seems to work this way:

From boxes to the xml:
  • A transaction content is surrounded with the <xFC> tag.
  • Each box at the left will have an xml tag and its contents will be inside. For instance, seems that 'Numero de caja' will have the <xDFFF25> tag.
  • The contents of each textbox are codified or translated differently to the the corresponding xml tag
  • In this way, the content of the 'Numero de caja' textbox is an ascii string defining an hex value. The rules to codify it is an hex char for each asci char.
  • The other textboxes, which contain numeric values, seem to be BCD-codified.
  • Since you have the PC program, you'll have to play with different values in the textboxes and see which part of the xml changes i order to complete the map (which tag corresponds to each textbox)

From the xml to the transaction data (data to send) --> If you observe the generated xml and the generated data to send, the rules seem to be:
  • All starting tags (not the closing ones) are directly transferred to the data to send.
  • After each tag, there is a byte which tells us the total number of bytes that come after that: 0x30 (=48) is the total number of bytes that come after it.
  • Then comes the next tag (DF FF 25) and then again the number of bytes that correspond to that tag (0A, which is 10d). Then we have the 10 bytes which are the asci codes each char in the first textbox ( '0'-->30h, 'C'-->43h, ...)
  • Once the 10 chars have been translated, we have the next tag (9A), which seems the data textbox. Again the next byte after the tag (03) is the number of bytes that follow corresponding to that byte, and its codification (in this case, seems that they codify the YYyy/mm/dd into bcd yy mm dd so the resulting bytes are 22 04 02.
  • This follows until the last tag...


This is the general idea. The way to go, when in doubt, is to individually change some textboxes in order to know which xml tag is affected and find out the codification rules.
As you see, translating the xml to the frame seems quite easy. In fact you don't have to build an xml, since it is just an intermediate representation. Jist assigning a tag to each textbox and knowing its order and codification rules, you'll be able to generate the frame.
 
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
It is a sample application of how I should send the data by bluetooth to an Ingenico Dataphone. As you can see in the video of the sample app that they gave me to guide me, but I can't send the frame without the Dataphone recognizing it
I don't have any problem in the encoding of the XML, if not in the sending since the dataphone is not recognizing the Hex frame that you see in the image.
The part of the code that the App does that is this.
Java:
protected void runDoTransactionEx() {
        int appNumber;
        TransactionIn transIn = new TransactionIn();
        TransactionOut transOut = new TransactionOut();
        transIn.setAmount(metStatic4.getText().toString());
        transIn.setCurrencyCode(metStatic3.getText().toString());
        transIn.setOperation(msSpinner1.getSelectedItem().toString().substring(0,1));
        transIn.setTermNum(metStatic2.getText().toString());
        transIn.setAuthorizationType(msSpinner2.getSelectedItem().toString());
        transIn.setCtrlCheque(msSpinner3.getSelectedItem().toString());
        transIn.setUserData1(metStatic5.getText().toString());
        if (metStatic7.getText().length() == 0)
            appNumber = 0;
        else
            appNumber = Integer.parseInt(metStatic7.getText().toString());
        byte[] extDataIn = null;
        try {
            byte[] tmp = metStatic6.getText().toString().getBytes("ISO-8859-1");
            if (mcbHexa.isChecked())
            {
                extDataIn = new byte[tmp.length/2];
                int j=0;
                for (int i=0; i<tmp.length; i++)
                {
                    if (tmp[i] >= 'a' && tmp[i] <= 'f')
                        tmp[i] = (byte) (tmp[i] - 'a' + 10);
                    else if (tmp[i] >= 'A' && tmp[i] <= 'F')
                        tmp[i] = (byte) (tmp[i] - 'A' + 10);
                    else if (tmp[i] >= '0' && tmp[i] <= '9')
                        tmp[i] = (byte) (tmp[i] - '0');
                }
                for (int i=0; i<tmp.length; i+=2)
                {
                    String str = String.format("%02x", tmp[i]*16 + tmp[i+1]);
                    extDataIn[j++] = (byte) Integer.parseInt(str, 16);
                }
            }
            else
            {
                extDataIn = tmp;
            }
            
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            mtvStatus.setText("TEST ERROR: UnsupportedEncodingException");
            return;
        }
        byte[] extDataOut = new byte[5000];
        Log.d(TAG, "Amount:" + transIn.getAmount() + " Currency:" + transIn.getCurrencyCode() + " Operation:" + transIn.getOperation());
        Log.d(TAG, "TermNum:" + transIn.getTermNum() + " AuthoType:" + transIn.getAuthorizationType() + " CtrlCheque:" + transIn.getCtrlCheque());
        Log.d(TAG, "UserData:" + transIn.getUserData1());
        mtvStatus.setText("TEST STARTED ...\n");
        mtvResult.setText("");
        mPclService.registerCallback(mCallback);
        mCallbackRegistered = true;
        new DoTransactionExTask(transIn, transOut, appNumber, extDataIn, extDataOut).execute();
    }
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Hopefully i get some time this evening to build an example. 1st Version of Library written.

NOTE: As i do not own such a device i can not test the library at all.

You need to test it and create a new thread for any issue you have. It´ll take some time working like this too.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…