Skip to content

installing 09 ySensorsService manager

yOyOeK1 edited this page Aug 30, 2022 · 4 revisions

It's a flow responsible for turning on or off ySensorsService app on your phone. This apk is responsible for feeding the system with position data, temperature or what ever you can extract from host device. We need to focus on GPS, accelerators, magnetometers, speaker, wifi, ......

When ySensorsService is running it will give you access to your location and it will send that data to mqtt layer. Then it's processed or not. Easy thing to remember if it's running you need to have green icon on your top bar in android or in notifications that it's using service mode. When icon is not found it's off. Less traffic less battery usage.

Manager is responsible for making it running when you use opencpn or check instruments, use autopilot not all the time.

Node-red is allowing us to listen for connections on TCP, UDP ports and this flow is using it to trigger flow chine reaction. If it see listener or client (instrument panel is on,laptops is looking for GPS Access Point,...) it starts the ySensorService by sending android broadcast message witch start apk ySensorsService (green icon on bar).

apk can be download from repositorys' "ySensorsService_apk" directory. Newest better :P Install it as you will install apk from unknown source.

On remote file access to the device hosting oiyshTerminal you will find or not directory "oiyshTerminal" if not download or put it there. address ~/oiyshTerminal/ySensorsService/sh4Production/ will have lot of *.sh files. You need to put them in ~/ySS. So at the end you will have executable shell file script files by executing command ~/ySS/shStartService.sh what will start ySensorService in background mode. It will emit broadcast message to apk to tell it to start part of apk.

We need to import json to node-red. In repository "nodeRedAPFlows" is the source of json files. We need to use one ySensorServce manager.json.

It content import to node-red import flow process.

