added examples

master
cheetah 2 years ago
parent 966cb4c5ed
commit e0c410e1d9

@ -0,0 +1,44 @@
#!/bin/bash
## Bash Library for sending out Pages and/or getting their State
# dependencies: curl, jq
# echo "Bericht" | send_page "http://127.0.0.1:3000" "duplex" "birdyslim" "pocsag=133701A"
send_page() {
text=$(cat -)
endpoint=$1
msgType=$2
deviceType=$3
argArr=("$@")
connectorJSON=$(for arg in "${argArr[@]}"; do echo $arg; done | jq -Rcs '{array:split("\n")|.[3:-1]|map(split("=")|[(.[0]),.[1]]?)}.array')
echo $connectorJSON |\
jq -c --arg t "$msgType" --arg d "$deviceType" --arg p "$text" '{type:$t, routing: {connectors:.,device:$d}, payload:$p}' |\
curl -s -XPOST -H "Content-type: application/json" "$endpoint/api/message/advanced" -d @- |\
jq -r .
}
msg_status() {
endpoint=$1
msgid=$2
curl -s "$endpoint/api/message/status/$msgid" |\
jq -r ._routerData
}
is_msg_recv() {
msg_status $* | jq .recvAck | grep -q "true"
return $?
}
is_msg_read() {
msg_status $* | jq .readAck | grep -q "true"
return $?
}
is_msg_resp() {
msg_status $* | jq .response | grep -vq "false"
return $?
}
ENDPOINT="http://127.0.0.1:3000"
#echo "Test" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133701D" "test=123"
echo "Testing API, respond with 1" | send_page "$ENDPOINT" "duplex" "emessage2WayS" "emessage=eCityruf#8907737"

@ -0,0 +1,44 @@
#!/bin/bash
## Bash Library for sending out Pages and/or getting their State
# dependencies: curl, jq
# echo "Bericht" | send_page "http://127.0.0.1:3000" "duplex" "birdyslim" "pocsag=133701A"
send_page() {
text=$(cat -)
endpoint=$1
msgType=$2
deviceType=$3
argArr=("$@")
connectorJSON=$(for arg in "${argArr[@]}"; do echo $arg; done | jq -Rcs '{array:split("\n")|.[3:-1]|map(split("=")|[(.[0]),.[1]]?)}.array')
echo $connectorJSON |\
jq -c --arg t "$msgType" --arg d "$deviceType" --arg p "$text" '{type:$t, routing: {connectors:.,device:$d}, payload:$p}' |\
curl -s -XPOST -H "Content-type: application/json" "$endpoint/api/message/advanced" -d @- |\
jq -r .
}
msg_status() {
endpoint=$1
msgid=$2
curl -s "$endpoint/api/message/status/$msgid" |\
jq -r ._routerData
}
is_msg_recv() {
msg_status $* | jq .recvAck | grep -q "true"
return $?
}
is_msg_read() {
msg_status $* | jq .readAck | grep -q "true"
return $?
}
is_msg_resp() {
msg_status $* | jq .response | grep -vq "false"
return $?
}
ENDPOINT="http://127.0.0.1:3000"
#echo "Test" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133701D" "test=123"
echo "Empty" | send_page "$ENDPOINT" "simple" "birdyslim" "pocsag=80D"

@ -0,0 +1,72 @@
#!/bin/bash
## Bash Library for sending out Pages and/or getting their State
# dependencies: curl, jq
# echo "Bericht" | send_page "http://127.0.0.1:3000" "duplex" "birdyslim" "pocsag=133701A"
send_page() {
text=$(cat -)
endpoint=$1
msgType=$2
deviceType=$3
argArr=("$@")
connectorJSON=$(for arg in "${argArr[@]}"; do echo $arg; done | jq -Rcs '{array:split("\n")|.[3:-1]|map(split("=")|[(.[0]),.[1]]?)}.array')
echo $connectorJSON |\
jq -c --arg t "$msgType" --arg d "$deviceType" --arg p "$text" '{type:$t, routing: {connectors:.,device:$d}, payload:$p}' |\
curl -s -XPOST -H "Content-type: application/json" "$endpoint/api/message/advanced" -d @- |\
jq -r .
}
msg_status() {
endpoint=$1
msgid=$2
curl -s "$endpoint/api/message/status/$msgid" |\
jq -r ._routerData
}
is_msg_recv() {
msg_status $* | jq .recvAck | grep -q "true"
return $?
}
is_msg_read() {
msg_status $* | jq .readAck | grep -q "true"
return $?
}
is_msg_resp() {
msg_status $* | jq .response | grep -vq "false"
return $?
}
ENDPOINT="http://127.0.0.1:3000"
#echo "Test" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133701D" "test=123"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"
echo -e "Test1234567890_1234567890_Testbericht13377777777777777777777777777777777777777777777777777777777777777777" | send_page "$ENDPOINT" "duplex" "birdyslim" "pocsag=133704A"

@ -79,13 +79,15 @@ class MessageManager {
this.messages[ msgId ]._routerData.response = response this.messages[ msgId ]._routerData.response = response
this.events.emit('event', 'response', [msgId, response]) this.events.emit('event', 'response', [msgId, response])
if (!!this.messages[ msgId ]._routerData.menu && !!this.messages[ msgId ]._routerData.menu.options) { if (!!this.messages[ msgId ]._routerData.menu && !!this.messages[ msgId ]._routerData.menu.options) {
let menuOption = Uint8Array.from(response).reduce((a,b) => a+b,0)
//console.log('response menuOption', response[0], '/', +response[0], Uint8Array.from(response), menuOption)
const menuOptions = this.messages[ msgId ]._routerData.menu.options const menuOptions = this.messages[ msgId ]._routerData.menu.options
console.log(this.messages[ msgId ]._routerData.menu, menuOptions, parseInt(response) - 1, clamp(-1+response, 0, Object.keys(menuOptions).length)) //console.log(this.messages[ msgId ]._routerData.menu, menuOptions, menuOption - 1, clamp(-1+response, 0, Object.keys(menuOptions).length))
const selectedMenu = menuOptions[ Object.keys(menuOptions)[ const selectedMenu = menuOptions[ Object.keys(menuOptions)[
clamp(parseInt(response) - 1, 0, Object.keys(menuOptions).length) clamp(menuOption - 1, 0, Object.keys(menuOptions).length)
] ] ] ]
this.events.emit('event', 'menu', [msgId, response, selectedMenu]) this.events.emit('event', 'menu', [msgId, menuOption, selectedMenu])
if (!!selectedMenu && !!selectedMenu.url) { if (!!selectedMenu && !!selectedMenu.url) {
axios.get(selectedMenu.url).then( () => false ) axios.get(selectedMenu.url).then( () => false )
} }

Loading…
Cancel
Save