GithubHelp home page GithubHelp logo

Comments (18)

gerfen avatar gerfen commented on June 9, 2024 1

@fbeltrao Just wanted to let you know that I was finally able to test sending C2D hex messages and I had no issues.

from iotedge-lorawan-starterkit.

Mandur avatar Mandur commented on June 9, 2024

@gerfen I am not sure I fully understand your question, let's discuss this issue over the phone thursday

from iotedge-lorawan-starterkit.

gerfen avatar gerfen commented on June 9, 2024

@Mandur - sounds good.

from iotedge-lorawan-starterkit.

Mandur avatar Mandur commented on June 9, 2024

More tests will be conducted by @gerfen with C2D messaging that might lead to another session. I let the issue open in the meanwhile

from iotedge-lorawan-starterkit.

gerfen avatar gerfen commented on June 9, 2024

I was doing two things incorrectly. One I was using "Direct Message" instead of "Message to device". I also misread the documentation for the device I am trying to configure. The device is expecting a message in the format of |Command| Parameter| CRC |. With those issues resolved I ended up sending the command "0002003CF5A1" (without the quotes). Unfortunately this did not work as I received the following in the gateway logs:

2019-02-08 00:48:47.727 0004A30B0021E4E2: valid frame counter, msg: 226 server: 225
2019-02-08 00:48:47.728 0004A30B0021E4E2: decoding with: http://decodersample/api/DecoderDecentlabWaterLevelSensor port: 1
2019-02-08 00:48:47.736 0004A30B0021E4E2: sending message {"time":null,"tmms":0,"tmst":3085307900,"freq":902.5,"chan":1,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-30,"lsnr":9.2,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001251220703125,"temperature":15.78125},"port":1,"fcnt":226,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549586927726} to hub
2019-02-08 00:48:47.760 0004A30B0021E4E2: sent message {"time":null,"tmms":0,"tmst":3085307900,"freq":902.5,"chan":1,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-30,"lsnr":9.2,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001251220703125,"temperature":15.78125},"port":1,"fcnt":226,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549586927726} to hub
2019-02-08 00:48:47.760 0004A30B0021E4E2: message '{"deviceId":"2570","battery":3073,"pressure":-0.001251220703125,"temperature":15.78125}' sent to hub
2019-02-08 00:48:47.760 0004A30B0021E4E2: checking c2d message
2019-02-08 00:48:47.761 0004A30B0021E4E2: done checking c2d message
2019-02-08 00:48:47.761 0004A30B0021E4E2: checking c2d message
2019-02-08 00:48:47.765 0004A30B0021E4E2: done checking c2d message
2019-02-08 00:48:47.765 0004A30B0021E4E2: abbandoning c2d message
2019-02-08 00:49:05.447 Statistic: {"stat":{"time":"2019-02-08 00:49:05 GMT","rxnb":2,"rxok":1,"rxfw":1,"ackr":100.0,"dwnb":0,"txnb":0}}
2019-02-08 00:49:17.772 0004A30B0021E4E2: could not abbandon c2d with error: Operation timeout expired.
2019-02-08 00:49:17.773 0004A30B0021E4E2: Additional C2D messages waiting, setting FPending to 1
2019-02-08 00:49:17.773 0004A30B0021E4E2: C2D message: 0002003CF5A1
2019-02-08 00:49:17.773 0004A30B0021E4E2: abbandoning c2d message
2019-02-08 00:49:17.799 0004A30B0021E4E2: could not abbandon c2d with error: 'receiver181' is closed
2019-02-08 00:49:17.799 0004A30B0021E4E2: too late for down message, sending only ACK to gateway
2019-02-08 00:49:17.799 0004A30B0021E4E2: processing time: 00:00:30.0734066

