Payload decoder problem

Hi friends
i have a problem with my datas:
i receive datas on my ttn gateway, but no datas decoder
it work few minutes and after it not work and after it work !! very bad to analyse data with http integration
do you have this problem and how fix it ?
thanks a lot and sorry for my bad english, i am french

New information, i just changed devadr and it works !
So my new question : Is there a maximum payload by device by day ?
Best regards all

No, but the server loads can result in the decoder timing out and not processing. The decoder is great for development, but ideally you take a direct feed like MQTT or HTTP Integration and decode on your own systems.

No, but there is an (as yet unenforced) maximum airtime per device per day. The TTN fair access policy states you are allowed 30 seconds of airtime for uplinks (and 10 downlinks including acks for confirmed uplinks) a day.
Behave socially and do not exceed those limits…

Hi, thanks for help
Actually i use http integration but it works only when decoder is ok.
So i understand in your message that it can work without payload decoder …
I must a php file on my server and this is this php file decode payload_raw ?
Thanks

Yes, without a decoder you don’t get your decoded fields, but you get the raw payload which is Base64 encoded of the byte array.

Doesn’t have to be PHP - it’s just an easy to get setup language on a publicly available web host.

I get raw payloads for multiple end nodes.

All devices are under one application. Looks like only one decoder script per application.

So one application per device, if the devices payload is to be decoded?

If the payloads are different and you need to decode the payload in the application at the TTN backend that would be the solution. In version 3 of the stack you will be able to specify the decoder at device level allowing different decoders for different devices within one application. (You can still define it at application level as well)

ONLY if you want TTN to do the decode. It is preferable that you do the decode, at which point you can choose how to identify different uplinks to use the different formats.

I though decoding at the TTN end was preferable because of the inefficiency of ASCII?

Over the radio, absolutely.

But once it’s at the application server and has been decrypted, it’s ASCII all the way - along with all the other JSON formatting that comes with the HTTP Integration.

And it has been seen on a number of occasions that the JS decoder service can timeout when under extreme load. So best to get the data out to TTN and then you can decode it after you’ve saved it to database or disk or similar.

Sorry for my come back
Do you have an example to decode myself.
here is what i made but not work :
With http integraiton, i send on my server (a web page on my web site)
This page is php, so i try to save raw_payload in database, and i do this
$raw_payload=$_GET[‘payload_raw’];
$sqlcommand to insert in database but $raw_payload is empty
Thanks for help

Starter file:

<?php

// Grab the PHP post
$data = file_get_contents("php://input");

// Decode it
$json = json_decode($data, true);


// Grab various values
$counter		= $json['counter'];
$coding_rate	= $json['metadata']['coding_rate'];
$data_rate		= $json['metadata']['data_rate'];
$requency		= $json['metadata']['frequency'];
$port			= $json['port'];

// Get the payload_raw which is Base64 encoded binary
$payload_raw	= $json['payload_raw'];

// Decode payload_raw in Base64, gives you binary so turn in to a hex string
$asHex			= strtoupper(bin2hex(base64_decode($payload_raw)));

// Example!
// This grabs the first two characters as hex and turns it in to a decimal number
$aValue			= hexdec(substr($asHex, 0, 2));


// Add to a text file, put it in a database, whatever you need ...

?>

Thanks !
but $asHex is always empty ($payload_raw is not empty)

Sorry, typo, the real code is a bit more complex:

$asHex = strtoupper(bin2hex(base64_decode($payload_raw)));

I’ve edited the original above as well.

It work !!
thanks a lot

i need time when gateway receice data, so i try this :

$date_time = $json[‘metadata’][‘gateways’][‘timesamp’];
but i think there is a mistake …

You can print_r($json) to see the whole message in JSON format.

But for the quick win, gateways is an array as there may be more than one:

$gateways = $json['metadata']['gateways'];
// Loop gateways
foreach($gateways as $gateway) {
	$gtw_id = $gateway['gtw_id'];
	$gtw_timestamp = $gateway['timestamp'];

	// etc, and then do something with the data

}

thanks a lot