Hi!
I would like to ask a question about the OpenWrt Luci JSON-RPC API.
I want to call the find function of luci.model.ipkg class, but I don't understand how callback works.
This is my request:
curl http://192.168.1.1/cgi-bin/luci/rpc/ipkg?auth=d454d28a1dabfde80a591d2f99e25xyz --data @ipkg_find
ipkg_find:
{
"method": "find",
"params": [
"luci"
]
}
And the response:
{"id":null,"result":null,"error":{"message":"Invalid params.","data":"/usr/lib/lua/luci/model/ipkg.lua:152: attempt to call local 'cb' (a nil value)\u000astack traceback:\u000a\u0009/usr/lib/lua/luci/model/ipkg.lua:152: in function '_list'\u000a\u0009/usr/lib/lua/luci/model/ipkg.lua:174: in function </usr/lib/lua/luci/model/ipkg.lua:173>","code":-32602}}
maybe ipkg_find:
{
"method": "find",
"params": [
"luci",
<this place the callback function?!>
]
}
Documentation:
find (pat, cb)
Find packages that match the given pattern.
Parameters
pat: Find packages whose names or descriptions match this pattern, nil results in zero results
cb: Callback function invoked for each patckage, receives name, version and description as arguments
Return value:
nothing
I don't know how work this callback. Can you explain how it works?
I found ubus I read the documentation and it solves my problem. However, I would still be interested in how this callback function should be called in the present case. For learning purposes.
Thank you very much
Roland Dandi