Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Using mgos_dash calls and PWA

I have an ESP32 application connected to AWS and to mDash. I have a few questions with using mDash:

  • If AWS is enabled, then do any updates to the shadow go only to AWS, or can mDash pick them up too? Experimentation seems to show that mDash doesn't see them, but I could be doing something wrong.
  • If I use mgos_dash_notify, will that go directly to mDash, or is that routed through AWS?
  • What do the parameters to mgos_dash_notifyf mean? I've tried changing them in various ways, but nothing seems to appear in any part of the mDash that I can see. Should the data go to the PWA application, and if so, how do the parameters in the mgos_dahs_notifyf call relate to PWA? I can't find any tutorial which tells me.

thanks,

dan.

Comments

  • SergeySergey Dublin, Ireland
    1. There should be only one thing that controls the shadow - either AWS or mDash. You can nail down what is the authority by mos config-set shadow.lib=aws or mos config-set shadow.lib=dash
    2. mgos_dash_notify() generates a notification (similar to MQTT publish) that goes directly to mDash, and handled there. You can intercept all notifications, see https://mongoose-os.com/docs/mdash/notifications.md
    3. Added more docs on the notifications,see https://mongoose-os.com/docs/mdash/notifications.md#how-to-send-a-notification-from-your-device
    Thanked by 1dwtowner
  • Useful. Thank you. Some follow-up questions:

    • Is the only way to modify the PWA through the web interface? It would be useful to be able to upload from mos otherwise, so that the code can be kept in version control somewhere alongside the source code which generates the notifications.
    • Once I start sending notifications to the dash (using your example from the documentation), the ESP32's network connection becomes unstable, dropping off the dash every few minutes. If I remove the call to dash_notify call it becomes stable again. Increasing the debug log doesn't show anything obvious that I can see.
    • I added the code below to PWA (in the app class, just below the appuser/ws setup).but the WS developer tools just show it is continually getting a 401 authorisation error.
      var wsNotify = util.wsconnect('/api/v2/notify', { auth: auth });
      wsNotify.onmessage = function (msg) {
      console.log('wsNotify->', msg);
      self.refresh();
      };
      Am I using that wrongly?

    thanks,

    dan.

  • SergeySergey Dublin, Ireland
    1. It makes sense to make a endpoint to upload the code. We'll do that.
    2. You're most probably getting OOM. Monitor your free RAM, basically. I highly doubt the problem is with the network.
    3. Hmm, not sure - but you always refer to the working example (the default PWA app)
Sign In or Register to comment.