Epson printer connect fails status ERR_CONN

旧巷老猫 提交于 2019-12-05 05:44:41

Looks like you don't have the proper permissions in your manifest. Try putting these in your project under the manifest tag:

<uses-permission android:name="android.permission.BLUETOOTH"/>

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

They also have the

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

permission but I'm not sure you need it. I think the essentials are Bluetooth and Internet permissions.

As I suspect there seems to be an error in connect printer method. I have used this SDK once so better follow the documentation properly (means don't skip steps). Make sure you have defined permission as mentioned in the SDK.

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>


<activity android:name=".MainActivity" android:label="@string/app_title"  android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter"/>

As I see you haven't mentioned what type of connection you are making thus, in that case, there must be problem in selecting target

Check out the function from SDK:

Public void connect(String target, int timeout) throws Epos2Exception;

You might be using wrong target parameter.

Note: if you are using USB or any other mode make sure run discoverability service as per the docs.

 Discovery.start(this, mFilterOption, mDiscoveryListener);

It will return you the required target name. And I am sure no connection failure will occur. Good Luck \o

Crime_Master_GoGo

Status ERR_CONN is basically shows if device cannot be reached or connection failing with device. It can be USB, LAN/NETWORK, Bluetooth Connection failure status.

If you are trying to connect printer with Bluetooth then you must write below permissions:

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

If you are using LAN for network printers then

<uses-permission android:name="android.permission.INTERNET"/>

For USB Printer Connection Use:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

As you are using EPOS2 Sample Project, remember to import Jar file "EPOS2.jar". Click here to download the file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!