Use BLF keys to call REST functions



We have several GXP2160s, 30s and their related newer from the series, most have an owner and therefore share an extension number. The phones with the most BLF keys programmed doesn’t have more than 8, maybe 7; the thing is, there are a lot of unused BLF keys that could be put to better use.

In the network, there’s also a RESTful automation system and I know the phones already can send some sort of HTTP-ish request to the Grandstream…umm…door locks? The SIP deadbolts Grandstream makes. I remember too that these phones have the ability to run simple XML apps, so I know all the pieces are there to send a REST call which is nothing more than an HTTP request; I’m not a developer though. So instead I went looking to directly program an address to a BLF key but in a sea of selectable options executable by a key there seems to be none that cold request a web address.

I went into the UCM to try programming the keys remotely but I didn’t find a suitable option for the keys, I didn’t went out of my way using the UCM though because ZeroConfig is very hit and miss anyway and between reprovisions there’s a lot of wasted time–if the NOTIFY goes through that is–most of the time the phone just ignores it. On the phones’ web GUI though, there I did spent a kit of time testing and choosing other options for the BLF keys thinking maybe there were mislabeled, I updated the phones to the latest firmware and then again to the latest beta and I still don’t know how to send the REST call.

The closest I got is the section that does this but on status of the phone, not on a key press. “Action URL” is the section. The automation server does send status of the device, for instance, a door open or closed, it can be queried or gotten grouped on an RSS feed, which I think is more or less again what the phones already to with status broadcast groups, configurable at the UCM, this should be easily mapable to BLF keys–I just need a push in the right direction, although with all the time I’ve been looking and gotten nowhere a push in the exact direction fits better.




i am not sure, if I understand your question right…
If you need a hint, how to send a HTTP-Request to a Server (that might be an REST-Call or whatever you want…) you have to go to (in the phone gui) settings/Programmable Keys / Virtual Multi-Purpose Keys.
There you click on “Edit VPK” of the corresponding key and a window pops up.

Mode -> XML-Application
Accounts -> your active account (mostly Account 1)
Description -> what you want as label on beneath your Button
Value -> the full http-request

then click “Save” and then click “Save VPK”

Now you see your label (description) next to the button on the phone. If you hit the button, the url will be called. If the http-request returnes a well-formed XML-document, the phone will display it. If not, nothing will happen “visually” on the phone, but your http-request will be executed anyways.

There is a demo around in the docs with a survey-example, that shows pretty much of what is possible.

Yves aka Jens


You are a genius!

TBH, I had read the document you referenced before but at the time I didn’t know what to make of it. I spent a lot of time researching how to create XML apps without knowing exactly what I was looking for. Not even ballpark.

In the past year, I’ve learned the basic concepts about RESTful APIs, federation, and a ton of server technologies, even since I wrote the question I still got a ton of new stuff in my head. But also when I wrote the question it had been months since I stopped trying to create apps and opted for using the built-in API on my automation server, for instance, and piggyback from there to other systems, I’m already doing it with several.

Anyway, I tried it, using the link from its web interface but it didn’t work. I thought maybe the web page formats the link differently so I took an iPhone where I have this app that calls the function directly, I set a packet capture on the firewall and to my surprise I did manage to find the address–Wireshark is the one tool I still don’t know how to use, I started reading a book of the TCP/IP protocol suite just yesterday though. :slight_smile: It was indeed a different address. I set the new one which didn’t work either but with the details in Wireshark there was this “nonce” value, so I figured it didn’t work.

As far as I know nonce, related to encryption/nonreplay functions. I took the same address and called it in a browser windows, it asked me for my username and password. As soon as I entered the details it executed the function. <3

I now just have to find a way to incorporate this values in the call, I saw first it establishes a connection, and the app on the phone does turns a little indicator it was executed, so I don’t know if it needs to have a conversation or not, authentication is digest so somebody with as little experience as me should figure it out–I’m hoping. Nevertheless you got me closer that I would be a year from now. Thank you very much!