ojousima / ruuvi-nodejs

Nodejs communication with RuuviTag using upcoming protocol. Runs on Raspberry Pi - unofficial
15 stars 5 forks source link

Cannot Get example.js working. #1

Closed JDrakeC closed 6 years ago

JDrakeC commented 6 years ago

I've followed all the steps to the best of my ability up until "node example.js" in the ruuvi-nodejs directy. This is what I get when trying to run...

image

JDrakeC commented 6 years ago

I've started with a Fresh Install of Raspbian. Cloned the Repo, NPM init inside ruuvi-nodejs NPM install noble - check NPM install ccurl.interface.js NPM install sleep - check git submodule - check git init - check

Then I try to run again, and this... image

ojousima commented 6 years ago

Have you done git submodule initand git submodule update?

JDrakeC commented 6 years ago

Yes. As far as I know I've followed the steps to a T. I must admit I'm not that familiar with NodeJS, but I really want to get this working with the Pi and Ruuvi communicating through The Tangle...

I hate to ask, but could you please walk me through the steps a little bit more in depth? I don't want to waste time, so first I will give you all my specifications and the steps that I took in case I left something out.

Raspberry Pi 3 - Raspbian ARM7l image

You can see hcitool lescan brings up a few different addresses, one is a Ruuvi weatherstation, and another is the Ruuvi with the hackathon firmware. (This should be displaying itself as RuuviBoot right? Or does it have some other name other than RuuviBoot or RuuviTag?)

Here is a print out of the steps I took. You can see the first git clone command fails because I've already done it. Please let me know any other information you need. I would feel so accomplished getting this functional.

(Oh, should I have used npm init in the ruuvi-nodejs dir? I did do that, but I'm wondering if I created the .json the wrong way, or I'm not understanding something about the way dependencies work with NodeJs and file paths.) image

JDrakeC commented 6 years ago

After this I tried sudo npm install bluetooth-hci-socket, and I get this error, repeating... image

JDrakeC commented 6 years ago

Okay, so I changed write permissions to the ruuvi-nodejs folder...now this is the error I'm getting: `` ~/ruuvi-nodejs $ node example.js /home/pi/ruuvi-nodejs/iota-mam/iota-mam.js:1 (function (exports, require, module, filename, dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB

