Device Selector Sync/Update Issue

Android: 2.26.4
iPhone: 2.21.0 (2)
Local Server: 0.38.5-java8.jar

Setup:
Using Device Selector with 2 devices
Android running project in SHARED MODE
iPhone logged into project account

Problem 1:

  • Upgrading server .jar invalidates field values on H Step controls. iPhone values go to 0 and Android values have some correct but others not.
  • virtualSync is called on hardware (verified via blynk_debug) but server does not respond and does not call BLYNK_WRITE(vchan).
  • Blynk server log (trace mode) does not show any errors.

Fix:

  • reset every H Step Control value. Each one reset allows hardware to sync value.

Problem 2:
Setup: Android device selector is set to DEVICE 1 and iPhone is changed to DEVICE 2.

  • Android DOES NOT change to DEVICE 2. This is clear as shown in device selector.
  • changing H Step values on iPhone changes values on both iphone (dev 2) & android (still on dev 1).

If the same process above is done starting with Android, both it and iphone change to proper device and field are updated are handled properly.

Problem 3:
Setup: Android logged into project account (iPhone app. closed & swiped from memory).

Make changes to H Step values then make sure to wait:
#period in millis for saving all user DB to disk.
profile.save.worker.period=60000

Perform a sudo reboot on pi 3. After waiting for reconnect of phone app. & hardware, the H Step fields are corrupted. Typically values go to zero.

Summary:
Big concerns,

  1. The control values establish limits for alarms. If you update server, everything goes into alarm. Then each device requires reset of all limit values.
  2. Any reboot of server corrupts set points.
  3. Selecting different device on “iphone” is causing wrong device field update on android.

Hello. Thanks for detailed report.

Could you please clarify. You mean some widgets show correct value other - not? All under device selector? Is problem only with stepper? What pin is used by stepper?

I’ll check that right away. By the way what OS is server running on?

Made a test - all seems fine. Please provide more info. Are those step widget on DeviceSelector? What OS (where sever is) do you have? What pins are used. And what “iPhone values go to 0 and Android values have some correct but others not.” means.

ALL were Stepper Controls & ALL were Using Device Selector->V25 thru V30,V25 uses param.asInt() and V30 uses param.asFloat() and were getting corrupted. (in my previous post for problem 1, I forgot to put in the sudo reboot after downloading new .jar & updating crontab for auto-load, my bad…:expressionless:)

I later created another project using V10 thru V13 (stepper controls) and V2 thru V5 Labeled Values. 2 Steppers were setup as floats and 2 as integers. I had a push button (V0) that would transfer the values from stepper controls to labeled value fields. ALL the above were using a Device Selector (2 devices). Device 1 was online and Device 2 was not. Here was the test:

  1. set device 1, put 3 in all stepper controls and pushed values to labels values. Set stepper values back to 1.
  2. set device 2, put 5 in all stepper controls. Note: cannot transfer to labeled value fields since device is offline and requires hardware to perform Blynk.virtualWrite(vchan).
  3. went back and forth with Device Selector to make sure all values remained and they did.
  4. Shutdown phone app. and swiped blynk from memory (using iphone). Re-opened blynk phone app. and made sure ALL values were correct and they were.
  5. rebooted hardware and re-checked values and they were correct.
  6. Shutdown phone app. and swiped blynk from memory (using iphone). Performed a sudo reboot on pi 3. ALL values went BLANK and ALL Stepper Controls on both devices went to 0.
  7. Performed the same test on Android BUT did a forced stop. After re-opening, same results. Appears not to be iphone/android specific.
    Note: the above tests were done with only 1 phone logged into account…

I’m thinking there are only 2 problems:

  1. sudo reboot is corrupting database. (Is there a specific way you want us to reboot pi ?)
  2. iphone app. is not syncing its device selector change with server, SEE previous post problem 2.

Local Server inside my house on local network.

uname -a
Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l GNU/Linux

cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian

