Hi,
can anybody explain me how to transfert the right datas from a 1st function node to a second function node?
I can't make it. The result is always: "{"error":{"code":400,"message":"Parse Error","errors":[{"domain":"global","message":"Parse Error","reason":"parseError"}]}}"
Here are the nodes:
[{"id":"383f4af8.c70816","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"42ac1eb2.53354","type":"inject","z":"383f4af8.c70816","name":"Invalid IWAP01+WIFI","topic":"","payload":"IWAP01190215V0000.0000N00000.0000E000.1061830323.8706000908000102,460,0,9520,3671,Home|74-DE-2B-44-88-8C|97&Home1|74-DE-2B-44-88-8C|97&Home2|74-DE-2B-44-88-8C|97&Home3|74-DE-2B-44-88-8C|97#","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":141,"y":138.0000023841858,"wires":[["5fbfa8e5.d24398"]]},{"id":"5fbfa8e5.d24398","type":"function","z":"383f4af8.c70816","name":"AP01 split flag A/V","func":"// flag = A\n//IWAP01080524A2232.9806N11404.9355E000.1061830323.8706000908000102,460,0,9520,3671#\n// flag = V\n//IWAP01080524V0000.0000N00000.0000E000.1061830323.8706000908000102,460,0,9520,3671,Home|74-DE-2B-44-88-8C|97&Home1|74-DE-2B-44-88-8C|97&Home2|74-DE-2B-44-88-8C|97&Home3|74-DE-2B-44-88-8C|97# \nlet answer = {}\nlet elements = msg.payload.replace('#','').split(\",\") // this gives an array containing the bits\n// elements[0] is the long string starting IWAP01\nanswer.command = elements[0].substr(0,6)\nlet dateStr = elements[0].substr(6,6) // eg \"190215\" 15th Feb 2019\nanswer.date = new Date(Number(dateStr.substr(0,2))+2000, Number(dateStr.substr(2,2))-1, dateStr.substr(4,2)) // 080524 - date\nanswer.flag = (elements[0].substr(12,1)) // true or false - A or V\nif (answer.flag === \"A\") {\n let degreesN = Number(elements[0].substr(13,2))\n let minutesN = Number(elements[0].substr(15,7))\n let ns = elements[0].substr(22,1) // N or S\n let degreesE = Number(elements[0].substr(23,3))\n let minutesE = Number(elements[0].substr(26,7))\n let ew = elements[0].substr(33,1) // E or W\n answer.latitude = degreesN + minutesN/60 // 2232.9806N\n if (ns === \"S\") answer.latitude = -answer.latitude\n answer.longitude = degreesE + minutesE/60\n if (ew === \"W\") answer.longitude = -answer.longitude // 11404.9355E\n}\n\nanswer.speedMoving = elements[0].substr(34,5) // 000.1\nanswer.angleDirection = elements[0].substr(45,6) // 323.87\nanswer.signalStrength = elements[0].substr(51,3) // 060\nanswer.satellites = elements[0].substr(54,3) // 009\nanswer.batteryLevel = elements[0].substr(57,3) // 080\n// LBS datas\nanswer.mobileCountryCode = elements[1] // 460\nanswer.mobileNetworkCode = elements[2] // 0\nanswer.locationAreaCode = elements[3] // 9520 \nanswer.cellId = elements[4] // 3671\n// WIFI bases only with flag = V\nlet i;\nanswer.wifiAccessPoints = []\n if (answer.flag === \"V\") {\n let wifiAccessPointsStrings = elements[5].split(\"&\")\n let j;\n for (j = 0; j < wifiAccessPointsStrings.length; j++) {\n let baseElements = wifiAccessPointsStrings[j].split(\"|\")\n answer.wifiAccessPoints.push({ ssid: baseElements[0], macAddress: baseElements[1], signalStrength: baseElements[2] }) // Home|74-DE-2B-44-88-8C|97&Home1|74-DE-2B-44-88-8C|97&Home2|74-DE-2B-44-88-8C|97&Home3|74-DE-2B-44-88-8C|97\n }\n // adjust baseCountwifiAccessPoints just in case the number actually there didn't match that expexted\n answer.baseCountwifiAccessPoints = answer.wifiAccessPoints.length\n}\n\nmsg.payload = answer\nreturn msg","outputs":1,"noerr":0,"x":371.50000762939453,"y":137.80000686645508,"wires":[["2f8f4e66.0a5e02"]]},{"id":"2f8f4e66.0a5e02","type":"switch","z":"383f4af8.c70816","name":"Answer option","property":"payload.flag","propertyType":"msg","rules":[{"t":"eq","v":"A","vt":"str"},{"t":"eq","v":"V","vt":"str"}],"checkall":"true","repair":true,"outputs":2,"x":361.50000762939453,"y":169.00000190734863,"wires":[[],["24ed7be4.61d274","28e4a4b2.800f9c"]]},{"id":"28e4a4b2.800f9c","type":"function","z":"383f4af8.c70816","name":"MLS POSITION","func":"// Get positions from wifiAccessPoints\nvar dev_url = \"https://location.services.mozilla.com/v1/geolocate?key=test\";\nvar data =\n {\n \"considerIp\": \"false\",\n \"wifiAccessPoints\": [\n {\n \"ssid\": \"msg.payload.flag.baseElements[0]\",\n\t \"macAddress\": \"msg.payload.flag.baseElements[1]\",\n \"signalStrength\": \"msg.payload.flag.baseElements[2]\"\n }\n ]\n};\nvar msg = {\n \"method\" : \"POST\",\n \"url\" : dev_url,\n \"headers\" : {\n \"Content-Type\": \"application/json\",\n },\n \"payload\" : JSON.stringify(data)\n};\n \nreturn msg\n","outputs":1,"noerr":0,"x":361.50000381469727,"y":206.80002784729004,"wires":[["d48eaba7.f5f6e8","5016f062.3e769"]]},{"id":"d48eaba7.f5f6e8","type":"http request","z":"383f4af8.c70816","name":"MOZILLA MLS REQUEST","method":"use","ret":"txt","url":"","tls":"","x":396.300048828125,"y":283.8000535964966,"wires":[["8538befd.aec8f","755c9912.f87368"]]},{"id":"755c9912.f87368","type":"http response","z":"383f4af8.c70816","name":"","statusCode":"","headers":{},"x":631.8000106811523,"y":322.60005378723145,"wires":[]},{"id":"8538befd.aec8f","type":"debug","z":"383f4af8.c70816","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":649.8000106811523,"y":251.600004196167,"wires":[]},{"id":"5016f062.3e769","type":"debug","z":"383f4af8.c70816","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":649.5000076293945,"y":208.80002784729004,"wires":[]},{"id":"24ed7be4.61d274","type":"debug","z":"383f4af8.c70816","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":652.2399978637695,"y":175.4400053024292,"wires":[]}]