2019-02-08 00:58:54.099 0004A30B0021E4E2: using edgeHub local queue
2019-02-08 00:58:54.100 0004A30B0021E4E2: getting twins
2019-02-08 00:58:54.698 0004A30B0021E4E2: done getting twins
2019-02-08 00:58:54.699 0004A30B0021E4E2: done getting twins
2019-02-08 00:58:54.699 0004A30B0021E4E2: processing message, device not in cache
2019-02-08 00:58:54.700 0004A30B0021E4E2: valid frame counter, msg: 227 server: 220
2019-02-08 00:58:54.701 0004A30B0021E4E2: decoding with: http://decodersample/api/DecoderDecentlabWaterLevelSensor port: 1
2019-02-08 00:58:54.743 0004A30B0021E4E2: sending message {"time":null,"tmms":0,"tmst":345493804,"freq":902.9,"chan":3,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-47,"lsnr":8.2,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001220703125,"temperature":15.85},"port":1,"fcnt":227,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549587533956} to hub
2019-02-08 00:58:54.771 0004A30B0021E4E2: sent message {"time":null,"tmms":0,"tmst":345493804,"freq":902.9,"chan":3,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-47,"lsnr":8.2,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001220703125,"temperature":15.85},"port":1,"fcnt":227,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549587533956} to hub
2019-02-08 00:58:54.771 0004A30B0021E4E2: message '{"deviceId":"2570","battery":3073,"pressure":-0.001220703125,"temperature":15.85}' sent to hub
2019-02-08 00:58:54.772 0004A30B0021E4E2: checking c2d message
2019-02-08 00:58:55.035 0004A30B0021E4E2: done checking c2d message
2019-02-08 00:58:55.044 0004A30B0021E4E2: checking c2d message
2019-02-08 00:58:55.049 0004A30B0021E4E2: done checking c2d message
2019-02-08 00:58:55.053 0004A30B0021E4E2: abbandoning c2d message
2019-02-08 00:58:55.412 0004A30B0021E4E2: done abbandoning c2d message
2019-02-08 00:58:55.412 0004A30B0021E4E2: Additional C2D messages waiting, setting FPending to 1
2019-02-08 00:58:55.415 0004A30B0021E4E2: C2D message: 0002003CF5A1
2019-02-08 00:58:55.415 0004A30B0021E4E2: down frame counter: 1
2019-02-08 00:58:55.433 0004A30B0021E4E2: using standard second receive windows
2019-02-08 00:58:55.433 0004A30B0021E4E2: Cloud to device message with a Fport of 1
2019-02-08 00:58:55.434 0004A30B0021E4E2: Sending a downstream message with ID AFC9
2019-02-08 00:58:55.469 026D7217: UnconfirmedDataDown {"txpk":{"imme":false,"data":"YBdybQIQAQABS/RugLcz9flu1ODHyG0FfA==","tmst":347493804,"size":25,"freq":923.3,"rfch":0,"modu":"LORA","datr":"SF12BW500","codr":"4/5","powe":14,"ipol":true}}
2019-02-08 00:58:55.474 0004A30B0021E4E2: completing c2d message
2019-02-08 00:58:55.518 0004A30B0021E4E2: processing time: 00:00:01.5617695
2019-02-08 00:58:55.519 Packet with id AFC9 successfully transmitted by the aggregator
2019-02-08 00:58:55.662 0004A30B0021E4E2: done completing c2d message

At this point I rebooted the gateway and tried again. This time it looked like the message was successfully sent but it did not appear to change the reporting frequency of my devices - tried sending the same command to both devices.


