Custom RPC function example. Error "rpc_gpio_write not found"

I cannot get any method to execute, they all say not found even in examples copy directly from M Dash GitHub.

I used to use mDashExport
mDashExport(“setPin”, setPin, NULL);

curl: (6) Could not resolve host: application
curl: (3) URL rejected: Bad hostname
{
“id”: 12,
“method”: “rpc_gpio_write”,
“error”: {
“code”: -32601,
“message”: “rpc_gpio_write not found”
}
}
I cannot upgrade until I figure out how to make an RPC call.
Please any help would be greatly appreciated!!

Can you share the docs you’re looking at?

I copy/pasted this from mDash looking at a device, you just need to replace the “device858” and the “undefined” token with your API key:

curl https://mdash.net/api/v2/devices/device858/rpc/Sys.GetInfo?access_token=undefined

Thanks for your reply. I am able to get the built-in RPC functions to work. However I need to be able to make calls to my own custom functions. The code is copied directly from the rpc_gpio_write example.

static void rpc_gpio_write(struct mg_rpc_req *r) {
long pin = mg_json_get_long(r->frame, “$.params.pin”, -1);
long val = mg_json_get_long(r->frame, “$.params.val”, -1);
if (pin < 0 || val < 0) {
mg_rpc_err(r, 500, “%Q”, “pin and val required”);
} else {
pinMode(pin, OUTPUT);
digitalWrite(pin, val);
mg_rpc_ok(r, “true”);
}
}

I used to use mDashExport(rpc_gpio_write); To make rpc_gpio_write visable but mDashExport is apparently no longer supported.

I don’t use this library, but if you could add some more link with examples you’re following it might help someone help out

I can only suppose that you are talking about the RPC example in the mDash library

It compiles ok for me and can call GPIO.Write form mdash device dashboard successfuly

Thanks so much for your response. It’s quite encouraging that it works, now I just got to figure out what I’m doing wrong.

mg_rpc_add(&g_rpcs, mg_str("GPIO.Write"), rpc_gpio_write, NULL); is the line that registers the rpc function.

You are truly a Godsend! I searched for 4 days trying to find a replacement for mDashExport(). Unfortunately there’s no cross reference from the old libraries to the current ones.

mg_rpc_add() totally changed my day!

I have updated - mDash OLD Funtions - replacements for mDash 2.1.16

Hope we can meet someday, dinner’s on me.
Many Many Thanks,
Brad