Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StarIO10IllegalHostDeviceStateException: Network unavailable - after connecting to a network #33

Open
Szczypiorek44 opened this issue Dec 20, 2024 · 2 comments

Comments

@Szczypiorek44
Copy link

Description

Hey,
So in my app I've implemented a callback to detect for network changes, and when the network is available I'm trying to connect to the printer.
It looks like this:

    private fun registerNetworkChangesCallback() {
        // just android way to detect network changes: 
        // https://developer.android.com/training/monitoring-device-state/connectivity-status-type
        val networkRequest = NetworkRequest.Builder()
            .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
            .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
            .build()
        connectivityManager.requestNetwork(networkRequest, this)
    }

    override fun onAvailable(network: Network) {
        ...
        printer.openAsync().await()
        ...
    }

The problem is that sometimes the openAsync() throws an exception:
StarIO10IllegalHostDeviceStateException: Network unavailable. errorCode: NetworkUnavailable

How can I fix it to have stable implementation which will always try to connect to a printer after a network change?
Could you please specify how your sdk is detecting whether the network is available so I can use the same method or at least adjust to it?

Your device where the bug occurs

Lenovo Tab M10 FHD Plus

Your printer

Star SP700 (SP742)

  • Interface:
    Ethernet or Wi-Fi

Your development environment

ProductName: macOS
ProductVersion: 14.4.1
BuildVersion: 23E224

To Reproduce

Steps to reproduce the behavior:

  1. Register to Android's network changes monitor
  2. When a network is available connect to the printer
  3. StarIO10IllegalHostDeviceStateException occurs

Expected behavior

After the network is available the StarIO10IllegalHostDeviceStateException should not occur

@KHosozawa
Copy link

@Szczypiorek44

Thanks for the information.
The phenomenon you reported is new to us as well.

I have created and tested a code similar to yours. However, we are not experiencing this issue.
If possible, could you please provide us with the following information for further investigation?

  1. Android version
  2. StarXpand SDK version
  3. Frequency of occurrence (e.g., 1 in 10 times)
  4. Does this problem occur on other android devices?
  5. Self-printing result
    • When the printer is turned on while holding down the FEED button, information on the printer itself is printed. Please take a picture of it and attach it to this Issue.

@Szczypiorek44
Copy link
Author

Szczypiorek44 commented Jan 2, 2025

Hey,
So I've tried to reproduce it today but unfortunately I couldn't - which is strange as on the day I've created this issue I had 50% reproducibility ( 5 in 10 times the issue occurred ).
On the day I've opened this issue I could also reproduce it on another device: Elo I-Series 4.0 Value (Android 12) connected to the network using ethernet cable.
StarXpand SDK version is 1.8.0.

I'll try to reproduce this issue again next week - I'll let you know the results.

Self-printing result:
image

@Tatsuki-Yamamoto2731 Tatsuki-Yamamoto2731 added Status: work in progress and removed Status: question Further information is requested labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants