Is there a way to customize the ADR algorithm

I mean by rewriting some relevant source code at github (I don’t know if they need to be compiled) to set the relevant content of ADR by myself.

I really need help.

Found this in the search, which Mr. Brocaar answers:

It is hard to understand and change the code.

It should be pretty straightforward, see this example:

You receive a req variable with all the parameters which you can use for your own ADR algorithm and then you return the DR, TX Power and NbTrans values that the NS must sent to the device.

My understanding is as follows:

The code you paste is an empty template, and I have to write codes at the My own codes part, which includes parameters like req.MaxDR, req.MinDR and So on.

If this is not an empty template, but a written example, it will be more conducive to modification. For example, there may include the default ADR code to show how to call parameters to process.

func (h *Handler) Handle(req adr.HandleRequest) (adr.HandleResponse, error) {

        ***My own codes***

	return adr.HandleResponse{
		DR:           req.DR,
		TxPowerIndex: req.TxPowerIndex,
		NbTrans:      req.NbTrans,
	}, nil
}

And if I understand correctly, how can I successfully execute the modified code by compiling?

You will find the default ADR implementation here:

This is an example how you can test your code:

You can compile the plugin file like any other Go binary :slight_smile:

1 Like

When I want to refer to external dependencies:

go get github.com/brocaar/chirpstack-network-server/adr

go get: module github.com/brocaar/chirpstack-network-server@upgrade found (v2.5.0
+incompatible), but does not contain package github.com/brocaar/chirpstack-networ
k-server/adr

Repeatedly report the following error, I wonder if there is something wrong with the URL in import:

go.go:7:2: no required module provides package github.com/brocaar/chirpstack-network-server/adr; to add it:
	go get github.com/brocaar/chirpstack-network-server/adr

Sorry, my fault. The example works since it is within the github.com/brocaar/chirpstack-network-server Go module, but since the version is v3.x.x, the Go module should have been named github.com/brocaar/chirpstack-network-server/v3.

This commit fixes this + updates all the imports:

https://github.com/brocaar/chirpstack-network-server/commit/604d5e8825e50ccca67d2ebfcca55ab0de4dca25.

When the next version is tagged, you will be able to run go get github.com/brocaar/chirpstack-network-server/v3@v3.y.z (where v3.y.z matches an actual version number).

1 Like
go get github.com/brocaar/chirpstack-network-server/v3@v3.12.3

go get github.com/brocaar/chirpstack-network-server/v3@v3.12.3: github.com/brocaar/chirpstack-network-server@v3.12.3: invalid version: module contains a go.mod file, so ma
jor version must be compatible: should be v0 or v1, not v3

At present, the attempt is still unsuccessful. Is there any progress?