Best practice: CURL or extesion script or other way

  1. Using curl is the appropriate way to interoperate with GenieACS for ex. client login to WEB PANEL and then click button to change SSID on his router?

  2. Or it will be better if I go with ackoder way: How to pass JSON object to provisioning script (best practice?)

  3. Or it depends of my programing skills and purpose?

I wouldn’t use curl, it executes out of process. Use provision scripts and extension scripts.

Hmm… So how would look equivalent code from CURL to provision scripts and extension scripts.

CURL example:
https://github.com/genieacs/genieacs/wiki/API-Reference => Change WiFi SSID and password:

curl -i 'http://localhost:7557/devices/202BC1-BM632w-0000000/tasks?connection_request' \
  -X POST \
  --data '{"name":"setParameterValues", "parameterValues":[["InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", "GenieACS", "xsd:string"],["InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.PreSharedKey", "hello world", "xsd:string"]]}'

My current logic looks like that:

  1. Client log in to WEB PANEL.
  2. Client change SSID.
  3. After submit SSID change - CURL query is executed.
  4. Done! Client router has new SSID.

Okay, now that you have explained things more, using curl from your custom app makes more sense. If you are using PHP, then I would use something like Guzzle to do the HTTP calls instead of shelling out to curl.

One thing to keep in mind is you probably want to do GPVs before the SPVs. If the value you are trying to set is the same as the value in the cached device model, genie won’t set that param on the CPE. Most of the time this won’t be an issue, but sometimes things can get out of sync.

For example, the actual SSID of the CPE might be “Home WiFi”, and for whatever reason the cache value in the data model might be “GenieACS”. If you make the curl call like you have above, then Genie will only actually change the PreSharedKey and not the SSID, and then you will be frustrated as to why the values aren’t changed on the device.

So do this call before the SPV:

curl -i 'http://localhost:7557/devices/202BC1-BM632w-0000000/tasks' \
  -X POST \
  --data '{"name":"getParameterValues", "parameterValues":["InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.PreSharedKey"]}'

Notice this call does not have ?connection_request in it. By making this API call first, then doing the SPV call, Genie will batch the requests up, speeding things up.

-dan

1 Like

akcoder thank you for your time and hint with Guzzle.