2019-02-08 00:58:54.099 0004A30B0021E4E2: using edgeHub local queue
2019-02-08 00:58:54.100 0004A30B0021E4E2: getting twins
2019-02-08 00:58:54.698 0004A30B0021E4E2: done getting twins
2019-02-08 00:58:54.699 0004A30B0021E4E2: done getting twins
2019-02-08 00:58:54.699 0004A30B0021E4E2: processing message, device not in cache
2019-02-08 00:58:54.700 0004A30B0021E4E2: valid frame counter, msg: 227 server: 220
2019-02-08 00:58:54.701 0004A30B0021E4E2: decoding with: http://decodersample/api/DecoderDecentlabWaterLevelSensor port: 1
2019-02-08 00:58:54.743 0004A30B0021E4E2: sending message {"time":null,"tmms":0,"tmst":345493804,"freq":902.9,"chan":3,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-47,"lsnr":8.2,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001220703125,"temperature":15.85},"port":1,"fcnt":227,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549587533956} to hub
2019-02-08 00:58:54.771 0004A30B0021E4E2: sent message {"time":null,"tmms":0,"tmst":345493804,"freq":902.9,"chan":3,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-47,"lsnr":8.2,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001220703125,"temperature":15.85},"port":1,"fcnt":227,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549587533956} to hub
2019-02-08 00:58:54.771 0004A30B0021E4E2: message '{"deviceId":"2570","battery":3073,"pressure":-0.001220703125,"temperature":15.85}' sent to hub
2019-02-08 00:58:54.772 0004A30B0021E4E2: checking c2d message
2019-02-08 00:58:55.035 0004A30B0021E4E2: done checking c2d message
2019-02-08 00:58:55.044 0004A30B0021E4E2: checking c2d message
2019-02-08 00:58:55.049 0004A30B0021E4E2: done checking c2d message
2019-02-08 00:58:55.053 0004A30B0021E4E2: abbandoning c2d message
2019-02-08 00:58:55.412 0004A30B0021E4E2: done abbandoning c2d message
2019-02-08 00:58:55.412 0004A30B0021E4E2: Additional C2D messages waiting, setting FPending to 1
2019-02-08 00:58:55.415 0004A30B0021E4E2: C2D message: 0002003CF5A1
2019-02-08 00:58:55.415 0004A30B0021E4E2: down frame counter: 1
2019-02-08 00:58:55.433 0004A30B0021E4E2: using standard second receive windows
2019-02-08 00:58:55.433 0004A30B0021E4E2: Cloud to device message with a Fport of 1
2019-02-08 00:58:55.434 0004A30B0021E4E2: Sending a downstream message with ID AFC9
2019-02-08 00:58:55.469 026D7217: UnconfirmedDataDown {"txpk":{"imme":false,"data":"YBdybQIQAQABS/RugLcz9flu1ODHyG0FfA==","tmst":347493804,"size":25,"freq":923.3,"rfch":0,"modu":"LORA","datr":"SF12BW500","codr":"4/5","powe":14,"ipol":true}}
2019-02-08 00:58:55.474 0004A30B0021E4E2: completing c2d message
2019-02-08 00:58:55.518 0004A30B0021E4E2: processing time: 00:00:01.5617695
2019-02-08 00:58:55.519 Packet with id AFC9 successfully transmitted by the aggregator
2019-02-08 00:58:55.662 0004A30B0021E4E2: done completing c2d message
2019-02-08 00:41:39.638 0004A30B0022A720: valid frame counter, msg: 161 server: 160
2019-02-08 00:41:39.639 0004A30B0022A720: decoding with: http://decodersample/api/DecoderDecentlabWaterLevelSensor port: 1
2019-02-08 00:41:39.645 0004A30B0022A720: sending message {"time":null,"tmms":0,"tmst":2657210444,"freq":903.3,"chan":5,"rfch":1,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-35,"lsnr":10.5,"size":24,"data":{"deviceId":"2569","battery":3061,"pressure":-0.0018310546875,"temperature":15.68125},"port":1,"fcnt":161,"eui":"0004A30B0022A720","gatewayid":"baileynursery-production-gateway","edgets":1549586499633} to hub
2019-02-08 00:41:39.671 0004A30B0022A720: sent message {"time":null,"tmms":0,"tmst":2657210444,"freq":903.3,"chan":5,"rfch":1,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-35,"lsnr":10.5,"size":24,"data":{"deviceId":"2569","battery":3061,"pressure":-0.0018310546875,"temperature":15.68125},"port":1,"fcnt":161,"eui":"0004A30B0022A720","gatewayid":"baileynursery-production-gateway","edgets":1549586499633} to hub
2019-02-08 00:41:39.671 0004A30B0022A720: message '{"deviceId":"2569","battery":3061,"pressure":-0.0018310546875,"temperature":15.68125}' sent to hub
2019-02-08 00:41:39.672 0004A30B0022A720: checking c2d message
2019-02-08 00:41:39.673 0004A30B0022A720: done checking c2d message
2019-02-08 00:41:39.673 0004A30B0022A720: checking c2d message
2019-02-08 00:41:39.673 0004A30B0022A720: done checking c2d message
2019-02-08 00:41:39.674 0004A30B0022A720: abbandoning c2d message
2019-02-08 00:41:39.816 0004A30B0022A720: done abbandoning c2d message
2019-02-08 00:41:39.816 0004A30B0022A720: Additional C2D messages waiting, setting FPending to 1
2019-02-08 00:41:39.816 0004A30B0022A720: C2D message: 0002003CF5A1
2019-02-08 00:41:39.816 0004A30B0022A720: down frame counter: 1
2019-02-08 00:41:39.816 0004A30B0022A720: Cloud to device message with a Fport of 1
2019-02-08 00:41:39.817 0004A30B0022A720: Sending a downstream message with ID AEA1
2019-02-08 00:41:39.819 021FD0D6: UnconfirmedDataDown {"txpk":{"imme":false,"data":"YNbQHwIQAQABTCLXourGdNaV4BfXZE8AeQ==","tmst":2658210444,"size":25,"freq":926.3,"rfch":0,"modu":"LORA","datr":"SF10BW500","codr":"4/5","powe":14,"ipol":true}}
2019-02-08 00:41:39.819 0004A30B0022A720: completing c2d message
2019-02-08 00:41:39.820 0004A30B0022A720: processing time: 00:00:00.1874525
2019-02-08 00:41:39.821 Packet with id AEA1 successfully transmitted by the aggregator
2019-02-08 00:42:05.447 Statistic: {"stat":{"time":"2019-02-08 00:42:05 GMT","rxnb":1,"rxok":1,"rxfw":1,"ackr":100.0,"dwnb":1,"txnb":1}}
2019-02-08 00:42:09.824 0004A30B0022A720: could not complete c2d with error: Operation timeout expired.

