-
Notifications
You must be signed in to change notification settings - Fork 0
Semtech SX1262 compatibility completion port #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -58,25 +143,21 @@ uint32_t BoardGetRandomSeed( void ) | |||
return (mac_addr_bin[5] << 0) | (mac_addr_bin[4] << 8) | (mac_addr_bin[3] << 16) | (mac_addr_bin[2] << 24); | |||
} | |||
|
|||
#include "nvs.h" | |||
|
|||
void BoardGetUniqueId( uint8_t *id ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure you want to use the DEVEUI here? all other implementations use something hardware unique - see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I'm glad you called this out, I was iffy on this commit. I am dropping it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure of the reason either. Searching online about it, it seems like a bad idea to leave the reset pin floating/doesn't make any difference. I think I am going to leave it as disabled for now for these reasons.
Kconfig
Outdated
help | ||
Set the GPIO number used for IRQ (DIO1). | ||
|
||
config LORAWAN_BUSY_GPIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least my module has no dedicated BUSY-GPIO as far I can remember - maybe it can be enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdesterBE if its indeed an optional thing then you should make this config entry depend on another entry that enables it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added define guard to limit busy pin to boards that have one.
{ | ||
while(gpio_get_level(lora_spi.busy) == 1); | ||
} | ||
|
||
/*! | ||
* \brief HW Reset of the radio | ||
*/ | ||
void SX126xReset( void ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the reason, but in
https://github.com/manuelbl/ttn-esp32/blob/master/src/hal/hal_esp32.c
there is an option to keep reset floating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure of the reason either. Searching online it seems to be a bad idea to leave reset pin floating/doesn't make any difference, so I think I will just leave it disabled.
Happy new year, |
Happy new year! Thank you for reviewing, I will fixup/respond to comments today. Please don't merge until you feel it is ready. @cmorganBE may also review. |
idf_component.yml
Outdated
@@ -0,0 +1,4 @@ | |||
description: LoRaWAN board port for ESP32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this more clear? this is loramacnode port for esp32 no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
#define KHZ_PER_MHZ 1000 | ||
#define HZ_PER_MHZ (HZ_PER_KHZ * KHZ_PER_MHZ) | ||
|
||
#define SX1262_SPI_CLOCK_SPEED_MHZ 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 16mhz the max speed? if so I'd make another define or constant to define that and then assign that to the clock speed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the name of the define to include MAX for clarity
.command_bits = 8, | ||
.address_bits = 16 | ||
}; | ||
ESP_ERROR_CHECK(spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_DISABLED)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do you know its SPI2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why disable SPI_DMA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding configuration. changed to use DMA, accident.
@@ -81,7 +83,8 @@ void BoardInitPeriph(void) | |||
.mode = 0, | |||
.spics_io_num = lora_spi.cs, | |||
.command_bits = 8, | |||
.address_bits = 16 | |||
.address_bits = 16, | |||
.queue_size = 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, can be 1. changing and added comment.
|
||
ESP_ERROR_CHECK(gpio_set_level(lora_spi.reset, 1)); | ||
|
||
// Hold low for at least 100us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datasheet citation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
trans.tx_buffer = buffer; | ||
trans.length = size * 8; | ||
|
||
SX126xCheckDeviceReady(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if this never indicates ready? if we are ok with blocking at this point we should note the behavior in the README.md of this component to aid implementers in debugging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this, and additional detail to the README
trans.cmd = RADIO_READ_BUFFER; | ||
trans.addr = offset; | ||
trans.rx_buffer = buffer; | ||
trans.length = size * 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why size*8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added link to docs on this
static portMUX_TYPE my_spinlock = portMUX_INITIALIZER_UNLOCKED; | ||
|
||
static esp_timer_handle_t irq_timer_handle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a timer for measuring the irq?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used to call the stack's internal TimerIRQHandler()
function upon timer expiration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable name is a little confusing. 'timer_handler' maybe? its unclear where its coming from, internal vs. external etc.
@@ -1,3 +1,3 @@ | |||
[submodule "src/LoRaMac-node"] | |||
path = src/LoRaMac-node | |||
url = https://github.com/Lora-net/LoRaMac-node.git | |||
url = https://github.com/boston-engineering/LoRaMac-node.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in your fork here can you include output of the linking issue in the git commit log body? have you opened a PR against the upstream repo? we really want to avoid having to use a forked loramac-node if we can avoid it by getting your PR in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
72ef340
to
5f561b7
Compare
b7d7fc9
to
c908724
Compare
adeb6d1
to
b9b7596
Compare
b9b7596
to
0d85d0f
Compare
@ljakob @cmorganBE Ready for review again. This has now been tested with an SX1262 devkit, and successfully sends join requests. |
int64_t time_us = esp_timer_get_time(); | ||
uint32_t time_s = (uint32_t)(time_us / US_PER_S); | ||
|
||
*milliseconds = (uint16_t)(time_us * US_PER_MS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't look correct, milliseconds appears to be the remainder of time since epoch when you've taken away all of the whole seconds.
…rypt() multiple definitions fix Linking error: .espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../../xtensa-esp32s3-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(crypto_mbedtls.c.obj): in function `aes_encrypt': esp/esp-idf/components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls.c:421: multiple definition of `aes_encrypt'; esp-idf/LoRaMac-node-esp32/libLoRaMac-node-esp32.a(aes.c.obj):src/LoRaMac-node/src/peripherals/soft-se/aes.c:569: first defined here collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
… Remove hard-coding of RegionEU868 definition - should be determined by the application which regions are enabled.
0d85d0f
to
d4b7ed5
Compare
2f541c2
to
3da8136
Compare
No description provided.