-
I love the idea of being able to program devices with TypeScript, and this project looks very promising. I found very little documentation about how to do anything network related, the TCP docs are empty, and the Wifi docs don't go into any details about how to use the network once it's established. I've seen the Cloud docs, that "provides a cloud agnostic device to cloud API", but there is no information what this is. Is it MQTT, HTTP? It seems to be MQTT based on the Development gateway, but it's unclear to me how to use it, since there is no example code and no API docs. When I program devices today I almost always make some kind of network connection, often MQTT, sometimes HTTP, sometimes raw TCP or UDP. TLS is a must to be able to connect to cloud services. There seems to be a TCP stack in DeviceScript, and I've seen TLS mentioned, but there doesn't seem to be an HTTP client. I don't mind working with raw TCP + TLS if it's available, but I don't find any example code or API documentation. Does anyone have examples, or some hint for me where to start if I want to make a TCP + TLS connection? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
This part of the story is still something we haven't really made a final decision on. (ignore the tcp service for now) We have a "prototype" network solution to demonstrate how DeviceScript could be used with a gateway to provide a device management / data streaming story. Extensible support with existing industrial device management, provisioning system, is still TBD. We don't support direct HTTP requests mostly because those could easily eat all the available memory, so going through a gateway is a more reasonable solution. For development/demonstration purposes, on ESP32, we use the wssk (C implementation) over a wifi and web sockets (and TLS). This solution is paired with the development gateway to create a micro-iot-cloud experience. If you fork the device gateway, you will be able to add any kind of node.js code to handle custom messages published using |
Beta Was this translation helpful? Give feedback.
-
Definitely open to discuss this topic and see where this lands. |
Beta Was this translation helpful? Give feedback.
-
This is just a drive-by comment, but some limited support for triggering a webhook might be useful? Example: using IFTTT or Pushover to send a notification from a device to a phone. I helped someone do this for a hobbyist project using Arduino on a Pico-W. We found IFTTT notifications to be unreliable, so we switched to Pushover. I suppose in theory, we could run out of memory since the API we use allocates Arduino's String objects, but it didn't happen for us. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the answers. I would very much like to see support for low level networking primitives to make it possible to talk to existing services and APIs from devices. Having to deploy a gateway is more limiting to me, but I see that it can simplify things like being able to connect a button to the cloud with very little code. Here are a few examples of what I've done with microcontrollers and that don't seem like they would be possible with DeviceScript today:
I have more projects and devices running, but I think these three were good examples. The first would require me either running a local gateway or one in the cloud, just to make an HTTP request. I don't think I'm using an HTTP library for that today, it's such a basic API that all I have to do is open a connection and send a very basic HTTP request. Just the IaC for deploying a gateway in the cloud would be more code. The second would require a local gateway, because one of the nice things about IKEA's home automation is that it is not a cloud service, it's all on your home network. I would have to have some kind of home server, or a Raspberry Pi, and in that case, why not just use a Raspberry Pi Zero W which has GPIOs and can run Node.js? The third example would require me to run a gateway in the cloud, to talk to another gateway, AWS IoT. Like many other cloud platforms AWS IoT is just MQTT, and having to deploy a DeviceScript-specific gateway to talk to a device-agnostic IoT platform is backwards. If there was TCP and TLS support, the community could write a MQTT library, or libraries for all the different platforms out there. Having a built in MQTT library would be even better. I'm excited about DeviceScript because I like TypeScript, and because it feels like a modern take on programming embedded devices. To me. To me the way JavaScript/TypeScript does async has always felt like a natural fit for embedded systems. I've used ESP-IDF, but don't have the energy for working that low level on hobby stuff, and Arduino, but been put off by the long compile-flash-test cycle, and by the unfriendliness of C++. I'm currently using MicroPython because it makes it possible to try things out quickly, but I'm annoyed by its scrappiness, and all the rough edges, and by the backwardness of Python in general. I hope DeviceScript is going to be what I will be using in the future. I'm mostly programming with libraries and device drivers that others have written, but sometimes I need to be able to use lower level primitives, like doing networking. It looks to me like DeviceScript today only exposes high level components, and does not expose the low level primitives. |
Beta Was this translation helpful? Give feedback.
-
@iconara In the meantime you may want to check Moddable's take on networking, especially MQTT implementation. |
Beta Was this translation helpful? Give feedback.
-
We recently added sockets and "fetch" on top of it. |
Beta Was this translation helpful? Give feedback.
We recently added sockets and "fetch" on top of it.