[ { "id": "805e345c078ffbda", "type": "tab", "label": "ySensorService manager", "disabled": false, "info": "", "env": [] }, { "id": "d0f5cc44e836c1f5", "type": "exec", "z": "805e345c078ffbda", "command": "/data/data/com.termux/files/home/ySS/shStopService.sh", "addpay": "", "append": "", "useSpawn": "false", "timer": "", "winHide": false, "oldrc": false, "name": "shStopService.sh", "x": 970, "y": 280, "wires": [ [], [], [] ] }, { "id": "ac458332aa63e932", "type": "exec", "z": "805e345c078ffbda", "command": "/data/data/com.termux/files/home/ySS/shStartService.sh", "addpay": "", "append": "", "useSpawn": "false", "timer": "", "winHide": false, "oldrc": false, "name": "shStartService.sh", "x": 970, "y": 220, "wires": [ [], [], [] ] }, { "id": "e3c978b7551f4285", "type": "inject", "z": "805e345c078ffbda", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "5", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "doActionsChk", "payload": "", "payloadType": "date", "x": 270, "y": 480, "wires": [ [ "1e47f16c79fb5797" ] ] }, { "id": "1e47f16c79fb5797", "type": "function", "z": "805e345c078ffbda", "name": "", "func": "var timeOut = 5000; // 5 sec\nvar clients = flow.get('yssClients')||{};\n\nif( msg.status ){\n \n if( msg.status.text == '0 connections' ){\n clients[ msg.status.source.name ] = 0;\n }else if( msg.status.text == 'common.status.disconnected' ){\n clients[ msg.status.source.name ] = 0;\n }else{\n clients[ msg.status.source.name ] = 1;\n }\n flow.set('yssClients', clients);\n \n}\n\n\n\nif( msg.topic == 'doActionsChk' ){\n tn = new Date().getTime();\n lastPing = parseInt(flow.get('andPingLastTime'))||0;\n \n var andStatus = 'on';\n fillColor = 'green';\n if( (lastPing+timeOut) < tn ){\n andStatus = 'off';\n fillColor = 'red'\n }\n \n var s = \" -- \";\n var ks = Object.getOwnPropertyNames(clients);\n var onSum = 0;\n for( var k=0,kl=ks.length;k<kl;k++ ){\n s+= ' ( '+ks[k]+' -> '+clients[ ks[k] ]+'), ';\n onSum+= clients[ ks[k] ];\n }\n \n if( global.get('apOnIs') )\n onSum+=1;\n \n \n \n node.status({\n fill:fillColor,\n shape: 'ring',\n text:'doAction andStat('+andStatus+')' +s+'[ap:'+global.get('apOnIs')+']'\n }); \n \n \n if( onSum > 0 && andStatus == 'off'){\n node.send([\n {payload:'make it running'},\n null\n ]);\n }else if( onSum == 0 && andStatus == 'on'){\n node.send([\n null,\n {payload:'make it stop'}\n ]);\n }\n \n}\nif( msg.topic == 'and/stat/ping' ){\n flow.set('andPingLastTime',new Date().getTime());\n \n //node.status({\n // text:'gotPing'\n //});\n}", "outputs": 3, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 640, "y": 540, "wires": [ [ "ac458332aa63e932" ], [ "d0f5cc44e836c1f5" ], [] ] }, { "id": "efbd243056224b42", "type": "mqtt in", "z": "805e345c078ffbda", "name": "", "topic": "and/stat/ping", "qos": "2", "datatype": "auto", "broker": "4bf528a73403ee8b", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 310, "y": 540, "wires": [ [ "1e47f16c79fb5797" ] ] }, { "id": "5e34213eb7c27988", "type": "inject", "z": "805e345c078ffbda", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "on", "payloadType": "str", "x": 790, "y": 220, "wires": [ [ "ac458332aa63e932" ] ] }, { "id": "723d7daebb7540b4", "type": "inject", "z": "805e345c078ffbda", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "off", "payloadType": "str", "x": 790, "y": 280, "wires": [ [ "d0f5cc44e836c1f5" ] ] }, { "id": "52f734b330961380", "type": "link in", "z": "805e345c078ffbda", "name": "yssManagerCmdLink", "links": [ "d72c7ff305d06eee", "6c193329fe0d5f0c" ], "x": 355, "y": 660, "wires": [ [ "1e47f16c79fb5797", "c0de322b2322cf08" ] ] }, { "id": "c0de322b2322cf08", "type": "debug", "z": "805e345c078ffbda", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 450, "y": 720, "wires": [] }, { "id": "2028074dde6dc44d", "type": "inject", "z": "805e345c078ffbda", "name": "zero clients list", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 300, "y": 420, "wires": [ [ "19674c3f36303a79" ] ] }, { "id": "19674c3f36303a79", "type": "function", "z": "805e345c078ffbda", "name": "", "func": "flow.set('yssClients',{});\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 600, "y": 420, "wires": [ [] ] }, { "id": "4bf528a73403ee8b", "type": "mqtt-broker", "name": "MqAtNex7", "broker": "localhost", "port": "10883", "clientid": "nodeRedNex7Client", "autoConnect": true, "usetls": false, "protocolVersion": "4", "keepalive": "60", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "birthMsg": {}, "closeTopic": "", "closeQos": "0", "closePayload": "", "closeMsg": {}, "willTopic": "", "willQos": "0", "willPayload": "", "willMsg": {}, "sessionExpiry": "" } ]

you can import it as a new flow or ad it to existing one. You need to edit some stuff?

do Deploy in node-red.

Now Testing process.

  • opencpn as a test. Set up Connection to network type tcp protocol. Ip is your oiyshTerminal ip and port 11226 In my case it's 192.168.43.1 port 11226 disable control checsum and Apply

If all went good by starting that opencpn you will start node in node-red and greed icon with ySensorService will pop up in top bar in android device where you have oiyshTerminal.

  • linux command line check

$ nc 192.168.43.1 11226

you will get lines of nmea data. If apk is running you will see: `

....

$NRHDM,283,M

$NRXDR,A,12.04,,PTCH,A,-95.81,,ROLL,

$NRHDM,283,M

$NRXDR,A,12.31,,PTCH,A,-95.67,,ROLL,

$NRHDM,282,M

$NRXDR,A,12.83,,PTCH,A,-95.16,,ROLL,

.....

` :) Green light you see accelerator data and compass. Look for yss_calibration !

Checking flow in node-red is also with some debug information's.

Let me know how it went for you!

Clone this wiki locally