ksksue / PhysicaloidLibrary

Android Library for communicating with physical-computing boards (e.g.Arduino, mbed)
http://www.physicaloid.com/
357 stars 151 forks source link

Problem with . open() running only once. #42

Open ghoumatn opened 1 year ago

ghoumatn commented 1 year ago

Hi, I encounter this annoying result: the open method executed just once. The resulting part of the code "Do actions" would only be performed once because mPhysicaloid no longer wants to open.

mPhysicaloid = new Physicaloid(mContext);
if (!mPhysicaloid.isOpened()) { /* if not opened */
    if(mPhysicaloid.open()){
       /* open connection */
    }
}
if (mPhysicaloid.isOpened()) {
    /* Do actions */
}
xxxajk commented 1 year ago

Close the connection when done, and before you open, check if it's open first, and if it is, close it and reopen it.

xxxajk commented 1 year ago

Also my github has a lot of these issues fixed, plus enhancements. it's here: https://github.com/xxxajk/PhysicaloidLibrary