TheThingsArchive / java-app-sdk

The Things Network Application SDK for Java
MIT License
30 stars 25 forks source link

generating downlink message not works. #56

Closed wireless-road closed 3 years ago

wireless-road commented 6 years ago

Hi! I can see onMessageevents using following code:

            client.onMessage((String devId, DataMessage data) -> {
            log.info("\r\n###############################"
            + "\r\nMessage from device " + devId + " with: "
            + "\r\nAppId: " +  ((UplinkMessage)data).getAppId()
            + "\r\nDevId: " + ((UplinkMessage)data).getDevId()
            + "\r\nCounter: " + ((UplinkMessage)data).getCounter()
            + "\r\nHWserial: " + ((UplinkMessage)data).getHardwareSerial()
            + "\r\nPort: " + ((UplinkMessage)data).getPort()
            + "\r\nDataRaw: " + bytesToHex(((UplinkMessage)data).getPayloadRaw())
            + "\r\nGateway: " + ((UplinkMessage)data).getMetadata().getGateways().get(0).getId());

            DownlinkMessage responce = new DownlinkMessage(((UplinkMessage)data).getPort(), "hello");
            log.info("Sending");
            try {
                client.send(devId, responce);
            } catch (Exception e) {
                log.warning("Responce failed: " + e.getMessage());
            }
        });

but downlink message payload is empty no matter if java-app-sdk is started or stopped. Seems that downlink messages generated by TTN: capture Here is gateway traffic: capture2 Here is what I see on gateway logs:

JSON up: {"rxpk":[{"tmst":726823164,"chan":1,"rfch":1,"freq":868.300000,"stat":1,"modu":"LORA","datr":"SF12BW125","codr":"4/5","lsnr":-11.0,"rssi":-99,"size":29,"data":"gLMlASaAAgACkxKfpABcWadUiq93niqv77Ro2JM="}]}
INFO: [up] PUSH_ACK received in 61 ms
INFO: [down] PULL_RESP received  - token[171:94] :)

JSON down: {"txpk":{"imme":false,"tmst":728823164,"freq":869.525,"rfch":0,"powe":27,"modu":"LORA","datr":"SF9BW125","codr":"4/5","ipol":true,"size":12,"ncrc":true,"data":"YLMlASYgAgDHsKiy"}}
INFO: tx_start_delay=1495 (1495.500000) - (1497, bw_delay=1.500000, notch_delay=0.000000)
Info: packet will be sent without CRC
INFO: Enabling TX notch filter
59.61.99.2b.70.ef.a5.f.0.19.c.10.0.8.0.0.60.b3.25.1.26.20.2.0.c7.b0.a8.b2.end
INFO: [down] PULL_ACK received in 59 ms
JSON up: {"stat":{"time":"2018-06-22 19:13:32 GMT","rxnb":3,"rxok":3,"rxfw":3,"ackr":100.0,"dwnb":2,"txnb":2}}
INFO: [up] PUSH_ACK received in 62 ms
INFO: [down] PULL_RESP received  - token[142:6] :)

JSON down: {"txpk":{"imme":false,"tmst":723531196,"freq":869.525,"rfch":0,"powe":27,"modu":"LORA","datr":"SF9BW125","codr":"4/5","ipol":true,"size":12,"ncrc":true,"data":"YLMlASYgAQBGwLpT"}}
INFO: tx_start_delay=1495 (1495.500000) - (1497, bw_delay=1.500000, notch_delay=0.000000)
Info: packet will be sent without CRC
INFO: Enabling TX notch filter
59.61.99.2b.20.2f.e5.f.0.19.c.10.0.8.0.0.60.b3.25.1.26.20.1.0.46.c0.ba.53.end