Can a phone post an event to estimote cloud

Can a phone post an event to estimote cloud the same way an LTE beacon would do an enqueue and sync?

Twilio haves some apis for that.I wonder if there is something local that doesn’t need extra payment tho.

No, you cannot do it. Events are only for LTE Beacons, but you can use Cloud Code to re-send event to your own server where you can also store events from phone.

can you give example of sending a POST request from the Cloud Code I cant find anyrhing in the documentation.

I think this code snippet should be useful:

https://developer.estimote.com/lte-beacon/cloud-code-and-apis/#cloud-code

const request = require('request-promise');
module.exports = async function (event) {
    if (event.type === 'assets-update') {
        const assets = event.payload.assets;
        await request.post(
            'http://my.own.api/assets-update', {json: true, body: {assets}});
    }
}

It uses the request-promise library to do the POST request. request-promise is a wrapper on top of request library, but uses Promises instead of callbacks for results. So for more, you might want to consult the documentation of these two packages:

https://www.npmjs.com/package/request
https://www.npmjs.com/package/request-promise

1 Like

nodeerror
Thanks, I started trying different things to fix the errors on the left but, my javascript is poor.
It says it’s missing 2 semmicolomns and also is missing name in function declaration. It would be nice to update it

The beacon doesn’t have the data I want to send. The phone does. So if the phone can’t communicate with the beacon (at least this is what I’ve read), then the beacon can’t send an event for it.

The beacon doesn’t have the data I want to send. The phone does. So if the phone can’t communicate with the beacon (at least this is what I’ve read), then the beacon can’t send an event for it.

I think what Pober was suggesting is that you architect things somewhat like this:

LTE Beacon => event => Estimote Cloud => forward to your own backend
phone      => event                   => goes immediately to your backend

This way, all the events, from the LTE Beacon and from the phone, eventually end up in your own backend.

Those are just style warnings I believe, our Web IDE doesn’t understand async functions very well yet. But the code should work fine. (I mean, you gotta change my.own.api/assets-update for your own endpoint :wink:)

I get how it can be done. using user messages ie.

Phone (user_message) -> Cloud (to onRecieve) -> LTE beacon (enqueue event) -> Cloud (handle event)

This really seems like overkill to get an event into the estimote cloud. It also requires credentials to somehow get to the app. Which brings in the need for a backend to basically do nothing more than proxy calls to estimote cloud which can then go through a similar flow as above.

I was hoping for a more simple way to do this and to if possible not have a backend requirement

if possible not have a backend requirement

Oh, gotcha, I think I understand now. I think long-term, I’d definitely make sense to somehow unify LTE and mobile events, have Estimote Cloud be a single source of truth. Estimote’s mission has always been to build an “operating system for the physical world”, so it’d definitely fit our mission to allow devs to store and process LTE-triggered and mobile-triggered (and “other-triggered”?) “physical-world-events”.

Alas, for now, that’s not the case. So maybe, for now, you could look into some backend-as-a-service, like Firebase, as a solution to this problem?

I’ve got a backend we can use just was really last resort to have to add to it. A proxy service on AWS should work for what we’re doing.

You can’t do so as cloud code will resend event to your own server whereas you can store events from phone.