Cleanup
This commit is contained in:
parent
c0b73f0155
commit
409e9d93d0
21
Modem/main.c
21
Modem/main.c
|
@ -27,11 +27,6 @@ static Serial ser; // Declare a serial interface struct
|
|||
#define ADC_CH 0 // Define which channel (pin) we want
|
||||
// for the ADC (this is A0 on arduino)
|
||||
|
||||
#define TEST_TX false // Whether we should send test packets
|
||||
// periodically, plus what to send:
|
||||
#define TEST_PACKET "Packet received. This is an ACK."
|
||||
#define TEST_TX_INTERVAL 10000L
|
||||
|
||||
|
||||
static uint8_t serialBuffer[MP1_MAX_DATA_SIZE]; // This is a buffer for incoming serial data
|
||||
|
||||
|
@ -50,13 +45,6 @@ static bool sertx = false; // Flag signifying whether it's time to send da
|
|||
static void mp1Callback(struct MP1Packet *packet) {
|
||||
if (SERIAL_DEBUG) {
|
||||
kfile_printf(&ser.fd, "%.*s\n", packet->dataLength, packet->data);
|
||||
|
||||
if (AUTOREPLY && packet->data[0]-128 == 'R' && packet->data[1]-128 == 'Q') {
|
||||
timer_delay(1000);
|
||||
|
||||
uint8_t output[sizeof(TEST_PACKET)] = TEST_PACKET;
|
||||
mp1Send(&mp1, output, sizeof(TEST_PACKET));
|
||||
}
|
||||
} else {
|
||||
for (unsigned long i = 0; i < packet->dataLength; i++) {
|
||||
kfile_putc(packet->data[i], &ser.fd);
|
||||
|
@ -174,15 +162,6 @@ int main(void)
|
|||
serialLen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Periodically send test data if we should do so
|
||||
if (SERIAL_DEBUG && TEST_TX && timer_clock() - start > ms_to_ticks(TEST_TX_INTERVAL)) {
|
||||
// Reset the timer counter;
|
||||
start = timer_clock();
|
||||
// And send a test packet!
|
||||
uint8_t output[sizeof(TEST_PACKET)] = TEST_PACKET;
|
||||
mp1Send(&mp1, output, sizeof(TEST_PACKET));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -544,6 +544,7 @@ void mp1Init(MP1 *mp1, KFile *modem, mp1_callback_t callback) {
|
|||
// number, and if it is less than
|
||||
// MP1_P_PERSISTENCE, we transmit.
|
||||
bool mp1CarrierSense(MP1 *mp1) {
|
||||
if (MP1_ENABLE_CSMA) {
|
||||
if (mp1->randomSeed == 0) {
|
||||
mp1->randomSeed = timer_clock();
|
||||
srand(mp1->randomSeed);
|
||||
|
@ -560,6 +561,9 @@ bool mp1CarrierSense(MP1 *mp1) {
|
|||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// A handy debug function that can determine
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
// These two parameters are used for
|
||||
// P-persistent CSMA
|
||||
#define MP1_ENABLE_CSMA false
|
||||
#define MP1_SETTLE_TIME 100UL // The minimum wait time before considering sending
|
||||
#define MP1_P_PERSISTENCE 85UL // The probability (between 0 and 255) for sending
|
||||
#define MP1_TXDELAY 150UL // Delay between turning on the transmitter and sending
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define VERS_BUILD 1570
|
||||
#define VERS_BUILD 1576
|
||||
#define VERS_HOST "shard"
|
||||
|
|
Loading…
Reference in New Issue