Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blockly Networking #55

Closed
martin9115 opened this issue Oct 7, 2020 · 18 comments
Closed

Blockly Networking #55

martin9115 opened this issue Oct 7, 2020 · 18 comments

Comments

@martin9115
Copy link

Hi, can we establish some (sensor) network topology with blockly?

@cymplecy
Copy link
Collaborator

cymplecy commented Oct 7, 2020

Can you explain a bit more?

Might be better to open a discussion on the Node-RED forum?

https://discourse.nodered.org

@bartbutenaers
Copy link
Owner

Hi Martin,
Can you please describe a bit more in detail what you want to do?
Bart

@martin9115
Copy link
Author

In the best cases, I want to establish the topology of the sensor network.

I noticed that different software that use blocky has different libraries.

For example, in PKA there are the following libraries (photo 1)
Blockly

In Node-red there are the following (photo 2)
Blockly 1

Robot Mesh has libraries for easier robot control.

In micro: bit libraries are the following:
https://aca.edu.au/resources/blockly-microbit-radio/offline-56-microbit-radio.pdf

So my question is - is it possible to add more libraries to Blockly to help me for easier network configurations?

@bartbutenaers
Copy link
Owner

This node is developed as an alternative for the Function-node, for users that are not familiar with Javascript or programming in general. So we have added some basic blocks that allow users to implement some custom basic logic, which they cannot find in other blocks.
So you won't find e.g. an email block in this node, because there is already an email node in Node-Red. The purpose of this blocly node is not to replace or provide alternatives for other nodes, but to write basic custom logic which is not already available in other nodes already.
In your case you should create a series of custom nodes for Node-Red (e.g. node-red-contrib-usb, node-red-contrib-bluetooth, ...) instead of trying to add extra blocks to this blockly node.

@martin9115
Copy link
Author

Do you know any software (except maybe micro: bit), that use blockly, that have embedded that kind of networking library?
Do you think that zigbee libraries in NR ca help me build zigbee mesh?

@bartbutenaers
Copy link
Owner

For the blockly question perhaps @cymplecy can give any advise. I don't use blockly outside of Node-RED.

About the Zigbee question: I have no idea. You should ask such questions on the Node-RED Discourse forum instead of here...

@martin9115
Copy link
Author

I've noticed, that in blockly in NR there is an option for adding libraries. Can we add some code/commands there, to work like libraries? Is the code must be in Javascript?
bLOCKLY LIB

@bartbutenaers
Copy link
Owner

That option has become accidentally available, because the core of the Blockly-node is a copy of the Function-node: indeed once the Blockly-node has generated Javascript code, it has to behave exactly the same as the Function-node. Seems I should have not copied that part of the Function-node code...

I have never used Function-node libraries myself, but when I read this article, I see this:

image

I some next release I should remove that from the Blockly node, because it would never work:

  1. You draw your Blockly diagram.
  2. The Blockly-node generates Javascript from your diagram.
  3. Let's suppose you could export that generated Javascript code to that library.
  4. Let's suppose you could afterwards import that Javascript code from that library.
  5. Then there is no way the Blockly-node can regenerate a Blockly diagram again from your imported Javascript code.

I assume you want to bamboozle the Blockly node to get your recent feature request implemented? You want to create a library of Javascript code snippets and then load that into the Blockly node. Am I correct or not?

But it doesn't work like that. In Blockly every block can generate a very small code snippet of Javascript. And when you combine a lot of such blocks together, an entire Javascript program will be generated. Which is a fairly simple concept (in theory...).

However there is no way to do the reverse: you cannot generate Blockly blocks from a Javascript program, since that is much more difficult. Indeed you would have to support the entire Javascript ECMA specification, and keep it updated at each new version of that specification. See here the response of the Blockly team to that question:

image

Very short discussion. If you get the point ...

P.S. you might find attempts (like JS2Blockly but that is incomplete and unmaintained. I cannot add such a feature to the Blockly-node, since it will give more questions than answers to the users. Moreover all the blocks that I have implemented myself (e.g. to support the Node-RED API) can never be regenerated by that library.

Summarized: unfortunately impossible.

@martin9115
Copy link
Author

Actually i wanted to add some additional commands, like mechanical or radio commands (like in Robot Mesh or Micro Bit software's)
Is it possible?

@bartbutenaers
Copy link
Owner

Where or how do you want to add what?

@cymplecy
Copy link
Collaborator

cymplecy commented Oct 31, 2020 via email

@martin9115
Copy link
Author

I was looking for radio commands to input in Bockly.

How can i understand what library originally have in the function nodes, like in Python, Java, etc?

P.S. I just wanted to explore the all options

@bartbutenaers
Copy link
Owner

@martin9115: To be very honest, you don't make it very easy for us. You expect us to help you in our free time, but you just give us a pdf of 51 pages and expect us to read it and understand what you want to achieve. You could have done a bit more homework yourself. If everybody (who are using my nodes) expect this kind of (free) service, then I have to divorce and quit my daily job...

Anyway, I had a (very quick) look myself at the pdf and I 'think' it works like this:

  1. You draw a diagram with their blockly nodes
  2. When the diagram is ready you download a .hex file
  3. Then you deploy the .hex file to your micro:bit device

With this knowledge I also have no idea at all what you expect to do in Node-RED:

  1. Our blockly nodes generate Javascript, which will be executed on the NodeJs backend. I don't know which programming language is generated from your blocks (into the .hex file), but I'm pretty sure it is some kind of low-level language and not javascript.
  2. Node-RED runs on devices which have enough hardware resources to run NodeJS, which is completely other hardware compared to that micro:bit device.

Now it is your turn to explain 'clearly' what you want to achieve!

@martin9115
Copy link
Author

The links i share with you contain just a couple examples of the library used by the software, this is not some high- level literature, that consume a lot of time, but i understand you very well. And i'm grateful, that you create this node for people like me, that are not very good at programing.

As for my idea, i have i couple of Xbee modules and i wanted to establish some network between them and maybe some topology (Star, Mesh), and since i'm not good in programing i wanted to try do something with visual programming.

@bartbutenaers
Copy link
Owner

Hmmm, unfortunately I have never used xbee myself. If I were you I would post on the Node-RED forum a well described question. That you want to connect N xbee devices with some topology (star, mesh), and that you don't know how to get started with that. And that you aren't familiar with programming. I assume that you aren't the first one using xbee in combination with Node-RED...

@martin9115
Copy link
Author

I post everywhere, but nothing for now... I found some Python library with some command for xbee control, and that is why i wonder can i add this commands in Python function node for example?

@bartbutenaers
Copy link
Owner

bartbutenaers commented Nov 1, 2020

I post everywhere, but nothing for now...

Do you mean you have already posted it on the Node-RED forum?

i add this commands in Python function node for example?

I saw yesterday that they advice to use the Exec node for Python instead of the python contrib node. But I have never used python myself... You should really ask these kind of questions on the Node-RED forum!!!

@martin9115
Copy link
Author

OK i will ask again in NR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants