ADR plugin creation example

I am confused about the ADR plugin system. Is there anyone who can implement a new ADR plugin successfully? If so, can you share a tutorial about it? I know there are some entries about ADR plugins but I actually need a step-by-step tutorial. I appreciate it if you help.

Have you seen chirpstack-network-server/main.go at master · brocaar/chirpstack-network-server · GitHub? The adr.HandleRequest param provides you with the uplink context, the adr.HandleResponse return value defines the desired state of the device. Everything in-between is up to you to implement :slight_smile:

This is the default ADR implementation which is already embedded:

Thank you for your response and yes, I see that topic as I said before. And I can modify that algorithm.

However, now I am using chripstack NS on my computer, and I do not know how can update the algorithm with my new algorithm. Should I install NS from the source code. And then modify the code and then compile again or is there any simpler way. It is called as ADR plugin, so I thought that there is a way to update the ADR algorithm without recompiling. I checked .etc.chirpstack-network-server directory. There is only one setting file. So, I could not find anyway to update the default ADR algorithm. Can you explain me step-by-step so that I can run my own ADR algorithm.

https://www.chirpstack.io/network-server/install/config/

  # ADR plugins.
  #
  # By default, the 'default' ADR algorithm is available. The number of available
  # ADR algorithms can be extended through plugins. This setting can be configured
  # to a list of one or multiple plugins.
  adr_plugins=[]

As far as I can tell you have to create a Go module based on chirpstack-network-server, compile it and “install” is so that I can be called systemwide, then you add that module’s name to the list of adr_plugins…

see Is there a way to customize the ADR algorithm for reference, also not a complete guide but has some hints…

ok I got it working, documentation is really the bare minimum so…

I installed the Go language, then I created a new mod:

mkdir my-new-mod
cd my-new-mod
go mod init my-new-mod

I copied the content from the adr example in main.go, changed relevant sections to “my-new-mod” and then I tried

go build

and followed what that put out:

go get github.com/brocaar/chirpstack-network-server/v3/adr
go get github.com/hashicorp/go-plugin@v1.4.0
go get my-new-mod

After that the build succeeded, I moved the my-new-mod binary to /usr/bin and edited the network server config toml:

adr_plugin=["my-new-mod"]
1 Like

Alex, this is exactly what I need. I appreciate your help. Thank you.

There is no need to put the plugin in /usr/bin. You can configure the adr_plugin setting to the absolute path of the plugin binary :slight_smile: