Advertisement
Guest User

Tracker Test

a guest
Apr 13th, 2021
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ih = require("./index")
  2.  
  3. // specify your wallet path here
  4. const walletKey = "d1.key"
  5.  
  6. // function for sending lat / lng updates
  7. async function sendUpdates() {
  8.    
  9.     for (let index = 0; index < 5; index++) {
  10.         console.log('\n\nMSG #'+index.toString+ "\n")
  11.         try {
  12.             var walletPath = walletKey
  13.             var lat = 35.227 + Math.random()
  14.             var lng = -80.84 + Math.random()
  15.             var rep = await ih.sendState({
  16.                 'lat': lat.toString(),
  17.                 'lng': lng.toString()
  18.                 // REPLACE BELOW WITH YOUR AES
  19.             }, walletPath, "aesSecret", "aesIv");
  20.             console.log(rep)
  21.         } catch (e) {
  22.             console.log(e)
  23.         }    
  24.     }
  25. }
  26.  
  27. // function for creation of the device and seeing the qr code
  28. async function createDevice() {
  29.     var ret = await ih.setupWallet(walletKey)
  30.     var adr = ret['wallet'].address()
  31.     var qr = ret['qr_code']
  32.     console.log('Address: '+adr+"\nQr Code:\n"+qr)
  33. }
  34.  
  35. // specify which function to call (ideal)
  36. // createDevice - called once on the creation of the device
  37. // sendUpdate - called on a loop to keep the chain updated
  38. createDevice()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement