Shop OBEX P1 Docs P2 Docs Learn Events
Driving wirelessly Digi WIFI from javascript — Parallax Forums

Driving wirelessly Digi WIFI from javascript

EMHmark7EMHmark7 Posts: 93
edited 2015-03-15 11:31 in Accessories
Hi,

For my web interfaces and applications, I will program in meteor js that is based on javascript and node.js
Beside Javascript, HTML and CSS (a web based interface), it can compile to Android and iOS.

I would like to use it for programming a remote control that would control (wireless) a Digi Wifi module on my Propeller projects (presently using XBEE footprint modules)
(I am using the passthrough mode and I/O readings, not the API mode)

The Wifi module would be driven either by an Android tablet, or directly by my server (it can be for production devices, or security systems, etc.)
It would be great to use the web or a network for remote control, but also (that framework on JS, HTML and CSS) for the look and feel of the user interface.

Any idea about APIs function calls or what API's available?
(as I said, it is javascript on nodejs that takes care of compiling applications in Android and iOS)
Not sure if I need to call nodejs directly, or other ways.

At worst, can an Android send and receive to and from another Android app that could do the sending/receiving for Digi wifi?
If so, is there an Android app that could be used as an API?

Thanks
Marc

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-01-08 19:00
    Marc,

    I am not entirely clear on what you need from the XBee Wi-Fi interface, however I just downloaded an Android app that is basically a UDP/TCP terminal. When I connect to the XBee Wi-Fi it sees all the messages and receives what I send back. UDP/TCP communication is pretty straight-forward on the S6B. I have also been able to send messages back and forth from VB.NET as well.
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-01-08 19:25
    Simply put, I am looking for how to send and receive serial data to the tablet's wifi, so it is received by the Digi Module.
    All that from javascript API, or at worst, from Android.

    (I am not using the API mode in the XBEE, but the passthrough serial and I/O reading/setting)

    When it is not from a tablet but from a windows desktop (let's say from a web browser), how could we send messages to the USB serial terminal?

    Could you put the link of the application you are talking about?

    Thanks for your reply.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-01-08 20:01
    All you need to do is send/receive UDP or TCP on the same port configured on the S6B and on that end the data is sent and received serially. So your app, whether it is on a tablet or PC must be able to communicate over UDP or TCP. I have three android apps I can use to communicate with my S6B from my tablet or cell phone. On the S6B end it is serial data so it can be text strings or binary values. It doesn't really matter how the data is formatted, it is packetized and sent serially.
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-02-20 11:57
    Thanks for reply,

    But I am looking for programming my own app (automation and logic such as sending several parameters or controlling from a web app), not just clicking on buttons on a screen from an existing app.

    5 cases:

    1) From a mobile device. Meteor JS can use Cordova plugins, but I do not find one for send/receive IP messages.

    2) From an app SERVER using Node.js (Meteor Js) connected to a Wifi (an app would call a server side function)

    3) From a BROWSER on the computer acting as the remote control to the Wifi interface (but not nessary if we install a Meteor JS on local host, in this case the local server would dialog with the Wifi as in case 4) )

    4) A LOCALHOST SERVING the browser but communication to the Parallax device by Wifi.

    5) A LOCALHOST SERVING the browser but communication to the Parallax device by the serial USB. (Same as previous but through the Serial USB)

    In all these cases, It would be interesting to know a path to function that would allow using the wifi or serial .
    Digi method seems complicated and seems to involve some kind of paid server based service.
    The main idea is to allow using webbased technologies for interface design and SSL communication for controling remote devices (wired or wireless) or getting status from them.
    It could be an alarm system monitoring or controling a manufacturing tool that needs lots of custom data according to a design.

    So the point is to access (duplex) the Wifi and or Serial USB through a browser or NodeJS or Cordova.

    I am not an expert of technology interactions behind meteor Js, but it is based on Node js and it can compile a native app for iOS and Android. (Cordova plugins can be used)
    The 2 nice things about Meteor js are:
    -client-server dual-way data sync without reloading a page
    -Simple web based templating
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-02-21 18:45
    This should help you:


    The xbee-api Node.js module helps you parsing and building API frames that are used to communicate with radio modules talking the 802.15.4 and ZigBee (including ZNet) protocol stacks. These are most commonly used in Digi's xbee radio modules, hence the name of this node module. However, other devices with the mentioned protocol stacks should also be supported. For details on supported firmwares and devices, see here.

    https://www.npmjs.com/package/xbee-api
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-02-22 08:13
    Thanks for your reply.

    But for now, I would prefer using the passthrough mode over Wifi. If somebody can help on that : ) .

    Thanks
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-02-22 08:26
    I will however investigate this API for future devices. For now, in your link, I found the following https://developer.chrome.com/apps/serial
    Who said we need to use an higher abstraction layer! This is cool fo desktop apps with a web bases interface. If it can be usefull to someone.

    But still, would be interested in using a mobile (tablet) via WIFI as a remote.
    Even if we could use the USB port, it is not the point to use a tablet with another external box for XBEE and batteries

    The software API uncertainty is why my actual device uses a 4D Systems touch screen + An XBEE module, std batteries, casing. The box is pretty big and tick and more expensive than a tablet.
    Also, a table has much more RAM/SSHD and allows Android for programming (such as Meteor JS compiled for Android)
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-02-22 08:32
    Again thanks for your link Bob: if we dig into it here it is:
    https://developer.chrome.com/apps/app_usb
    https://developer.chrome.com/apps/app_network

    For sure I will investigate that! Thanks!

    However they work only for Chrome Apps.

    I also found :
    https://github.com/voodootikigod/node-serialport
    https://www.npmjs.com/package/usb

    But the best solution would be through wifi network.
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-02-22 14:17
    This youtube https://www.youtube.com/watch?v=KqRiJQV8PE4 talks about a node.Js server talking to an XBee via serial.

    It leads to adding 2 options to my list:

    6) Have a lightweight Node.js server with Wifi and serial to a wifi XBee. (somehow redondant)

    7) Have a Propeller powered device that can be called as a webserver (maybe with Node.Js)
    This not only solves the wifi side of the device, but the programming side of the remote control (the client) doing the calls, and receiving answers.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-02-23 18:20
    Double Post
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-02-23 18:26
    Triple Post :)
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-02-23 18:28
    Quad post LOL

    The forum or DNS server was having problems
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-02-23 18:33
    Node serialport
    https://www.npmjs.com/package/serialport


    Understanding Serial Data from XBee using Node-XBee and Node-SerialPort

    http://stackoverflow.com/questions/21952233/understanding-serial-data-from-xbee-using-node-xbee-and-node-serialport

    This video provides a Digi-Key demonstration on the XBee ZigBee in action and also explains the features, benefits, how to use the XBee ZigBee Cloud kit, Gateway, and ZigBee cloud connection
    http://www.digikey.ca/videos/en/v/XBee-Zigbee-Cloud-kit-Another-Geek-Moment/3989656848001

    It's poor acting but funny :)
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-02-23 19:05
    Thanks Bob,

    But still my goal is to use a tablet that has only Wifi for remote controlling a XBEE (Wifi) (not a ZigBee).
    Ideally programming the user interface in Meteor.JS (in fact, JavaScript, Node.JS, HTML and CSS usable by a web browser) (or native version compiled for Android or iOS FROM JavaScript, Node.JS, etc.)
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-03-15 11:24
    I found this; https://www.npmjs.com/package/johnny-five
    It is a Node.js API for robotics. Would be good if Parallax could interpret
    the firmata protocol as stated on http://node-ardx.org/
  • EMHmark7EMHmark7 Posts: 93
    edited 2015-03-15 11:31
    I also found (which I did not investigate yet):
    https://www.npmjs.com/package/serialport
    http://pythonhackers.com/p/w1nk/node-serialport
    http://thinkingonthinking.com/serial-communication-with-nodejs/
    http://servicelab.org/2012/12/12/wirelessly-control-your-arduino-with-nodejs-over-bluetooth/

    I suppose it can work OK ofrom a desktop using its serial. But for a Wifi, tablet it would mean the Parallax need a node.js server onboard.
    (in my understanding)
Sign In or Register to comment.