I then received this message for subsequent c2d messages to those devices:

2019-02-08 01:08:52.453 026D7217: processing message, device in cache
2019-02-08 01:08:52.454 0004A30B0021E4E2: valid frame counter, msg: 228 server: 227
2019-02-08 01:08:52.454 0004A30B0021E4E2: decoding with: http://decodersample/api/DecoderDecentlabWaterLevelSensor port: 1
2019-02-08 01:08:52.461 0004A30B0021E4E2: sending message {"time":null,"tmms":0,"tmst":943975004,"freq":902.9,"chan":3,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-47,"lsnr":11.5,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001190185546875,"temperature":15.896875},"port":1,"fcnt":228,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549588132447} to hub
2019-02-08 01:08:52.486 0004A30B0021E4E2: sent message {"time":null,"tmms":0,"tmst":943975004,"freq":902.9,"chan":3,"rfch":0,"stat":1,"modu":"LORA","datr":"SF10BW125","codr":"4/5","rssi":-47,"lsnr":11.5,"size":24,"data":{"deviceId":"2570","battery":3073,"pressure":-0.001190185546875,"temperature":15.896875},"port":1,"fcnt":228,"eui":"0004A30B0021E4E2","gatewayid":"baileynursery-production-gateway","edgets":1549588132447} to hub
2019-02-08 01:08:52.487 0004A30B0021E4E2: message '{"deviceId":"2570","battery":3073,"pressure":-0.001190185546875,"temperature":15.896875}' sent to hub
2019-02-08 01:08:52.487 0004A30B0021E4E2: checking c2d message
2019-02-08 01:08:52.488 0004A30B0021E4E2: done checking c2d message
2019-02-08 01:08:52.488 0004A30B0021E4E2: checking c2d message
2019-02-08 01:08:52.489 0004A30B0021E4E2: done checking c2d message
2019-02-08 01:08:52.489 0004A30B0021E4E2: abbandoning c2d message
2019-02-08 01:09:11.074 Statistic: {"stat":{"time":"2019-02-08 01:09:11 GMT","rxnb":3,"rxok":1,"rxfw":1,"ackr":100.0,"dwnb":0,"txnb":0}}
2019-02-08 01:09:22.497 0004A30B0021E4E2: could not abbandon c2d with error: Operation timeout expired.
2019-02-08 01:09:22.497 0004A30B0021E4E2: Additional C2D messages waiting, setting FPending to 1
2019-02-08 01:09:22.498 0004A30B0021E4E2: C2D message: 0002003CF5A1
2019-02-08 01:09:22.499 0004A30B0021E4E2: abbandoning c2d message
2019-02-08 01:09:24.610 0004A30B0021E4E2: could not abbandon c2d with error: Exception of type 'Microsoft.Azure.Devices.Client.Exceptions.DeviceMessageLockLostException' was thrown.
2019-02-08 01:09:24.610 0004A30B0021E4E2: too late for down message, sending only ACK to gateway

I'll try to gather more data as time permits.

from iotedge-lorawan-starterkit.

ronniesa avatar ronniesa commented on June 9, 2024

Let us check, I think we may have a problem in how we format the msg in case you send down HEX. Let you know

from iotedge-lorawan-starterkit.

