Commit 549433c4 authored by Guillaume Gonnet's avatar Guillaume Gonnet
Browse files

Fix DR parameter in LoRaMac-node.

parent 6e7ad31f
......@@ -21,7 +21,7 @@ extern lorariot_mcps_t bm_payload;
// Transmission powers to test.
extern uint8_t bm_powers[];
extern uint8_t bm_power[];
// Datarates to test.
extern uint8_t bm_dr[];
......@@ -35,7 +35,7 @@ extern const provider_t *bm_pvd[];
/**
* @brief Encode message data to the payload.
* @param power_i Transmission power (index in `bm_powers`).
* @param power_i Transmission power (index in `bm_power`).
* @param dr_i Datarate (index in `bm_dr`).
* @param cr_i Coding rate (index in `bm_cr`).
*/
......
......@@ -48,10 +48,12 @@ void bm_encode_payload(uint8_t power_i, uint8_t dr_i, uint8_t cr_i)
// Retreive GPS data.
int32_t lat, lon;
int16_t alt;
gps_get_binary(&lat, &lon, &alt);
//gps_get_binary(&lat, &lon, &alt);
lat = lon = alt = 0;
// Retreive temperature.
uint16_t temp = bm_get_temperature();
(void)bm_get_temperature;
uint16_t temp = 0; // bm_get_temperature();
// Encode LoRa settings (on 8 bits).
......@@ -81,6 +83,6 @@ void bm_encode_payload(uint8_t power_i, uint8_t dr_i, uint8_t cr_i)
// Change MCPS parameters for the next frame.
bm_payload.code_rate = bm_cr[cr_i];
bm_payload.power = bm_powers[power_i];
bm_payload.power = bm_power[power_i];
bm_payload.dr = bm_dr[dr_i];
}
......@@ -11,6 +11,7 @@ This project is under the MIT license
#include "drivers/ds75lx.h"
#include "providers/providers.h"
#include "commands/commands.h"
#include "benchmark/benchmark.h"
#include <xtimer.h>
......@@ -20,15 +21,10 @@ This project is under the MIT license
// TMP: send a ping message.
static void send_message(void)
{
lorariot_mcps_t mcps = LORARIOT_UNCONFIRMED(DR_0);
mcps.power = 19;
mcps.buffer = (uint8_t *)"Ballon!";
mcps.len = 7;
mcps.code_rate = 4;
bm_encode_payload(9, 5, 0);
puts("Sending message ...");
pvd_send(&pvd_orange_cmd, &mcps);
pvd_send(&pvd_orange_cmd, &bm_payload);
puts("Message sent!");
}
......@@ -51,9 +47,8 @@ int main(void)
// xtimer_sleep(10);
while (true) {
for (int i = 0; i < 3; i++) {
send_message();
return 0;
xtimer_sleep(90);
//xtimer_usleep(50 * 1000); // 50 ms
}
}
......@@ -3331,7 +3331,7 @@ LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest )
phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy );
// Apply the minimum possible datarate.
// Some regions have limitations for the minimum datarate.
datarate = MAX( datarate, phyParam.Value );
datarate = MAX( datarate, (int8_t)phyParam.Value );
if( readyToSend == true )
{
......
......@@ -153,5 +153,17 @@ int lorariot_init(void)
&lorariot_primitives, &lorariot_callbacks, LORAMAC_REGION_IMAG);
lorariot_debug_status("init", status);
// Set some LoRaWAN parameters.
MibRequestConfirm_t mibReq;
mibReq.Type = MIB_ADR;
mibReq.Param.AdrEnable = false; // Disable ADR so the server won't change our DR.
LoRaMacMibSetRequestConfirm(&mibReq);
mibReq.Type = MIB_PUBLIC_NETWORK;
mibReq.Param.EnablePublicNetwork = true;
LoRaMacMibSetRequestConfirm(&mibReq);
return 0;
}
......@@ -52,7 +52,7 @@ void lorariot_event_cb(netdev_t *dev, netdev_event_t event);
void lorariot_debug_status_ev(const char *name, LoRaMacEventInfoStatus_t status);
void lorariot_debug_mcps(Mcps_t code);
#else
#define lorariot_debug_status(name, status) ((void)0)
#define lorariot_debug_status_ev(name, status) ((void)0)
#define lorariot_debug_mcps(code) ((void)0)
#define lorariot_debug_status(name, status) ((void)status)
#define lorariot_debug_status_ev(name, status) ((void)status)
#define lorariot_debug_mcps(code) ((void)code)
#endif
......@@ -79,8 +79,8 @@ static void _send_mcps(const lorariot_mcps_t *mcps)
req.Req.Confirmed.fPort = mcps->port;
req.Req.Confirmed.fBuffer = (uint8_t *)mcps->buffer;
req.Req.Confirmed.fBufferSize = mcps->len;
req.Req.Confirmed.NbTrials = mcps->nb_trials;
req.Req.Confirmed.Datarate = mcps->dr;
req.Req.Confirmed.NbTrials = mcps->nb_trials;
// If we use a port >= 32, we skip reception windows.
LoRaMacTestRxWindowsOn(mcps->port < 32);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment