How the user input values-text fields, in lora-app-server, post that value to golang at backend?

Exactly, my point! The error that I am getting is unrelated to the files that I changed, unrelated to the functionality that I added. Which is all the more confusing.

The answer to this is:

Yes, yes I got that the first time only. But the problem is, I did not change the existing .proto file methods or parameters, I only added a new parameter name “pid”. That’s all. I did not change the dev_eui , neither did I renamed it, nor I touched any other .proto files or their definitions.

As I said above, I have only added one parameter to only one .proto file:

Yes, I already did that and I have made necessary changes inside the loraserver code and that is running just fine. I just wanted to reflect this functionality inside the lora-app-server UI also.

I am sorry, but I am not asking for that. All I am asking is that if you can help me with resolving Uncaught (in promise) Error , that I am getting inside a file I didn’t change and which is completely unrelated to the changes that I made.
:
If it helps, here’s the complete flow of the changes I made:-

  1. First, in the deviceQueue.proto file added the following line in the message DeviceQueueItem{}

    string pid = 7;
    
  2. Then, in the device_queue.go file, inside func Enqueue() , I added the following code snippet:

    var mac lorawan.EUI64
       if err := mac.UnmarshalText([]byte(req.DeviceQueueItem.Pid)); err != nil {
     return nil, grpc.Errorf(codes.InvalidArgument, "mac: %s", err)
      }
    err := d.validator.Validate(ctx, auth.ValidateGatewayAccess(auth.Read, mac))
    if err != nil {
     return nil, grpc.Errorf(codes.Unauthenticated, "authentication failed: %s", err)
    }
    

Then inside storage.Transaction(), I added:

gw, err := storage.GetGateway(ctx, storage.DB(), mac, true)
   fmt.Println(gw)
if err != nil {
	return nil, helpers.ErrToRPCError(err)
}
  1. Then, I preceded to stores/DeviceQueueStore.js, and added the following inside enqueue() function:

    "device_queue_item.pid": item.mac, 
    
  2. Then, in views/devices/DeviceDetails.js , inside onSubmit = (queueItem) => , added the following:

    qi.mac= this.props.match.params.mac;
    

Then, I built the ui folder using npm start, and viewed the UI in the development server, where I encountered the Uncaught (in promise) Error, which I want to resolve. :sweat:

Remember you recompiled all proto files, maybe with a version that’s different from the one used in the precompiled binaries, so it doesn0t matter which files you touched or not: everything is regenerated. So maybe your proto files indicate a parameter like:

string dev_eui = 1 [json_name = "devEui"]

The precompiled binaries may have taken that as dev_eui, as the stores show, but maybe your version takes it as devEui and now handing a dev_eui to the store method doesn’t work anymore. So try to change it and see if it’s fixed.

That’s not the actual error, that’s just saying there’s an error that was unhandled (that’s why it crashes), and in the same line the error is stated: Required parameter devEui is not provided. And that’s fixed by what I said before.

1 Like

So you mean to say that I have to change all of the below given values also, for which I am getting this error? Like gatewayId , organizationId , etc. :-

How can a different version of the .proto file, on re-compilation change the name of the parameter that the API is fetching?

For example, because of this: https://forum.loraserver.io/t/help-testing-the-next-lora-app-server-release-with-lorawan-1-1-support/1610/17

1 Like

Okay, so you were right and when I changed the values which were defined in .proto files as dev_eui ( and were taken as it is in .js files) ; to devEui, the error vanished.

BUT now I have to do this for every .js file, I have to change the default .proto values with snake_case to lowerCamelCase, inside .js files and Not inside .proto files (as changing the values from snake_case to lowerCamelCase is generating error while running make api) .

Which is a very lengthy and time consuming process. And what if when every new version update comes? Then also, I will have to change the cases present inside the .js files?

Isn’t their some other alternative to this?

In this, it’s said that we just have to delete the old binaries of protoc-gen-grpc-gateway and protoc-gen-swagger and install the updated one, then run make dev-requirements and then make api , then we will end up with the correct code. I tried doing that, but this also didn’t solve the problem.

And also, will this change in the value name inside .js files affect the code at loraserver or lora-gateway-bridge? or this change is limited to frontend only?

You could ask Orne what version he is using to use the same one.

If I recall correctly, it shouldn’t: GetJsonName() is used instead of GetName() when building the Swagger definitions for the REST API only.

1 Like

@brocaar Hi! Could you tell what version of protoc-gen-grpc-gateway and protoc-gen-swagger you’re currently using? Do we have to follow all the versions from the go.mod file?

I am asking because I modified the proto definitions and the respective .go and .js files. But on recompilation, the .js files are no longer accepting the snake_case values defined in the proto definitions, instead I have to change it to lowerCamelCase inside the .js files so that the UI could reload the response.
For example, .js file i have to redefine dev_eui to devEui, after then only it was able to take the whole parameter. As I cannot always change the cases of all the values in all .js files (currently there are 16), present. Kindly help.

Hi, @iegomez, thank you so much for helping me understand this flow better. As you know that I have changed the files as you told me to, I am now facing another problem. The last seen of the Gateway is not updating and is still showing Invalid Date.

I have a node and a gateway registered on my server and that node is correctly sending and receiving data, as I can see the frames inside LIVE LORAWAN FRAMES (gateway) as well as in DEVICE LIVE FRAMES.

Why is this happening?

Hi, @pooja.mittal.

First, this has been off-topic for a very long time now and that doesn’t help with keeping the forum ordered and easy to search, so I believe the topic shouldn’t go any further. I won’t close it yet as you addressed Orne directly, but after that I think it should be.

On the same line, you should also avoid just going on and opening a new topic for this issue: try searching first and see if any of those topics or others help before opening a new one.

1 Like