Connecting 4D with the real world – IoT & Home automation

Originally published at: https://events.4d.com/summit2020/session/connecting-4d-with-the-real-world/

Connecting 4D with the real world – IoT & Home automation

1 Like

Thank you, Thank you, Al Mahdi,
FAntastic!

1 Like

Excellent presentation!

I appreciate how you started with a split-screen live demo (you, 4D for iOS, Arduino in the room with servo, LED and sensors). You grabbed my attention immediately. I was constantly tempted to buy electronic parts online while watching your show…

You make good use of Schema made with Diagrams.net and the slides are clean, simple and easy to understand.

Even though this is technically not a “4D for iOS” presentation, I think you make a good case for how the feature could be used to create simple, practical application for very specific needs.

c.f.

It was a pleasant surprise that in the presentation you also talked about abstraction of mutually exclusive operations using a Shared Worker. Not only that, you also touch on project mode and headless mode. For a 36 minutes presentation, you surely cover a lot of interesting topics!

But above all, I like that you embrace built-in features such as 4D for iOS “actions” and write minimal code, focusing on the practical applications of IoT.

Great job!


Endianness

In your presentation, you suggest to use “Native byte ordering” for sending data from 4D.

I had to remind my self, what is the endianness of “Native byte ordering” passed to LONGINT TO BLOB.

Note to forum admin: I think the syntax highlight is incorrect for hex literal. Try 0xabcd

C_LONGINT($int)

$int:=0x1234
LONGINT TO BLOB($int;$data;Native byte ordering) //34:12:00:00

$int:=0x12345678
LONGINT TO BLOB($int;$data;Native byte ordering) //78:56:34:12

LONGINT TO BLOB($int;$data;PC byte ordering)  //i386 = LE 78:56:34:12

LONGINT TO BLOB($int;$data;Macintosh byte ordering)  //ppc = BE (note: 4D for mac was ppc until v11) 12:34:56:78

So “native” is synonymous to “little endian” today.

I understand you are using LE because we want to think in bytes, but because the data is stored in a 32-bit integer, you want to promote the least significant byte to first place and ignore the rest. That makes sense, but here is another way; use a BLOB and access each byte directly.

SET BLOB SIZE($data;1)
$data{0}:=0x01

Licensing

In your presentation, you mention 4D Web Server, which is true for web-enabled 4D applications in general.

But for completeness, I would like to point out that “4D for iOS” uses a client connection license in deployment, so a 4D Web Server (application) license is not necessary for 4D Server.

It’s a commercial arrangement, I understand that from a technical point of view, it make more sense to mention “4D Web Server” like you did.

1 Like

Thanks, Miyako for your constructive feedback. This is a use-case that can indeed be further polished on the same line of your comments.
Looking forward to continuing the work.