How to Use Accessory Agent Service with D22 and Q3 Devices: Difference between revisions

From wizarPOS
No edit summary
Line 1: Line 1:
== Introduction ==
== Introduction ==
D22 can connect with Q3 via USB cable. The D22 works in master mode and the Q3 works in slave mode. By the helping of the AccessoryConnectionAgent apk, the application in two terminals can send Intent to any other application in another terminal.
The D22 device can establish a USB connection with the Q3, where D22 operates in master mode and Q3 in slave mode. The AccessoryConnectionAgent APK facilitates communication between applications across these two devices using Intents sent through the USB connection.
 
== User Manual ==
== User Manual ==
[http://ftp.wizarpos.com/advanceSDK/AccessoryConnectAgentusermanual.pdf Accessory Connection Agent service user manual]
* For detailed instructions on how to use the Accessory Connection Agent service, refer to the [http://ftp.wizarpos.com/advanceSDK/AccessoryConnectAgentusermanual.pdf Accessory Connection Agent service user manual]
 
== Demonstration and Development: ==
== Demo ==
# '''Demo for APK Development:'''
Demo for APK developing.
#* Explore the demo for insights into developing APKs for this setup, [http://ftp.wizarpos.com/advanceSDK/AccessoryAgentDemo.zip Access AccessoryAgentDemo]
[http://ftp.wizarpos.com/advanceSDK/AccessoryAgentDemo.zip Demo]
# '''Testing APK:'''
 
#* After installation and running this APK, it will send an intent via the USB connection to initiate the merchant self-test application on the other device, [http://ftp.wizarpos.com/advanceSDK/AccessoryConnectionAgentDemo.apk Download AccessoryConnectionAgentDemo APK]
[http://ftp.wizarpos.com/advanceSDK/AccessoryConnectionAgentDemo.apk APK for testing, after install and run it, it will send intent through by the USB connection to the other device, to start the merchant self test apk]
 
'''Sender snippet code:'''
'''Sender snippet code:'''
<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
Line 92: Line 89:
     }
     }
</syntaxhighlight>
</syntaxhighlight>
== AccessoryConnectionAgent Service APK ==
== AccessoryConnectionAgent Service APK ==
By default, the AccessoryConnectAgent is included in the D22 and Q3 FW. But it maybe not exists in the old FW, so the developer should install the agent by themselves.
'''Installation Requirements:'''
Here is the agent apk:
* The AccessoryConnectAgent is typically included in the firmware (FW) of D22 and Q3. For older firmware versions, developers may need to install the agent manually. [http://ftp.wizarpos.com/advanceSDK/AccessoryAgentHostService-master-release-v1.0.22-r20230825095655-q1_platform.apk Download Connection Agent APK]
 
== Initiating USB Connection Mode in Development: ==
[http://ftp.wizarpos.com/advanceSDK/AccessoryAgentHostService-master-release-v1.0.22-r20230825095655-q1_platform.apk Connection Agent APK]
* '''Enabling AccessoryConnectionAgent:'''
 
** By default, the AccessoryConnectionAgent is disabled. Developers can use the provided APK to enable it.
== Init USB Connection Mode in Development==
** For production firmware, the agent is initialized before factory release.
By default, the AccessoryConnectionAgent is disabled, the developer can use this apk to enable it.<br>
** [http://ftp.wizarpos.com/advanceSDK/InitConnectionMode.apk Download Initialize APK]
For the production FW, the agent will be initialized before releasing from factory.
* '''Mode Selection:'''
Please download and install to D22 and Q3.
** In Q3, the default mode is set to slave, while other devices default to master mode.
 
* '''Usbchannel Switch:'''
[http://ftp.wizarpos.com/advanceSDK/InitConnectionMode.apk Initialize Initialize APK]
** Enable or disable the Accessory Connection Agent service as needed for your development and testing purposes.
* Selection Mode
This guide provides essential information for developers and users to set up and use the Accessory Agent Service between D22 and Q3 devices, ensuring efficient and effective communication and testing.
in Q3, default is slave, other devcies default is master mode.
* Usbchannel Switch
enable or disable the Accessory Connection Agent service

Revision as of 01:10, 26 December 2023

Introduction

The D22 device can establish a USB connection with the Q3, where D22 operates in master mode and Q3 in slave mode. The AccessoryConnectionAgent APK facilitates communication between applications across these two devices using Intents sent through the USB connection.

User Manual

Demonstration and Development:

  1. Demo for APK Development:
  2. Testing APK:

Sender snippet code:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        bindServer();
    }

    private void initView() {
        bindServerStatus = findViewById(R.id.bindServerStatus);
        startActivity = findViewById(R.id.startActivity);
        String json ="{\n" +
                "    \"action\": \"android.intent.action.MAIN\",\n" +
                "    \"className\": \"com.wizarpos.accessoryreceiveintentdemo.MainActivity\",\n" +
                "    \"flags\": 268435456,\n" +
                "    \"packageName\": \"com.wizarpos.accessoryreceiveintentdemo\",\n" +
                "    \"putExtra\": {\n" +
                "        \"extraData\": \"10\"\n" +
                "    }\n" +
                "}";
        startActivity.setOnClickListener(v -> {
            if(remoteServe != null){
                try {
                    remoteServe.remoteIntent(json);
                } catch (RemoteException e) {
                    throw new RuntimeException(e);
                }
            }else {
                Toast.makeText(this, "The AIDL service is disconnected", Toast.LENGTH_SHORT).show();
            }

        });
    }

    private void bindServer() {
        Intent intent = new Intent();
        ComponentName componentName =new ComponentName(INTENT_PACKAGE, INTENT_ACTION);
        intent.setComponent(componentName);
        bindService(intent, mServiceConnection, BIND_AUTO_CREATE);
    }
    ServiceConnection mServiceConnection = new ServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            remoteServe = IRemoteAccessoryApi.Stub.asInterface(service);
            bindServerStatus.setText("The AIDL service is Connected");
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            remoteServe = null;
            bindServerStatus.setText("The AIDL service is disconnected");
        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbindService(mServiceConnection);
    }

Receiver(com.wizarpos.accessoryreceiveintentdemo) snippet code:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //Receive intent data
        String extraData = getIntent().getStringExtra("extraData");
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        //Receive intent data
        String extraData = intent.getStringExtra("extraData");
    }

AccessoryConnectionAgent Service APK

Installation Requirements:

  • The AccessoryConnectAgent is typically included in the firmware (FW) of D22 and Q3. For older firmware versions, developers may need to install the agent manually. Download Connection Agent APK

Initiating USB Connection Mode in Development:

  • Enabling AccessoryConnectionAgent:
    • By default, the AccessoryConnectionAgent is disabled. Developers can use the provided APK to enable it.
    • For production firmware, the agent is initialized before factory release.
    • Download Initialize APK
  • Mode Selection:
    • In Q3, the default mode is set to slave, while other devices default to master mode.
  • Usbchannel Switch:
    • Enable or disable the Accessory Connection Agent service as needed for your development and testing purposes.

This guide provides essential information for developers and users to set up and use the Accessory Agent Service between D22 and Q3 devices, ensuring efficient and effective communication and testing.