Falcosc / locus-addon-tasker

Locus Maps API useable as Tasker Plugin
GNU General Public License v3.0
9 stars 2 forks source link

Broadcasting intents based on the Locus Map app events #14

Open rplevka opened 3 years ago

rplevka commented 3 years ago

Hello. I'd like to pull sensor data from the app every time a new track point is created (during track recording). Is your app also capable of sending intents if various events happen in Locus Maps? This way, I could create a tasker profile with such intent as a trigger and I wouldn't need to blindly trying to pull the data in the pre-defined intervals.

My goal is to make your app+tasker as a bridge between Locus Maps Track recording and MQTT. I'm mainly interested in data from my ANT+ sensors and Tasker doesn't provide a way of reading data from ANT+ directly.

Thanks and CG to a great addon

Falcosc commented 3 years ago

No, there isn't any event based api. Just request sensor data in an infinite loop. Only functions like "Tell Locus Map to open the select destination dialog" fire events. (is not implemented because nobody did request to use locus as coordinate selection tool so far)

There is no event-based interface for data or actions triggered by locus. So if I implement the tasker event API, I would need to implement the infinite loop, too.

But there is a problem, if I implement it, it would look like "cool there is an event-based API, lets use it to save battery (CPU cycles)"

You could still say: "if we educate the user about the technical limitation, the tasker events would still useful to reduce the Task complexity because the infinite loop is hidden in the plugin instead of inside the tasker task" But there are more problems: The loop solution is not in real time like you would expect it from an event. You always have to wait until the next loop iteration is executed. And if you don't have the waiting for new data loop inside your task you may forget that this is not an event and wonder why things are delivered after a delay.

Do you still want to have it?

Falcosc commented 3 years ago

If you would have usecases where the event is only triggered once every some minutes, then I would ask for an event based interface to avoid useless cycles.

But for ANT+ Sensors you should pull data every second anyway, you should get new sensor data even if no track point is recorded, so your integration would be wrong if you only deliver data if the recording profile decides to create a new point.

Only one thing is difficult to do in tasker: matching the tick rate In tasker you can either do a sleep action or a timer based profile. The Action doesn fit the tickrate because the sleep has a hard-coded duration like 950ms. You use 950ms because you know your code needs 50ms to run. If your code runs faster or slower, you will be out of sync with the tickrate. If this adds up to a whole second you will either miss a data delivery or you process the same data delivery twice.

The tasker profiles have a timer, but it has 2min as minimum repeat rate.

If you need to be in sync with the Locus tick rate, I could have a conversation with the Locus team to discuss your use-case. Why don't you use other addons to connect directly to your ANT+ device? Does these things still have the limitation that only one client can be connected to them? So either Locus or the Tasker Ant Plugin can get date, but not both?

TapioOfTapiola commented 3 years ago

Guys in case you have missed - there is a "tick" event in the profile triggers. In milliseconds. We're not bound to 2 minutes in profiles any more.

Falcosc commented 3 years ago

Ok, now it is even more easy to do it because you don't need this stupid 2 minute loop anymore. @tortuosit thank you so much. By the way, I did put the next Release into Beta Test https://play.google.com/apps/testing/falcosc.locus.addon.tasker

rplevka commented 3 years ago

Thank you guys and sorry for late response - The profile using "tick" event seems to be plausible.

I originally wanted to hook on new trackpoints as that would automatically fire the events only when it's relevant - track recording is on (so i'm probably using the sensors as I'm apparently on my ride) and also the track recording profile can be used to tweak the intervals between new track points => sensor readings.

TapioOfTapiola commented 3 years ago

OFFTOPIC, BUT AWESOME. "CALL TASKER TASK WITH PARAMETERS" https://forum.locusmap.eu/index.php?topic=7525.0

Direct task call with params, without having to use Tasker Secondary!