cablelabs / lpwanserver

LPWAN Provisioning & Management Server
https://lpwanserver.com
Apache License 2.0
37 stars 11 forks source link

Device profile name/description not being sent on create #245

Closed rhythnic closed 5 years ago

rhythnic commented 5 years ago

Device profile creation fails on LoRa because top-level properties are not in payload. Response to UI succeeds because response goes back before the device profiles are created on LoRa Server.

rest_1             | POST /api/deviceProfiles/ 200 25.864 ms - 30
rest_1             | [2019-01-14T15:48:59.978Z] LoRaOpenSource.js:2561: {"method":"POST","url":"https://lora_appserver1:8080/api/device-profiles","headers":{"Content-Type":"application/json","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJsb3JhLWFwcC1zZXJ2ZXIiLCJleHAiOjE1NDc1NjcxNjYsImlzcyI6ImxvcmEtYXBwLXNlcnZlciIsIm5iZiI6MTU0NzQ4MDc2Niwic3ViIjoidXNlciIsInVzZXJuYW1lIjoiYWRtaW4ifQ.7zlmdOnGfwvr1AuXXGThdbv6qvxe3Osd8M6Afbtxhls"},"json":{"deviceProfile":{"macVersion":"1.0.0","regParamsRevision":"A"},"networkServerID":"5","organizationID":"56"},"agentOptions":{"secureProtocol":"TLSv1_2_method","rejectUnauthorized":false}}
rest_1             | 
rest_1             | [2019-01-14T15:48:59.982Z] LoRaOpenSource_2.js:2640: {"method":"POST","url":"https://lora_appserver:8080/api/device-profiles","headers":{"Content-Type":"application/json","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJsb3JhLWFwcC1zZXJ2ZXIiLCJleHAiOjE1NDc1NjcxNjksImlzcyI6ImxvcmEtYXBwLXNlcnZlciIsIm5iZiI6MTU0NzQ4MDc2OSwic3ViIjoidXNlciIsInVzZXJuYW1lIjoiYWRtaW4ifQ.arkPGVsBNken7LCk_NI7Xwxwwi2b7lpWRMwiihIXhB4"},"json":{"deviceProfile":{"macVersion":"1.0.0","regParamsRevision":"A","networkServerID":"1","organizationID":"10"}},"agentOptions":{"secureProtocol":"TLSv1_2_method","rejectUnauthorized":false}}
rest_1             | 
lora_appserver_1   | time="2019-01-14T15:48:59Z" level=info msg="finished unary call with code InvalidArgument" error="rpc error: code = InvalidArgument desc = invalid device-profile name" grpc.code=InvalidArgument grpc.method=Create grpc.service=api.DeviceProfileService grpc.start_time="2019-01-14T15:48:59Z" grpc.time_ms=4.536 peer.address="127.0.0.1:42378" span.kind=server system=grpc
rest_1             | [2019-01-14T15:48:59.994Z] LoRaOpenSource_2.js:2649: Error on create deviceProfile CatMouseTrapDeviceProfileLv2:  {"error":"invalid device-profile name","message":"invalid device-profile name","code":3,"details":[]}(400)
lora_appserver1_1  | time="2019-01-14T15:48:59Z" level=info msg="finished client unary call" grpc.code=OK grpc.method=CreateDeviceProfile grpc.service=ns.NetworkServer grpc.time_ms=3.17 span.kind=client system=grpc
lora_appserver1_1  | time="2019-01-14T15:48:59Z" level=info msg="device-profile created" device_profile_id=9442aaab-eba6-4bad-8f57-0481f7506246
loraserver1_1      | time="2019-01-14T15:48:59Z" level=info msg="device-profile created" device_profile_id=9442aaab-eba6-4bad-8f57-0481f7506246
loraserver1_1      | time="2019-01-14T15:48:59Z" level=info msg="finished unary call with code OK" grpc.code=OK grpc.method=CreateDeviceProfile grpc.service=ns.NetworkServer grpc.start_time="2019-01-14T15:48:59Z" grpc.time_ms=2.121 peer.address="172.22.0.8:43080" span.kind=server system=grpc
rest_1             | Unhandled Promise Rejection at: Promise  Promise { <rejected> 400 }  reason:  400
rest_1             | Stack: undefined
rhythnic commented 5 years ago

Fixed for LoRa V2. I'm working on a similar bug. Going to use this issue. The bug is that device profiles created in the UI are not synced to LoRa V1.

Here is a successful device profile post to V1. It's the device profile from LoRa v2.

{"deviceProfile":{"classBTimeout":0,"classCTimeout":0,"deviceProfileID":"9dd538e8-a231-4a35-8823-eecbffb9d4a9","factoryPresetFreqs":[],"macVersion":"1.0.0","maxDutyCycle":0,"maxEIRP":0,"pingSlotDR":0,"pingSlotFreq":0,"pingSlotPeriod":0,"regParamsRevision":"A","rfRegion":"US902","rxDROffset1":0,"rxDataRate2":0,"rxDelay1":0,"rxFreq2":0,"supportsClassB":false,"supportsClassC":false,"supportsJoin":false},"name":"BobMouseTrapDeviceProfileLv2","networkServerID":"5","organizationID":"56"}

Here's the failing one from the UI:

{"deviceProfile":{"deviceProfileID":3,"macVersion":"1.0.0","regParamsRevision":"A"},"name":"CATA Device Profile","networkServerID":"5","organizationID":"56"}

Obviously there are a lot of missing properties. Need to figure out if the UI is not passing them up or there is a server bug. @dschrimpsher FYI

Changes thus far are on branch issue-245

rhythnic commented 5 years ago

The issue was that deviceProfileID was a number and not a string.