mirror of
https://github.com/thelsing/knx.git
synced 2025-10-12 11:15:54 +02:00
Continue cleanup
This commit is contained in:
parent
85c3f304f4
commit
d7ee4b8b85
@ -15,7 +15,8 @@
|
|||||||
#include "knx/bits.h"
|
#include "knx/bits.h"
|
||||||
#include "cc1310_platform.h"
|
#include "cc1310_platform.h"
|
||||||
|
|
||||||
#define printf(args...) (SEGGER_RTT_printf(0, args))
|
//#define printf(args...) (SEGGER_RTT_printf(0, args))
|
||||||
|
#define PRINT_RTT
|
||||||
|
|
||||||
volatile uint32_t CC1310Platform::msCounter = 0;
|
volatile uint32_t CC1310Platform::msCounter = 0;
|
||||||
|
|
||||||
@ -64,8 +65,8 @@ void CC1310Platform::InitNVS()
|
|||||||
|
|
||||||
NVS_Attrs attrs;
|
NVS_Attrs attrs;
|
||||||
NVS_getAttrs(nvsHandle, &attrs);
|
NVS_getAttrs(nvsHandle, &attrs);
|
||||||
printf("NVS flash size: %d\r\n", attrs.regionSize);
|
print("NVS flash size: "); println((int)attrs.regionSize);
|
||||||
printf("NVS flash sector size: %d\r\n", attrs.sectorSize);
|
print("NVS flash sector size: "); println((int)attrs.sectorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
CC1310Platform::CC1310Platform()
|
CC1310Platform::CC1310Platform()
|
||||||
@ -99,9 +100,12 @@ void CC1310Platform::init()
|
|||||||
uint8_t* CC1310Platform::getEepromBuffer(uint16_t size)
|
uint8_t* CC1310Platform::getEepromBuffer(uint16_t size)
|
||||||
{
|
{
|
||||||
if(size > EEPROM_EMULATION_SIZE)
|
if(size > EEPROM_EMULATION_SIZE)
|
||||||
|
{
|
||||||
fatalError();
|
fatalError();
|
||||||
#if 1
|
}
|
||||||
|
|
||||||
NVS_read(nvsHandle, 0, (void *) _NVS_buffer, size);
|
NVS_read(nvsHandle, 0, (void *) _NVS_buffer, size);
|
||||||
|
|
||||||
for (int i=0; i<size; i++)
|
for (int i=0; i<size; i++)
|
||||||
{
|
{
|
||||||
if (_NVS_buffer[i] != 0)
|
if (_NVS_buffer[i] != 0)
|
||||||
@ -109,7 +113,7 @@ uint8_t* CC1310Platform::getEepromBuffer(uint16_t size)
|
|||||||
return _NVS_buffer;
|
return _NVS_buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
memset(_NVS_buffer, 0xff, size);
|
memset(_NVS_buffer, 0xff, size);
|
||||||
|
|
||||||
return _NVS_buffer;
|
return _NVS_buffer;
|
||||||
@ -118,18 +122,19 @@ uint8_t* CC1310Platform::getEepromBuffer(uint16_t size)
|
|||||||
void CC1310Platform::commitToEeprom()
|
void CC1310Platform::commitToEeprom()
|
||||||
{
|
{
|
||||||
println("CC1310Platform::commitToEeprom() ...");
|
println("CC1310Platform::commitToEeprom() ...");
|
||||||
#if 1
|
|
||||||
int_fast16_t res = NVS_write(nvsHandle, 0, (void *)_NVS_buffer, EEPROM_EMULATION_SIZE, NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
|
int_fast16_t result = NVS_write(nvsHandle, 0, (void *)_NVS_buffer, EEPROM_EMULATION_SIZE, NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
|
||||||
if (res != NVS_STATUS_SUCCESS)
|
|
||||||
|
if (result != NVS_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
printf("Error writing to NVS, ret = %d\n", res);
|
print("Error writing to NVS, result: "); println(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
println("NVS successfully written\n");
|
println("NVS successfully written");
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1310Platform::restart()
|
void CC1310Platform::restart()
|
||||||
@ -143,7 +148,6 @@ void CC1310Platform::fatalError()
|
|||||||
println("A fatal error occured. Stopped.");
|
println("A fatal error occured. Stopped.");
|
||||||
while(true)
|
while(true)
|
||||||
{}
|
{}
|
||||||
//restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CC1310Platform::millis()
|
uint32_t CC1310Platform::millis()
|
||||||
@ -181,58 +185,65 @@ void delayMicroseconds (unsigned int howLong)
|
|||||||
ClockP_usleep(howLong);
|
ClockP_usleep(howLong);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
size_t write(uint8_t c)
|
||||||
/* Buffer size for string operations (e.g. snprintf())*/
|
|
||||||
#define MAX_STRBUF_SIZE 100
|
|
||||||
|
|
||||||
int UART_printf(const char * fmt, ...)
|
|
||||||
{
|
{
|
||||||
char s[MAX_STRBUF_SIZE];
|
#if defined(PRINT_UART)
|
||||||
va_list ap;
|
uint8_t buffer[1] = {c};
|
||||||
va_start(ap, fmt);
|
return UART_write(uart, buffer, sizeof(buffer));
|
||||||
int n = vsnprintf(s, sizeof(s), fmt, ap);
|
#elif defined (PRINT_RTT)
|
||||||
va_end(ap);
|
return SEGGER_RTT_PutChar(0, (char)c);
|
||||||
if (uart)
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
size_t write(const uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
size_t n = 0;
|
||||||
|
while (size--)
|
||||||
{
|
{
|
||||||
UART_write(uart, s, strlen(s));
|
if (write(*buffer++))
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
size_t write(const uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
#if defined(PRINT_UART)
|
||||||
|
return UART_write(uart, buffer, size);
|
||||||
|
#elif defined (PRINT_RTT)
|
||||||
|
return SEGGER_RTT_Write(0, buffer, size);
|
||||||
|
#else
|
||||||
|
return size;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t write(const char *buffer, size_t size)
|
||||||
|
{
|
||||||
|
return write((const uint8_t *)buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
void print(const char* s)
|
void print(const char* s)
|
||||||
{
|
{
|
||||||
if (uart)
|
if (s == NULL)
|
||||||
{
|
{
|
||||||
UART_write(uart, s, strlen(s));
|
return;
|
||||||
}
|
}
|
||||||
|
write(s, strlen(s));
|
||||||
}
|
}
|
||||||
|
void print(char c)
|
||||||
void print(int num, int base)
|
|
||||||
{
|
{
|
||||||
char s[MAX_STRBUF_SIZE];
|
write(c);
|
||||||
if (base == HEX)
|
|
||||||
snprintf(s, sizeof(s),"%X", num);
|
|
||||||
else
|
|
||||||
snprintf(s, sizeof(s),"%d", num);
|
|
||||||
if (uart)
|
|
||||||
{
|
|
||||||
UART_write(uart, s, strlen(s));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
int printf(const char * fmt, ...)
|
|
||||||
{
|
|
||||||
char s[MAX_STRBUF_SIZE];
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
int n = vsnprintf(s, sizeof(s), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
SEGGER_RTT_printf(0, s, strlen(s));
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void printUint64(uint64_t value, int base = DEC)
|
void printUint64(uint64_t value, int base = DEC)
|
||||||
{
|
{
|
||||||
@ -251,6 +262,106 @@ void printUint64(uint64_t value, int base = DEC)
|
|||||||
print(str);
|
print(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print(long long num, int base)
|
||||||
|
{
|
||||||
|
if (base == 0)
|
||||||
|
{
|
||||||
|
write(num);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (base == 10)
|
||||||
|
{
|
||||||
|
if (num < 0)
|
||||||
|
{
|
||||||
|
print('-');
|
||||||
|
num = -num;
|
||||||
|
printUint64(num, 10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printUint64(num, 10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printUint64(num, base);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned long long num, int base)
|
||||||
|
{
|
||||||
|
if (base == 0)
|
||||||
|
{
|
||||||
|
write(num);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printUint64(num, base);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned char num, int base)
|
||||||
|
{
|
||||||
|
print((unsigned long long)num, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(int num, int base)
|
||||||
|
{
|
||||||
|
print((long long)num, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned int num, int base)
|
||||||
|
{
|
||||||
|
print((unsigned long long)num, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(long num, int base)
|
||||||
|
{
|
||||||
|
print((long long)num, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned long num, int base)
|
||||||
|
{
|
||||||
|
print((unsigned long long)num, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned char num)
|
||||||
|
{
|
||||||
|
print(num, DEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(int num)
|
||||||
|
{
|
||||||
|
print(num, DEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned int num)
|
||||||
|
{
|
||||||
|
print(num, DEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(long num)
|
||||||
|
{
|
||||||
|
print(num, DEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned long num)
|
||||||
|
{
|
||||||
|
print(num, DEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(long long num)
|
||||||
|
{
|
||||||
|
print(num, DEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(unsigned long long num)
|
||||||
|
{
|
||||||
|
print(num, DEC);
|
||||||
|
}
|
||||||
|
|
||||||
void printFloat(double number, uint8_t digits)
|
void printFloat(double number, uint8_t digits)
|
||||||
{
|
{
|
||||||
if (std::isnan(number))
|
if (std::isnan(number))
|
||||||
@ -265,12 +376,12 @@ void printFloat(double number, uint8_t digits)
|
|||||||
}
|
}
|
||||||
if (number > 4294967040.0)
|
if (number > 4294967040.0)
|
||||||
{
|
{
|
||||||
print ("ovf"); // constant determined empirically
|
print("ovf"); // constant determined empirically
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (number <-4294967040.0)
|
if (number <-4294967040.0)
|
||||||
{
|
{
|
||||||
print ("ovf"); // constant determined empirically
|
print("ovf"); // constant determined empirically
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +402,7 @@ void printFloat(double number, uint8_t digits)
|
|||||||
// Extract the integer part of the number and print it
|
// Extract the integer part of the number and print it
|
||||||
unsigned long int_part = (unsigned long)number;
|
unsigned long int_part = (unsigned long)number;
|
||||||
double remainder = number - (double)int_part;
|
double remainder = number - (double)int_part;
|
||||||
print(int_part);
|
printUint64(int_part);
|
||||||
|
|
||||||
// Print the decimal point, but only if there are digits beyond
|
// Print the decimal point, but only if there are digits beyond
|
||||||
if (digits > 0)
|
if (digits > 0)
|
||||||
@ -304,107 +415,30 @@ void printFloat(double number, uint8_t digits)
|
|||||||
{
|
{
|
||||||
remainder *= 10.0;
|
remainder *= 10.0;
|
||||||
unsigned int toPrint = (unsigned int)(remainder);
|
unsigned int toPrint = (unsigned int)(remainder);
|
||||||
print(toPrint);
|
printUint64(toPrint);
|
||||||
remainder -= toPrint;
|
remainder -= toPrint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(const char* s)
|
void print(double num, int digits = 2)
|
||||||
{
|
{
|
||||||
printf("%s", s);
|
printFloat(num, digits);
|
||||||
}
|
|
||||||
void print(char c)
|
|
||||||
{
|
|
||||||
printf("%c", c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(unsigned char num)
|
void println(void)
|
||||||
{
|
{
|
||||||
print(num, DEC);
|
print("\r\n");
|
||||||
}
|
|
||||||
|
|
||||||
void print(unsigned char num, int base)
|
|
||||||
{
|
|
||||||
if (base == HEX)
|
|
||||||
printf("%X", num);
|
|
||||||
else
|
|
||||||
printf("%d", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(int num)
|
|
||||||
{
|
|
||||||
print(num, DEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(int num, int base)
|
|
||||||
{
|
|
||||||
if (base == HEX)
|
|
||||||
printf("%X", num);
|
|
||||||
else
|
|
||||||
printf("%d", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(unsigned int num)
|
|
||||||
{
|
|
||||||
print(num, DEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(unsigned int num, int base)
|
|
||||||
{
|
|
||||||
if (base == HEX)
|
|
||||||
printf("%X", num);
|
|
||||||
else
|
|
||||||
printf("%d", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(long num)
|
|
||||||
{
|
|
||||||
print(num, DEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(long num, int base)
|
|
||||||
{
|
|
||||||
if (base == HEX)
|
|
||||||
printf("%lX", num);
|
|
||||||
else
|
|
||||||
printf("%ld", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(unsigned long num)
|
|
||||||
{
|
|
||||||
print(num, DEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(unsigned long num, int base)
|
|
||||||
{
|
|
||||||
if (base == HEX)
|
|
||||||
printf("%lX", num);
|
|
||||||
else
|
|
||||||
printf("%ld", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(unsigned long long num)
|
|
||||||
{
|
|
||||||
printUint64(num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(unsigned long long num, int base)
|
|
||||||
{
|
|
||||||
printUint64(num, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(double num)
|
|
||||||
{
|
|
||||||
printf("%f", num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(const char* s)
|
void println(const char* s)
|
||||||
{
|
{
|
||||||
printf("%s\n", s);
|
print(s);
|
||||||
|
println();
|
||||||
}
|
}
|
||||||
void println(char c)
|
void println(char c)
|
||||||
{
|
{
|
||||||
printf("%c\n", c);
|
print(c);
|
||||||
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(unsigned char num)
|
void println(unsigned char num)
|
||||||
@ -414,10 +448,8 @@ void println(unsigned char num)
|
|||||||
|
|
||||||
void println(unsigned char num, int base)
|
void println(unsigned char num, int base)
|
||||||
{
|
{
|
||||||
if (base == HEX)
|
print(num, base);
|
||||||
printf("%X\n", num);
|
println();
|
||||||
else
|
|
||||||
printf("%d\n", num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(int num)
|
void println(int num)
|
||||||
@ -427,10 +459,8 @@ void println(int num)
|
|||||||
|
|
||||||
void println(int num, int base)
|
void println(int num, int base)
|
||||||
{
|
{
|
||||||
if (base == HEX)
|
print(num, base);
|
||||||
printf("%X\n", num);
|
println();
|
||||||
else
|
|
||||||
printf("%d\n", num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(unsigned int num)
|
void println(unsigned int num)
|
||||||
@ -440,10 +470,8 @@ void println(unsigned int num)
|
|||||||
|
|
||||||
void println(unsigned int num, int base)
|
void println(unsigned int num, int base)
|
||||||
{
|
{
|
||||||
if (base == HEX)
|
print(num, base);
|
||||||
printf("%X\n", num);
|
println();
|
||||||
else
|
|
||||||
printf("%d\n", num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(long num)
|
void println(long num)
|
||||||
@ -453,10 +481,8 @@ void println(long num)
|
|||||||
|
|
||||||
void println(long num, int base)
|
void println(long num, int base)
|
||||||
{
|
{
|
||||||
if (base == HEX)
|
print(num, base);
|
||||||
printf("%lX\n", num);
|
println();
|
||||||
else
|
|
||||||
printf("%ld\n", num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(unsigned long num)
|
void println(unsigned long num)
|
||||||
@ -466,37 +492,31 @@ void println(unsigned long num)
|
|||||||
|
|
||||||
void println(unsigned long num, int base)
|
void println(unsigned long num, int base)
|
||||||
{
|
{
|
||||||
if (base == HEX)
|
print(num, base);
|
||||||
printf("%lX\n", num);
|
println();
|
||||||
else
|
|
||||||
printf("%ld\n", num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(unsigned long long num)
|
void println(unsigned long long num)
|
||||||
{
|
{
|
||||||
printUint64(num);
|
println(num, DEC);
|
||||||
println("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(unsigned long long num, int base)
|
void println(unsigned long long num, int base)
|
||||||
{
|
{
|
||||||
printUint64(num, base);
|
printUint64(num, base);
|
||||||
println("");
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void println(double num, int digits = 2)
|
||||||
|
{
|
||||||
|
print(num, digits);
|
||||||
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
void println(double num)
|
void println(double num)
|
||||||
{
|
{
|
||||||
printf("%f\n", num);
|
// default: print 10 digits
|
||||||
}
|
println(num, 10);
|
||||||
|
|
||||||
void println(double num, int places)
|
|
||||||
{
|
|
||||||
printf("%f\n", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void println(void)
|
|
||||||
{
|
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t digitalRead(uint32_t dwPin)
|
uint32_t digitalRead(uint32_t dwPin)
|
||||||
|
@ -182,9 +182,6 @@ extern void delayMicroseconds (unsigned int howLong);
|
|||||||
#define TX_ACTIVE 4
|
#define TX_ACTIVE 4
|
||||||
#define TX_END 5
|
#define TX_END 5
|
||||||
|
|
||||||
// Calculate the real packet size out of the L-field of FT3 frame data. See KNX-RF spec. 3.2.5 Data Link Layer frame format
|
|
||||||
#define PACKET_SIZE(lField) ((((lField - 10 /*size of first pkt*/))/16 + 2 /*CRC in first pkt */) * 2 /*to bytes*/ +lField + 1 /*size of len byte*/)
|
|
||||||
|
|
||||||
class RfDataLinkLayer;
|
class RfDataLinkLayer;
|
||||||
|
|
||||||
class RfPhysicalLayerCC1101 : public RfPhysicalLayer
|
class RfPhysicalLayerCC1101 : public RfPhysicalLayer
|
||||||
|
@ -44,7 +44,7 @@ static volatile int err;
|
|||||||
|
|
||||||
static void RxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
|
static void RxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
|
||||||
{
|
{
|
||||||
if ((e & RF_EventNDataWritten) /*&& (packetStartTime == 0)*/)
|
if ((e & RF_EventNDataWritten) && (packetStartTime == 0))
|
||||||
{
|
{
|
||||||
// pDataEntry->rxData contains the first byte of the received packet.
|
// pDataEntry->rxData contains the first byte of the received packet.
|
||||||
// Just get the address to get the start address of the receive buffer
|
// Just get the address to get the start address of the receive buffer
|
||||||
@ -179,9 +179,12 @@ void RfPhysicalLayerCC1310::loop()
|
|||||||
{
|
{
|
||||||
case TX_START:
|
case TX_START:
|
||||||
{
|
{
|
||||||
|
uint8_t *sendBuffer {nullptr};
|
||||||
|
uint16_t sendBufferLength {0};
|
||||||
|
|
||||||
println("TX_START...");
|
println("TX_START...");
|
||||||
_rfDataLinkLayer.loadNextTxFrame(&sendBuffer, &sendBufferLength);
|
_rfDataLinkLayer.loadNextTxFrame(&sendBuffer, &sendBufferLength);
|
||||||
pktLen = PACKET_SIZE(sendBuffer[0]);
|
uint16_t pktLen = PACKET_SIZE(sendBuffer[0]);
|
||||||
|
|
||||||
if (pktLen != sendBufferLength)
|
if (pktLen != sendBufferLength)
|
||||||
{
|
{
|
||||||
@ -274,25 +277,27 @@ void RfPhysicalLayerCC1310::loop()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print("nRxOk = ");println(rxStatistics.nRxOk); // Number of packets that have been received with payload, CRC OK and not ignored
|
|
||||||
print("nRxNok = ");println(rxStatistics.nRxNok); // Number of packets that have been received with CRC error
|
|
||||||
print("nRxIgnored = ");println(rxStatistics.nRxIgnored); // Number of packets that have been received with CRC OK and ignored due to address mismatch
|
|
||||||
print("nRxStopped = ");println(rxStatistics.nRxStopped); // Number of packets not received due to illegal length or address mismatch with pktConf.filterOp = 1
|
|
||||||
print("nRxBufFull = ");println(rxStatistics.nRxBufFull); // Number of packets that have been received and discarded due to lack of buffer space
|
|
||||||
print("lastRssi = ");println(rxStatistics.lastRssi); // RSSI of last received packet
|
|
||||||
|
|
||||||
// add CRC sizes for received blocks, but do not add the length of the L-field (1 byte) itself
|
// add CRC sizes for received blocks, but do not add the length of the L-field (1 byte) itself
|
||||||
packetLength = PACKET_SIZE(pDataEntry->rxData);
|
packetLength = PACKET_SIZE(pDataEntry->rxData);
|
||||||
packetDataPointer = (uint8_t *) &pDataEntry->rxData;
|
packetDataPointer = (uint8_t *) &pDataEntry->rxData;
|
||||||
|
|
||||||
|
// Sanity check: the partial data entry index points to the next free location in the partial RX buffer
|
||||||
if (packetLength != (pDataEntry->nextIndex - 1))
|
if (packetLength != (pDataEntry->nextIndex - 1))
|
||||||
{
|
{
|
||||||
println("Mismatch between packetLength and pDataEntry->nextIndex: ");
|
println("Mismatch between packetLength and pDataEntry->nextIndex: ");
|
||||||
print("packetLength = ");print(packetLength);
|
print("packetLength = ");print(packetLength);
|
||||||
print(", pDataEntry->nextIndex = ");println(pDataEntry->nextIndex);
|
print(", pDataEntry->nextIndex = ");println(pDataEntry->nextIndex);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
print("nRxOk = ");println(rxStatistics.nRxOk); // Number of packets that have been received with payload, CRC OK and not ignored
|
||||||
|
print("nRxNok = ");println(rxStatistics.nRxNok); // Number of packets that have been received with CRC error
|
||||||
|
print("nRxIgnored = ");println(rxStatistics.nRxIgnored); // Number of packets that have been received with CRC OK and ignored due to address mismatch
|
||||||
|
print("nRxStopped = ");println(rxStatistics.nRxStopped); // Number of packets not received due to illegal length or address mismatch with pktConf.filterOp = 1
|
||||||
|
print("nRxBufFull = ");println(rxStatistics.nRxBufFull); // Number of packets that have been received and discarded due to lack of buffer space
|
||||||
|
*/
|
||||||
|
|
||||||
printHex("RX: ", packetDataPointer, packetLength);
|
print("RSSI: ");print(rxStatistics.lastRssi); // RSSI of last received packet
|
||||||
|
printHex(" - RX: ", packetDataPointer, packetLength);
|
||||||
_rfDataLinkLayer.frameBytesReceived(packetDataPointer, packetLength);
|
_rfDataLinkLayer.frameBytesReceived(packetDataPointer, packetLength);
|
||||||
}
|
}
|
||||||
_loopState = RX_START;
|
_loopState = RX_START;
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
#define RX_PACKET_TIMEOUT 20 // Wait 20ms for packet reception to complete
|
#define RX_PACKET_TIMEOUT 20 // Wait 20ms for packet reception to complete
|
||||||
|
|
||||||
// Calculate the real packet size out of the L-field of FT3 frame data. See KNX-RF spec. 3.2.5 Data Link Layer frame format
|
|
||||||
#define PACKET_SIZE(lField) ((((lField - 10 /*size of first pkt*/))/16 + 2 /*CRC in first pkt */) * 2 /*to bytes*/ +lField + 1 /*size of len byte*/)
|
|
||||||
|
|
||||||
// loop states
|
// loop states
|
||||||
#define RX_START 0
|
#define RX_START 0
|
||||||
#define RX_ACTIVE 1
|
#define RX_ACTIVE 1
|
||||||
@ -34,10 +31,6 @@ class RfPhysicalLayerCC1310 : public RfPhysicalLayer
|
|||||||
void setOutputPowerLevel(int8_t dBm);
|
void setOutputPowerLevel(int8_t dBm);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t pktLen {0};
|
|
||||||
uint8_t *sendBuffer {0};
|
|
||||||
uint16_t sendBufferLength {0};
|
|
||||||
|
|
||||||
uint8_t _loopState = RX_START;
|
uint8_t _loopState = RX_START;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user