The connection changed procedure is missing few arguments.
Also the mqtt received procedure should use exactly the same argument names as its corresponding event
Taifun
I would appreciate the help, I already updated my project to this latest version, but my problem persists and it is the following, the process works very well for me in the foreground or in the background but when I lock my phone it no longer works, this happens on some phones and in others not, there is a way to prevent the service from stopping working with the mobile phone locked?
I updated the variables like you said but still can't connect to mqtt.
So my question remains. The blocks that are used for the interface can cause the code to malfunction? I need them when I start the app. After I close the app or send it to the background I need the mqtt still receiving in the background
It is unfortunately completely dependent on the model and the manufacturer.
This problem does not exist on Stock Android, rather custom skins of Android manufacturers use.
For improvement, you can disable any battery optimization (Android 10>)
There isnt really much you can do about it.
Google had promised to enforce Android standards, such that the behavior across all the devices are uniformed, but this promise has not been fulfilled.
It may also help if you post your relavent blocks of the project.
As said before, you cannot use UI components in background AT ALL. In background process there is NO UI, therefore you cannot perform such actions.
In the meantime, for testing, you can use Notifications extension to debug and report information:
If you are really interested in reporting the changes directly to the user via user interface, then you would need to use broadcasting communication methods added in the latest version of the extension.
May help:
Please take a look at the following.
The "clock2.Timer" event runs smoothly. I get the random numbers on the notifications but the "UrsPahoMqttClient1.MessageReceived" doesn't run in the background like it should. It's working fine when the app is open but not when it is closed.
Could this be a limitation of the UrsPahoMqttClient extension ?
Probably the connection needs to be done in the background, too, before registering the events? This is only a guess...
Taifun
Yes exactly, you need to completely move the connect functionality to the background. Only maintain one connection for the background and that would be enough.
I moved it like it's shown in the screenshot but it doesn't connect this way.
I always get disconnected state and the mqtt received event never fires.
What mqtt extension are you using?
So you mean I must do it programmatically again cause they only apply for the UI ?
Yes, you have to individually set the green property blocks in your background procedure.
I get an error "Cannot load client certificate file or key file" but the filename is correct and the file is uploaded in the UI
Try to frst create the MqttClient, then do the setup
Taifun
I tried same result.
I don't see any examples on the internet setting up the mqtt through blocks apart from the basic connection, topic subscription etc
Make sure there is no typo in that filename... does the extension require 2 slashes to read from the assets like //filename.xyz
?
Taifun