mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 06:06:23 +01:00
Simplified (lower power) channel scanning, only 11/15/20/25/26/27
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -23,7 +23,7 @@ $stackdisturbed = false;
|
||||
$mem = checkmem();
|
||||
while(1){
|
||||
$errlist = array();
|
||||
exec("make BUILD=zbs154v033 CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
|
||||
exec("make BUILD=zbs29v033 CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
|
||||
if(checkmem()!=$mem){
|
||||
$stackdisturbed = true;
|
||||
echo "Stack size was $mem, is now ".checkmem()." !!!\n";
|
||||
|
||||
31
zbs243_Tag_FW/main.c
Normal file → Executable file
31
zbs243_Tag_FW/main.c
Normal file → Executable file
@@ -90,28 +90,25 @@ void displayLoop() {
|
||||
}
|
||||
|
||||
uint8_t showChannelSelect() { // returns 0 if no accesspoints were found
|
||||
uint8_t __xdata result[16];
|
||||
uint8_t __xdata result[sizeof(channelList)];
|
||||
memset(result, 0, sizeof(result));
|
||||
showScanningWindow();
|
||||
drawNoWait();
|
||||
powerUp(INIT_RADIO);
|
||||
for (uint8_t i = 0; i < 5; i++) {
|
||||
for (uint8_t c = 11; c < 27; c++) {
|
||||
if (detectAP(c)) {
|
||||
if (mLastLqi > result[c - 11]) result[c - 11] = mLastLqi;
|
||||
pr("Channel: %d - LQI: %d RSSI %d\n", c, mLastLqi, mLastRSSI);
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
for (uint8_t c = 0; c < sizeof(channelList); c++) {
|
||||
if (detectAP(channelList[c])) {
|
||||
if (mLastLqi > result[c]) result[c] = mLastLqi;
|
||||
pr("Channel: %d - LQI: %d RSSI %d\n", channelList[c], mLastLqi, mLastRSSI);
|
||||
}
|
||||
}
|
||||
epdWaitRdy();
|
||||
for (uint8_t c = 0; c < 16; c++) {
|
||||
addScanResult(11 + c, result[c]);
|
||||
}
|
||||
drawNoWait();
|
||||
}
|
||||
|
||||
uint8_t __xdata highestLqi = 0;
|
||||
uint8_t __xdata highestSlot = 0;
|
||||
for (uint8_t c = 0; c < sizeof(result); c++) {
|
||||
if (result[c] > highestLqi) {
|
||||
highestSlot = c + 11;
|
||||
highestSlot = channelList[c];
|
||||
highestLqi = result[c];
|
||||
}
|
||||
}
|
||||
@@ -123,18 +120,20 @@ uint8_t showChannelSelect() { // returns 0 if no accesspoints were found
|
||||
uint8_t channelSelect() { // returns 0 if no accesspoints were found
|
||||
uint8_t __xdata result[16];
|
||||
memset(result, 0, sizeof(result));
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
for (uint8_t c = 11; c < 27; c++) {
|
||||
if (detectAP(c)) {
|
||||
if (mLastLqi > result[c - 11]) result[c - 11] = mLastLqi;
|
||||
for (uint8_t c = 0; c < sizeof(channelList); c++) {
|
||||
if (detectAP(channelList[c])) {
|
||||
if (mLastLqi > result[c]) result[c] = mLastLqi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t __xdata highestLqi = 0;
|
||||
uint8_t __xdata highestSlot = 0;
|
||||
for (uint8_t c = 0; c < sizeof(result); c++) {
|
||||
if (result[c] > highestLqi) {
|
||||
highestSlot = c + 11;
|
||||
highestSlot = channelList[c];
|
||||
highestLqi = result[c];
|
||||
}
|
||||
}
|
||||
|
||||
12
zbs243_Tag_FW/userinterface.c
Normal file → Executable file
12
zbs243_Tag_FW/userinterface.c
Normal file → Executable file
@@ -210,9 +210,9 @@ void showScanningWindow() {
|
||||
epdPrintBegin(2, 275, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
|
||||
epdpr("Scanning for APs");
|
||||
epdPrintEnd();
|
||||
epdPrintBegin(40, 262, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_RED);
|
||||
epdpr("Channel - Quality");
|
||||
epdPrintEnd();
|
||||
//epdPrintBegin(40, 262, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_RED);
|
||||
//epdpr("Channel - Quality");
|
||||
//epdPrintEnd();
|
||||
loadRawBitmap(receive, 36, 24, EPD_COLOR_BLACK);
|
||||
#endif
|
||||
#if (SCREEN_WIDTH == 152) // 1.54"
|
||||
@@ -226,9 +226,9 @@ void showScanningWindow() {
|
||||
epdpr("Scanning for APs");
|
||||
epdPrintEnd();
|
||||
|
||||
epdPrintBegin(2, 40, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED);
|
||||
epdpr("Channel - Quality");
|
||||
epdPrintEnd();
|
||||
//epdPrintBegin(2, 40, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED);
|
||||
//epdpr("Channel - Quality");
|
||||
//epdPrintEnd();
|
||||
loadRawBitmap(receive, 320, 125, EPD_COLOR_BLACK);
|
||||
#endif
|
||||
|
||||
|
||||
2
zbs243_shared/soc/radioCommon.h
Normal file → Executable file
2
zbs243_shared/soc/radioCommon.h
Normal file → Executable file
@@ -7,7 +7,7 @@
|
||||
|
||||
//radio cfg
|
||||
#define RADIO_FIRST_CHANNEL (11) //2.4-GHz channels start at 11
|
||||
#define RADIO_NUM_CHANNELS (15)
|
||||
#define RADIO_NUM_CHANNELS (16)
|
||||
|
||||
|
||||
#define RADIO_MAX_PACKET_LEN (125) //useful payload, not including the crc
|
||||
|
||||
24
zbs243_shared/soc/zbs243/radio.c
Normal file → Executable file
24
zbs243_shared/soc/zbs243/radio.c
Normal file → Executable file
@@ -13,6 +13,8 @@ static volatile uint8_t __xdata mRxBufs[RX_BUFFER_NUM][RX_BUFFER_SIZE];
|
||||
static volatile uint8_t __xdata mLastRSSI, mLastTxedSeq, mRxOn, mRxBufNextR, mRxBufNextW, mRxBufNumFree;
|
||||
static volatile __bit mAckTimePassed, mGotAck;
|
||||
|
||||
const uint8_t __code channelList[6] = {11, 15, 20, 25, 26, 27};
|
||||
|
||||
// some things look like: https://www.ti.com/lit/ds/symlink/cc2430.pdf
|
||||
// maybe a licensed and heavily modified version?
|
||||
|
||||
@@ -30,7 +32,6 @@ void RF_IRQ1(void) __interrupt(4) {
|
||||
// radio will report ACK if we (1) got an ack or (2) sent a packet that did not require it
|
||||
mAckTimePassed = true;
|
||||
mGotAck = !!(cause & 0x10);
|
||||
|
||||
}
|
||||
if (cause & 0x20) { // radio has RXed a packet into its internal buffer. vet it quickly and set up DMA
|
||||
|
||||
@@ -144,11 +145,11 @@ bool radioTx(const void __xdata *packetP) // waits for tx end
|
||||
|
||||
CFGPAGE = bkp;
|
||||
|
||||
//RADIO_unk_C8 = 0xff; /// stock fw does this but seems unnecessary
|
||||
// RADIO_unk_C8 = 0xff; /// stock fw does this but seems unnecessary
|
||||
|
||||
// wait for tx to start
|
||||
wait = 0;
|
||||
wait--;
|
||||
wait--;
|
||||
do {
|
||||
if (RADIO_curRfState & 0x80)
|
||||
break;
|
||||
@@ -158,12 +159,12 @@ bool radioTx(const void __xdata *packetP) // waits for tx end
|
||||
if (wait) {
|
||||
while (!mAckTimePassed)
|
||||
;
|
||||
return true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//RADIO_unk_C8 = 0x7f; /// stock fw does this but seems unnecessary
|
||||
// RADIO_unk_C8 = 0x7f; /// stock fw does this but seems unnecessary
|
||||
}
|
||||
|
||||
void radioRxAckReset(void) {
|
||||
@@ -212,13 +213,10 @@ void radioSetTxPower(int8_t dBm) {
|
||||
}
|
||||
|
||||
void radioSetChannel(uint8_t ch) {
|
||||
static const uint8_t perChannelSetting1[] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33, 0x33, 0x33};
|
||||
static const uint8_t perChannelSetting2[] = {4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2};
|
||||
static const uint8_t perChannelSetting1[] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33};
|
||||
static const uint8_t perChannelSetting2[] = {4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2};
|
||||
|
||||
if (ch < RADIO_FIRST_CHANNEL || ch >= RADIO_FIRST_CHANNEL + RADIO_NUM_CHANNELS)
|
||||
return;
|
||||
|
||||
RADIO_channel = ch; // configmed to be at least RX channel
|
||||
RADIO_channel = ch; // confirmed to be at least RX channel
|
||||
RADIO_command = RADIO_CMD_RECEIVE;
|
||||
RADIO_perChannelSetting1 = perChannelSetting1[ch - 11];
|
||||
RADIO_perChannelSetting2 = perChannelSetting2[ch - 11];
|
||||
|
||||
12
zbs243_shared/soc/zbs243/radio.h
Normal file → Executable file
12
zbs243_shared/soc/zbs243/radio.h
Normal file → Executable file
@@ -9,14 +9,8 @@ void RF_IRQ1(void) __interrupt (4);
|
||||
void RF_IRQ2(void) __interrupt (5);
|
||||
#define RADIO_PAD_LEN_BY 2
|
||||
|
||||
extern uint8_t __code channelList[6];
|
||||
|
||||
#include "../radioCommon.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user