Coder Social home page Coder Social logo

Comments (6)

pjb304 avatar pjb304 commented on August 16, 2024 1

Yes, the code does currently have the assumption that uplink and downlink happen on the same frequency.

I think the way to change that would be to use similar calls to those in _choose_freq in the on_tx_done to change onto the correct frequency before entering RX mode.

As for the calibration I'm afraid I'm not sure how best to change that to 923MHz.

from dragino.

BNNorman avatar BNNorman commented on August 16, 2024

I use the code, from 9 months ago, on a project and it worked fine in the UK (815Mhz).

The MIC Mismatch you get from using V3 suggests to me that V3, somehow, calculates the MIC differently so you should stick with V2 for now. Look at dragino\LoraWAN\JoinAcceptPayload.py and JoinRequestPayload.py - you will find an example of the compute_mic() method.

However, 'waiting' forever suggests the join-accept response has been missed or not sent. What does your logfile have in it? If you look in dragino.py there's an on_rx_done() method on line 118 which logs the message "Received message". If the message is a JOIN_ACCEPT it logs 'Join resp' to the log file then validates the MIC etc. This should give you some idea what is/isn't happening.

from dragino.

pjb304 avatar pjb304 commented on August 16, 2024

I'm afraid I'm not sure what's going on here - I suspect there's something else that needs changing to adapt it to the different region. As it works fine on both v2 & v3 in the Uk

from dragino.

Dukat-Gul avatar Dukat-Gul commented on August 16, 2024

Thanks @pjb304 & @BNNorman .
Not sure how to further turn on logging - have experimented with editing dragino.py and adjusting the

D = Dragino("dragino.ini", logging_level=logging.INFO)

changing it to DEBUG - but nothing of note was showing on stdout or elsewhere.

Also tried -
DEFAULT_LOG_LEVEL = logging.DEBUG

Anyhow - I made a small change in the v3 console and updated my settings to be 1.0.1 Lorawan and I got a few extra steps, no sign of the MIC errors now.
v3_OTAA_slightprogress_metadata_rx-freq_9233

I have a feeling the issue is that I am not receiving anything. When I tweaked the dragino/FrequncyPlan.py to align to the AU915 (subband 2) frequencies for TTN in Australia, I didnt see any place to adjust the down (RX) frequencies.

As you can see from this - https://github.com/Fluent-networks/floranet/blob/f025825fa234194646d9831bd52fa3a3a55c0666/floranet/lora/bands.py

AU915 TX freq are 200khz stepped - Channel 8 (916.8) through Ch15 (917.5) plus a 500khz Ch65 (917.5) but unlike the EU868 the downlink (RX) frequencies are (also for US915) not the same as the uplink (TX).
They are 8 channels numbered 0 to 7 utilizing 500 kHz BW starting at 923.3 MHz and incrementing by 600 kHz to 927.5 MHz.

OTAA_AU915_tx_rx-freq

I have tried a few quick and dirty edits but all without any progress.
For example I edited a few places where I saw 868

dragino/SX127x/LoRa.py: def init(self, verbose=True, do_calibration=True, calibration_freq=923):
dragino/SX127x/LoRa.py: :param calibration_freq: call rx_chain_calibration with this parameter. Default is 923
dragino/SX127x/LoRa.py: def rx_chain_calibration(self, freq=923.3):

Any suggestions as to next (easy) steps I can try? Or will it require a significant code edit to have a TX and RX frequency alignment for this region?

from dragino.

Dukat-Gul avatar Dukat-Gul commented on August 16, 2024

Yeah.... cool Thanks.

I tried (i think) something along the lines of your suggestion prior to you suggesting it. As I looked at some of the other other forks - specifically the https://github.com/ryanzav/LoRaWAN/blob/master/otaa_helium.py
and he did it for the US downlink (which is the same as mine in AU).
I put into FrequncyPlan CH0 as the 923.3
then edited dragino.py:

def on_tx_done(self):
    """
        Callback on TX complete is signaled using I/O
    """
    self.clear_irq_flags(TxDone=1)
    self.set_mode(MODE.STDBY)
    self.set_dio_mapping([0, 0, 0, 0, 0, 0])
    self.set_invert_iq(1)
    self.reset_ptr_rx()
    self.set_freq(LORA_FREQS.CH0)
    self.set_spreading_factor(7)
    self.set_bw(9)
    self.set_rx_crc(False)
    self.set_mode(MODE.RXCONT)

didnt seem to hit the mark, or make any real difference. but its late here.... time to goto bed and perhaps tomorrow have another look

from dragino.

justin-cotarla avatar justin-cotarla commented on August 16, 2024

According to the specs, in the US902-928 channels:

RX1 Channel Number = Transmit Channel Number modulo 8

In other words, there are two sets of frequencies in the US frequency plan, one for uplink and one for downlink. If you use the first uplink channel, you will get a response on the first downlink channel.

I modified the code slightly to this effect:

FrequencyPlan.py

UPLINK_FREQS = (903.9, 904.1, 904.3, 904.5, 904.7, 904.9, 905.1, 905.3)
DOWNLINK_FREQS = (923.3, 923.9, 924.5, 925.1, 925.7, 926.3, 926.9, 927.5)

Dragino.py

def _choose_freq(self, uplink=False):
    if self.freq_index is None:
        self.freq_index = randrange(len(UPLINK_FREQS)) #Pick a random frequency

    if uplink:
        available = UPLINK_FREQS
    else:
        available = DOWNLINK_FREQS

    freq = available[self.freq_index]
    self.set_mode(MODE.SLEEP)
    self.set_freq(freq)
    self.logger.info("Frequency = %s", freq)

Then, every time there would be an uplink (such as when registering), I call self._choose_freq(uplink=True), and whenever I need to listen to a response, such as on_tx_done, I call self._choose_freq(uplink=False).

from dragino.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.