Mandur avatar Mandur commented on June 9, 2024

@ronniesa is correct. We identified this as a bug. We will connect back with you to test it out.

from iotedge-lorawan-starterkit.

gerfen avatar gerfen commented on June 9, 2024

@Mandur and @ronniesa Thanks for the update and bug confirmation.

from iotedge-lorawan-starterkit.

gerfen avatar gerfen commented on June 9, 2024

Working with @Mandur I was able to send messages to one class of devices. We were able to do this by replacing line 446 of MessageProcessor.cs

 frmPayload = cloudToDeviceMessage?.GetBytes();

with this

 if (cloudToDeviceMessage.Properties.TryGetValueCaseInsensitive("hex", out var hex))
 {
      frmPayload = ConversionHelper.StringToByteArray(System.Text.Encoding.UTF8.GetString(cloudToDeviceMessage?.GetBytes()));
 }
 else
 {
       frmPayload = cloudToDeviceMessage?.GetBytes();
 }

This requires sending a property named 'hex' set to 1, e.g.
image

I am in the process of putting together a PR but it will be some time next week before I can submit it as I want to do more testing.

from iotedge-lorawan-starterkit.

Mandur avatar Mandur commented on June 9, 2024

Thanks for the suggestion and help @gerfen. I know @fbeltrao is working on a C2D message refactoring. It might be good to sync to avoid duplicate or conflicting work.

from iotedge-lorawan-starterkit.

fbeltrao avatar fbeltrao commented on June 9, 2024

I am working on cloud to device message changes. The idea is to use JSON to represent the message to send downstream instead of properties. You will also have the option to send text or raw payload (in base64 format).

The idea is something like this, you either send payload or rawPayload:

{
  "fport": integer,
  "rawPayload": "base64_bytes",
  "payload": "utf8 payload",
  "confirmed": boolean,
}

from iotedge-lorawan-starterkit.

gerfen avatar gerfen commented on June 9, 2024

@fbeltrao This looks great. I have some sensors which I have not been able to configure with the current 0.4.0-preview code on the master branch. I can share the documentation with you if that would be helpful.

from iotedge-lorawan-starterkit.

fbeltrao avatar fbeltrao commented on June 9, 2024

@gerfen as mentioned before the C2D currently available does not support binary (hex) as downstream. Once the changes I am working on becomes available on dev branch I'd appreciate if you had the time to give it a go and let us know if it works for you.

from iotedge-lorawan-starterkit.

gerfen avatar gerfen commented on June 9, 2024

@fbeltrao I'm more than happy to help test the new C2D functionality. Just let me know when it's ready. :)

from iotedge-lorawan-starterkit.

fbeltrao avatar fbeltrao commented on June 9, 2024

@gerfen we have added to the dev branch the bits to of the new cloud to device messaging. More information can be found here:
https://github.com/Azure/iotedge-lorawan-starterkit/blob/dev/Docs/quickstart.md#cloud-to-device-message

It would be great if you could give it a try and share your experience.

from iotedge-lorawan-starterkit.

gerfen avatar gerfen commented on June 9, 2024

@fbeltrao I'll test out the new functionality just as soon as I can unfortunately it's going to be harder than I anticipated as I have had a few set backs with procuring new hardware. I just found out that the sensors I ordered will not arrive until April - they were supposed to arrive last week :(. I'm a little reluctant to try out the new code on the sensors I have already deployed to production. I may be able to a temporary deployment over the weekend, test and then roll back. How stable it the code in the dev branch in relationship to what's currently in main?

from iotedge-lorawan-starterkit.

fbeltrao avatar fbeltrao commented on June 9, 2024

@gerfen First, I don't want to give you too much work, causing you to temper with your production environment with a less stable version of the kit.

Even though changes to dev are only accepted if they pass our CI tests (which include tests against actual hardware), it does have a higher chance of having bugs. When we make a release, updating master, it means we have been running ourselves for a while, thus reducing the chance of something have slipped. So my recommendation would be to use dev if you need a feature that is available there and have additional time to react in case something is not working properly.

Having said that, the changes we are introducing in cloud to device messages are not backward compatible. The way you send messages with the current master branch won't be supported in next release.

from iotedge-lorawan-starterkit.

fbeltrao avatar fbeltrao commented on June 9, 2024

I am closing as the new changes to cloud to device message have been released.

from iotedge-lorawan-starterkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.