Error: Could not locate the bindings file. Tried: → /home/pi/ruuvi-nodejs/node_modules/ref/build/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/build/Debug/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/build/Release/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/out/Debug/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/Debug/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/out/Release/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/Release/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/build/default/binding.node → /home/pi/ruuvi-nodejs/node_modules/ref/compiled/9.4.0/linux/arm/binding.node at bindings (/home/pi/ruuvi-nodejs/node_modules/bindings/bindings.js:93:9) at Object. (/home/pi/ruuvi-nodejs/node_modules/ref/lib/ref.js:5:47) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:573:32) at tryModuleLoad (module.js:513:12) at Function.Module._load (module.js:505:3) at Module.require (module.js:604:17) at require (internal/module.js:11:18) at Object. (/home/pi/ruuvi-nodejs/node_modules/ffi/lib/ffi.js:6:1

ojousima commented 6 years ago

It seems that the program is broken in NodeJS 9+, I was able to compile and run the example on NodeJS 8.9.4. I have updated the instructions and Raspberry Pi binary for ccurl, tested to work on RPI 3.

nayttokuva 2018-2-4 kello 10 45 22
JDrakeC commented 6 years ago

Yes, I was able to get it working as well, but how exactly does it work? What would be the best way to understand the RPi to Tangle side of the equation? How do I view the data on the Tangle Explorer? Which address or tag do I search for in there? The long string is the MAM message, correct?

I was able to get it working though. Here is the first time it ran... first ruuvi send

JDrakeC commented 6 years ago

Asking for MAM INIT MAM Starting MAM receive, expecting 138 chunks Request: 137, length: 14, MAM complete GQVKSZBJFAI9OUUXZSAYVPHENMYSMDOTXSVUISVGWN9DVUBYTNXCFQK9AAAWHFIBHLPRHXIXPX9HUCRUCJHMKHL9OMSDCQFRZJYNDERJXRX9BG9SRJXVQFOGVVDCZPICNRJK9PYMPAELUNGKVYMGJV9YDFWUYCFSYUASKJJFNVPBSAREDVCANHRNFR9KTFZMUTUIECCGSZHBRYKCZWZSCZIEQOLJYJSGMOZXGFHPBCJLBDANXSKPNSOMDRMDSI9TSQVZSCCHJSKXKPKCIQAUZDXCEZKMMMQZKZZRIXUPXISWYFFFDSTZDJYLNZRAOXXBPTEYMEEKCAZZEUAJBWYWSHZBMMIIYPEJBDPTEGVJAVVSVDNFPPAKWDBGWHAGJ9VGGIKVEYGMODJODSCPUHXPE9XJZZSKHZAXWWGACQDKUHOYLKLEBDHXHIANG9TQLKJHSNQXGTZPPYFRBKDWMWTVBYRCNUCPIYLKNOZPULC9OEV9YJLZRHWBQQTMVGKYFY9RDTZDK9AOSLFVEQMH9DOBZEKPRFDIKOMYKJASLIDC9JXFWZOWNEWEZLYKYOALJFGZLNIESJJUPPLVIVEVTPIKOWAJVZ9AG9L9BEVJEBNZVCQNR9OMVSEOEYGRZYTIOFDLHYCECB9FUMUQKFLF9VFGNONRKFNRPZIACWZWNXLKWFZTVIRLGKWLJWZUAJQZL9RHMMVEFBBUROVTQGP9TWICSHHHTPYZTUJCUJ9HVNXQOGRSEAADSWQOQEITUQLLGGJQZJVWAGM9LW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XCNQWCWPCQNLHVZRVXSWYANTZEFTKJFRKPWSJKRDWMYTMKVAMH9HJWS9LYGAQQHMEBQWSTKS9HGZGFCLPISXSEJUQFKXENIFPXWXPXRLWRWDCLAZMZDIUEWCLQROOHNVCJTUXROBQDDEWZIOHRAYOUPMYSVCQIMAUHBLWJLLKZDFVNQQDTVXRUHGEWASKPPEM9MJMMCKYVRYTNMIQAALRYO9XOUFBMYIZOPAXDPO9HSKPAAZDWLFTZHKWXFIVDVVEYCZOJSEWCOKWRDUVPFDKZLTYPH9QYXBCF9UTRJUBTBGJNUSXBFSUESLBHDYWFLXLOEARELRNLOSDMTSXPHPZOCHCDJNCSOGDH9ZVOVF9IOONALWWMNEH9BSVYSKFOMEFXLIQPMGHXEOGHWLBGAALMPZYGUQESENS9DCKLLZRYKJBUHWQWNDNTNPGPMXHVQOOYFVEJGXUVTUREYZGQMNQZKAYWTEWQPLHAUJZ9LVU9AWUPUTNVRECPBVIAOWPJTLFRJTNKE9XMS9NJHEDOMQYTFBNZOIADMDVLLPEGOBZM9WSXLA RUOZEBHDCPVXNTLOLR9JDCJYBGASSCTPGERBIOCFTHGYKIHPOZYPSI9XPKJPNGNSDNQZJWGUZNERYEULH [ 'ODCCDBWAYAVAYAQAZBDBCBABABBBWAQARBDBWAYAQD',

'XCRXXZMWIUARASDWCOCWBQCBPHAOWOZGBWFEJYUCMCLGWJFSKOTJFGNKILFLBAZZZQFOXZLIEXX9XKMYR' ] {T:2414,P:97782,H:24} (node:10306) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Invalid Response: Error: connect ETIMEDOUT 94.23.158.252:14265 at Object._errnoException (util.js:1041:11) at _exceptionWithHostPort (util.js:1064:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1153:14) (node:10306) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

On Sat, Feb 3, 2018 at 10:27 PM, Otso Jousimaa notifications@github.com wrote:

It seems that the program is broken in NodeJS 9+, I was able to compile and run the example on NodeJS 8.9.4. I have updated the instructions and Raspberry Pi binary for ccurl, tested to work on RPI 3. [image: nayttokuva 2018-2-4 kello 10 45 22] https://user-images.githubusercontent.com/2360368/35774017-5b245508-099e-11e8-828c-d6045dba31db.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ojousima/ruuvi-nodejs/issues/1#issuecomment-362877553, or mute the thread https://github.com/notifications/unsubscribe-auth/AhA10JiEWmYIecd_dG7tnguRvhdLiCXlks5tRSOsgaJpZM4R1-bq .

ojousima commented 6 years ago

Long String is the MAM message. This repository was originally built to explore IoT device sending MAM messages, but you can find an example on how to send data to Tangle in Frankfurt-hackathon branch.

Please note that the Frankfurt-hackathon reuses address, which means that the security of your wallet is halved for every transaction you send with that code. You can find the details by googling "Winternitz one time signature". For sending data to tangle you might want to look into https://devpost.com/software/storing-encrypted-sensor-data-to-the-iota-tangle . Please note that is another hackathon project, and far from being polished and ready to use.

We have more polished examples and tutorials on the roadmap, but I cannot promise exact dates on when the materials would be read. In the meanwhile please open pull requests or make posts on f.ruuvi.com is you build something cool :)

JDrakeC commented 6 years ago

Thank you so much! I see you updated with my errors in mind. I've also downloaded some of your other Ruuvi projects.
You're quite the busy bee!

What would be some good resources to really understand the ins and outs of what you're doing in this nodeJS app?

EDIT: Nevermind, I see that you've posted the developer link. My apologies.