====== Использование сервисов Крокс через ubus ======
===== Пример использования ubus =====
root@kndrt31r27:~# ubus
Usage: ubus [] [arguments...]
Options:
-s : Set the unix domain socket to connect to
-t : Set the timeout (in seconds) for a command to complete
-S: Use simplified output (for scripts)
-v: More verbose output
-m : (for monitor): include a specific message type
(can be used more than once)
-M (for monitor): only capture received or transmitted traffic
Commands:
- list [] List objects
- call [] Call an object method
- listen [...] Listen for events
- send [] Send an event
- wait_for
===== Получение списка работающих сервисов =====
root@kndrt31r27:~# ubus list
dhcp
dnsmasq
file
hostapd.wlan0
iwinfo
kroks.dev.modem
kroks.dev.modem.modem1
kroks.dev.modem.modem1.simcard
kroks.dev.modem.modem1.simcard.modem1sim1
kroks.dev.modem.modem1.simcard.modem1sim2
kroks.dev.modem.modem1.sms
kroks.net.check
log
luci
luci-rpc
mwan3
network
network.device
network.interface
network.interface.lan
network.interface.loopback
network.interface.modem1
network.interface.wan
network.interface.wan6
network.rrdns
network.wireless
service
session
system
uci
===== Обращение к сервису =====
root@kndrt31r27:~# ubus call kroks.dev.modem.modem1 bands
{
"egsm": true,
"utran-8": true,
"eutran-3": true,
"eutran-20": true,
"eutran-40": true,
"eutran-1": false,
"eutran-41": false,
"eutran-28": false,
"eutran-38": true,
"eutran-7": true,
"utran-1": true,
"dcs": true,
"eutran-8": true
}
===== Изменение значений =====
Рассмотрим на примере примера выше с bands.\\
Как видно, включены все частоты, кроме band-1, band-41, band-28. Включим их, но выключим band-20.
root@kndrt31r27:~# ubus call kroks.dev.modem.modem1 bands '{"eutran-1": true, "eutran-41": true, "eutran-28": true, "eutran-20": false}'
{
"eutran-1": true,
"utran-8": true,
"utran-1": true,
"eutran-20": false,
"eutran-40": true,
"eutran-28": true,
"eutran-41": true,
"egsm": true,
"eutran-3": true,
"eutran-7": true,
"eutran-38": true,
"dcs": true,
"eutran-8": true
}
===== Получить список аргументов для modem1 =====
root@kndrt31r28:~# ubus -v list kroks.dev.modem.modem1*
'kroks.dev.modem.modem1' @827e6f0c
"object":{"folder":"String"}
"simtoggle":{}
"simcard":{}
"power":{}
"modes":{}
"state":{}
"capabilities":{}
"bands":{}
'kroks.dev.modem.modem1.simcard' @e7744e76
"object":{}
'kroks.dev.modem.modem1.simcard.modem1sim1' @119a2c80
"object":{"folder":"String"}
'kroks.dev.modem.modem1.sms' @8a46f205
"object":{"folder":"String"}
"cleanup":{"timestamp":"Integer","commit":"Boolean"}
"send":{"number":"String","smsc":"String","storage":"String","class":"Integer","validity":"String","delivery-report-request":"Boolean","text":"String"}
{{tag>ubus, service, kroks.dev.modem}}