diasbale unused channels
This commit is contained in:
parent
31950351c0
commit
70df292948
22
src/main.c
22
src/main.c
@ -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");
|
||||||
@ -207,7 +219,7 @@ void onEvent (ev_t ev) {
|
|||||||
debug_str("EV_LINK_ALIVE\r\n");
|
debug_str("EV_LINK_ALIVE\r\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debug_str("Unknown event\r\n");
|
debug_str("Unknown event\r\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
test/serial_test.py
Normal file
9
test/serial_test.py
Normal 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'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user