diasbale unused channels

This commit is contained in:
Dominik Kuhn 2023-12-12 15:46:13 +01:00
parent 31950351c0
commit 70df292948
2 changed files with 26 additions and 5 deletions

View File

@ -102,8 +102,18 @@ void initfunc (osjob_t* j) {
LMIC.dn2Dr = DR_SF9; LMIC.dn2Dr = DR_SF9;
// prevent some downlink messages, TTN advanced setup is set to the default 5 // prevent some downlink messages, TTN advanced setup is set to the default 5
LMIC.rxDelay = 5; LMIC.rxDelay = 5;
LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI);
int channel = 0;
for(int i=0; i<9; i++) { // For EU; for US use i<71
if(i != channel) {
LMIC_disableChannel(i);
}
}
// Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library) // Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(DR_SF12, 14); LMIC_setDrTxpow(DR_SF7, 14);
#else #else
// start joining // start joining
LMIC_startJoining(); LMIC_startJoining();
@ -124,7 +134,8 @@ static osjob_t reportjob;
static void reportfunc (osjob_t* j) { static void reportfunc (osjob_t* j) {
// read sensor // read sensor
u2_t val = readsensor(); u2_t val = readsensor();
debug_val("val = ", val); debug_int( os_getTime() );
debug_val(": val = ", val);
// prepare and schedule data for transmission // prepare and schedule data for transmission
LMIC.frame[0] = val << 8; LMIC.frame[0] = val << 8;
LMIC.frame[1] = val; LMIC.frame[1] = val;
@ -155,9 +166,10 @@ void onEvent (ev_t ev) {
debug_str("try joining\r\n"); debug_str("try joining\r\n");
break; break;
case EV_JOINED: case EV_JOINED:
debug_led(1); debug_str("joined\r\n");
// debug_led(1);
// kick-off periodic sensor job // kick-off periodic sensor job
reportfunc(&reportjob); // reportfunc(&reportjob);
break; break;
case EV_JOIN_FAILED: case EV_JOIN_FAILED:
debug_str("join failed\r\n"); debug_str("join failed\r\n");

9
test/serial_test.py Normal file
View File

@ -0,0 +1,9 @@
import serial
from datetime import datetime
with serial.Serial('/dev/ttyUSB0', 9600) as ser:
while(True):
line = ser.readline()
now = datetime.now()
print(now.strftime("%d/%m/%Y %H:%M:%S") + ': ' + line.decode('utf-8'))