This one is confirmed and fixed already. Will be available in next Adnroid update.

Please show exactly command you use to reboot.

Thanks for checking into these.

The exact command from Putty login is:
sudo reboot

@minnkid do you see the same problem when you shutdown server manually?

Not sure what you mean by that. The pi 3 does not have a button to do this. If you mean running shutdown, see below.

I tried a few other tests:

  1. disconnect both phone apps. then did sudo reboot. No difference, all steps control vals=0, labeled values=blank.
  2. same as above but had ALL hardware offline. Same results as item 1.
  3. performed sudo shutdown -r 1 , checking to see if 1 minute shutdown/reboot would work. Same results as item 1.
  4. ran reboot from VNC login to GUI. Same results as item 1.
  5. ran sudo shutdown -h now, cycled pi power and let it boot. Same results as item 1.

Dimitry: do you log anything at the TRACE level showing you received a SIGTERM. My understanding is both reboot and shutdown is suppose send SIGTERM to all running processes, notifying them to save their data and exit.

I mean - run server with “java -jar …” and then “ctrl + c”.

Yes. With above scenario you should see “Catch shutdown hook.” message on your screen. So if you see it and you still missing the values it mean problems is in your project setup. We need to go deeper in that case :slight_smile:.

Its definitely an issue with the Device Selector. Ran 2 more scenarios:

  1. added a slider control and its value went to 0 after reboot. Appears to not be control specific.
  2. added another Step Control and labeled value BUT did not use device selector. After reboot, both the step control and value field held their last values. (this was using int).
  3. repeat step 2 on previously failing step/value pair and they now work. (this was using float).

If it was something to do with Stretch, this would not work. Looks like there is something happening with the Device Selector…

Could you please clarify - this happens on iPhone? Or on Android too?

Not sure which screen your referring to. I do not see that phrase in the blynk.log file, on my Putty screen and the phone apps. just bark about server connection.

Ok, I manually fired server up from window and performed a ctr+c and got the following:

Blynk Server 0.38.6-SNAPSHOT successfully started.
All server output is stored in folder '/home/pi/Blynk/logs' file.
^CCatch shutdown hook.
Stopping servers...
Shutting down Hardware SSL server...
Shutting down HTTP API and WebSockets server...
Shutting down HTTPS API, WebSockets and Admin server...
Shutting down Mqtt hardware server...
Stopping scheduler...
Closing all sockets...
Stopping Transport Holder...
Stopping aggregator...
Stopping BlockingIOProcessor...
Stopping DBManager...
Saving user profiles...
Done.

Still get same results…:weary:

Both iphone and android work WITHOUT Device Selector and the fields are correct.

Have you had any luck reproducing this issue on your end?

I’ve even tried “ps SIGTERM Id” from another login and see the shutdown but the values are still incorrect after reboot. Based on that, I don’t think it’s related to shutdown timing since fields/controls not using the device selector work fine.

There is something going on with the Device Selector.

Please let me know your thoughts on how to proceed.

Thanks

Have you had any luck reproducing this issue on your end?

Nope. Are you sure restart of the server is necessary in order to reproduce the issue? Is all is ok without restart?

It only happens after restart of server. The controls & value fields work fine tied to the Device Selector prior to a restart. I can close the apps. (swipe from memory iphone, force stop on android) and re-open them and all values are correct. Note: Controls & value fields NOT using the Device Selector retain their values prior and post restart.

I also tried with server-0.38.6-java8.jar but same results.

Not sure how many of your users are running both a local server AND using device selector. This may be why its not showing up with others. Could there be an issue with my Blynk.user database file?

Yes. would be nice if you can provide me with BLynk.user file you are using for test. My email is dmitriy@blynk.cc

I sent the Blynk.user and .ino to email.

Look forward to seeing what you find.

Thanks

@minnkid thanks for your help! Reproduced and fixed. Fix will be available in the next 0.39.0 server release.
Fix for Problem 2 is already released by the way - New Android Release 2.26.5