B4J Question Simplest way to view output data from B4j app on a mobile

kostefar

Active Member
Licensed User
Longtime User
Dear All,

I´m developing an automated trading app for myself. This runs pretty smoothly but I still want to use my mobile phone to keep an eye on what´s going on in the app running on my computer at home in about a month, where I will be on a longer vacation. I have already found a decent remote desktop app which can be used both from the raspberry pi (with a portable monitor, so not something I´m going to bring "in the field" but just use in hotels etc.), that I´ll bring with me and from my android phone. However, trying to navigate on a win 10 screen from a 5" phone is really not convenient, so I was wondering what the easiest way would be to get a quick look at the current status of my app - basically just a couple of numbers that are updated upon changes, such as trades executed, balance etc., no fancy graphics or anything like that. I was thinking about if there´s a free webspace provider to whom I can send data that will be updated on the fly, just for me to have a look at them from time to time through a simple webpage. I could of course also design an app in B4A but this would take a lot more time, I believe.
So my question is: Does anybody have any inputs on what the easiest and fastest way to achieve this would be?

Thanks!
 

aminoacid

Active Member
Licensed User
Longtime User

I would definitely look into using MQTT. It seems very appropriate for your needs. Using a MQTT client in your B4J and B4A applications you can easily communicate information back and forth. This is the mainstream of several Apps that I have created. There are a LOT of examples on this forums on how to use MQTT and it really is very simple. Plus there are several reliable free MQTT servers (brokers) out there which you can use with your client - also documented on this forum. Good Luck.
 
Upvote 0

kostefar

Active Member
Licensed User
Longtime User
Thanks! The only thing is that it seems that I would need to build a b4a app to use this, which is something I would rather avoid, having to set up a test environment for b4a which I have not used for years.
EDIT: It may seem that I´m wrong. This was something I read in another thread here on the forum, but after googling it, it seems that I can also use a web page as a client.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User

Yes, you could probably get by without having to write a custom B4A App. There are several web-based and desktop MQTT clients that could serve the purpose.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
Yes, you could probably get by without having to write a custom B4A App. There are several web-based and desktop MQTT clients that could serve the purpose.

Here's one:



There's also an Android client called - MyMQTT

 
Upvote 0

amorosik

Expert
Licensed User

Making a smartphone 'talk' to a PC is immediate, a simple socket server program can remain in listening mode on the PC (with adequate settings of the router/PC firewall) and the smartphone sends requests and gets responses, same thing via Ftp, everything extremely simple to code

More complex is to do the opposite and therefore if from a PC you want to send information to the smartphone, this is because the address on the smartphone network is normally not visible and therefore it is always the smartphone that must connect to some system, and then the options are to send an Sms, use Firebase, use Fcm push notifications, use an Mqtt broker

Sending Sms is the simplest of all but it is not real-time it can also arrive a few minutes after sending, and therefore if you want almost instantaneous communication remains Firebase, Fcm, Mqtt

Personally I really like the communication system via Mqtt because it is simple to use, you can install everything 'in house' without the need for external services, and it is very widespread and therefore you can find documentation and experience of other users both in B4X development environments and with all the other programming systems

I use Mosquitto both to send simple commands and to send files of tens of megabytes
It has the ability to control access to the broker via user/password, and it also has some utilities to send commands and read information directly from the command line, very useful especially during the initial experiments
I would recommend you to follow both the initial tutorial of Erel and some significant examples such as the chat room and the the surprising chat with the possibility of drawing, also worth seeing is the connect-reconnect procedure, very important for automatically restoring the connection between client and broker, and also at super-interesting Network Guide To Galaxy

I still haven't understood why it's called 'MQTT broker' and not 'MQTT server' as would be logical to expect, ultimately it is a software procedure that waits and performs operations only when the clients do something, and this seems to me to be the precise definition of 'server'

Finally I would recommend you to take a look at Supabase and PocketBase they seem to be systems like Firebase but open source and can also be installed 'in house'

Last advice, if you want 'wake up' a phone that is with the screen locked and is in sleep mode, the only way is to use Fcm, all other systems are NOT detected until the phone returns to the active state
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…