Skip to content
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

Support for sub band choice within AU915 #19

Open
mutton74 opened this issue Nov 14, 2019 · 40 comments
Open

Support for sub band choice within AU915 #19

mutton74 opened this issue Nov 14, 2019 · 40 comments
Assignees
Labels
bug

Comments

@mutton74
Copy link

@mutton74 mutton74 commented Nov 14, 2019

I am trying to use the cubecell with LoRaWAN on The Things Network (TTN).

At the moment the join process takes a long time and receiving messages is unreliable.

I believe that this is due to TTN using the second sub band (Channels 8-15) out of the 64 channels available and this library seems to be set to the first sub band (Channels 0-7)

Taken from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAU915.c

// Channels // 125 kHz channels for( uint8_t i = 0; i < AU915_MAX_NB_CHANNELS - 8; i++ ) { Channels[i].Frequency = 915200000 + i * 200000; Channels[i].DrRange.Value = ( DR_5 << 4 ) | DR_0; Channels[i].Band = 0; } // 500 kHz channels for( uint8_t i = AU915_MAX_NB_CHANNELS - 8; i < AU915_MAX_NB_CHANNELS; i++ ) { Channels[i].Frequency = 915900000 + ( i - ( AU915_MAX_NB_CHANNELS - 8 ) ) * 1600000; Channels[i].DrRange.Value = ( DR_6 << 4 ) | DR_6; Channels[i].Band = 0; }

TTN uses these channels

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 15, 2019

you can change it in the RegionAU915.c file.

Channels[i].Frequency = 916800000 + i * 200000;

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 15, 2019

OK thanks I changed that and it does seem to join and send on the correct channels but it misses lots of (unconfirmed) uplinks.

image

It has perfect reception to a confirmed working gateway on TTN (11.5 SNR)

Any other ideas to get it more reliable?

Is there any way to debug what channels it is trying uplinks on?

A verbose debug output in serial monitor?

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 15, 2019

the change i provided only changed the uplink frequencies for the 125kHz channels but not for the 500kHz channels and the downlink.

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 23, 2019

tried my best to add a new compiler option for the frequency band AU915_SB2
ca009e0

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 23, 2019

Sorry not much different - if there is anything I can do to help diagnose please let me know

This what I am seeing
image

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 23, 2019

hope i have fixed the problem.
please try.

@wasn-eu wasn-eu self-assigned this Nov 23, 2019
@wasn-eu wasn-eu added the bug label Nov 23, 2019
@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 23, 2019

seeing this now
image

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 23, 2019

Please post the frequencies used for the correct uplinks and downlinks in your screenshot.
Whats the dutycycle you have used?

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 23, 2019

15 secs duty cycle

Join attempt
"lora": {
"spreading_factor": 12,
"bandwidth": 500,
"air_time": 288768000
},
"coding_rate": "4/5",
"timestamp": "2019-11-23T21:33:22.529Z",
"frequency": 923300000

Count 6 - uplink
"frequency": 917.8,
"modulation": "LORA",
"data_rate": "SF12BW125",
"coding_rate": "4/5",

Count 10 uplink
"frequency": 917.6,
"modulation": "LORA",
"data_rate": "SF12BW125",
"coding_rate": "4/5",

Downlink frequencies (from gateway)
"lora": {
"spreading_factor": 12,
"bandwidth": 500,
"air_time": 329728000
},
"coding_rate": "4/5",
"timestamp": "2019-11-23T21:36:58.628Z",
"dev_addr": "26042457",
"frequency": 923300000

@Bwooce

This comment has been minimized.

Copy link
Contributor

@Bwooce Bwooce commented Nov 24, 2019

There's an issue that was fixed in LoRaMac-node 4.4.2 that probably has some bearing here. Check out this bit and think about how many channels are in the mask -- only 8 right? So this function is likely failing when it gets called.

I think this is the source of the problems for OTAA but I've not been able to trace the flow yet (it's also possible that the channel list wasn't sent in the join response for AU915 for LoRaWAN 1.0.2 or something, I remember reading that somewhere it was a bit of an error in the spec). It's weird that it would work with ADR of course, which is why it's a good puzzle.

It also points to an easier way of implementing the sub-band restriction e.g.

`
// Enabling 2nd block of 8 channels (8-15) + channel 65
MibRequestConfirm_t mibReq;

uint16_t channelMask[] = { 0xFF00, 0x0000, 0x0000, 0x0000, 0x0002, 0x0000};
mibReq.Type = MIB_CHANNELS_MASK;
mibReq.Param.ChannelsMask = channelMask;
LoRaMacMibSetRequestConfirm( &mibReq );
`

[as well as removing that 20+ channel bit of code]

I'm testing this right now, and paring it back to discover if it's only required once (post-join) or more frequently (no pun intended). There were other regional changes in 4.4.2 that would be great to roll-forward too though, but quite an API change as well sadly.

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Nov 25, 2019

Hi guys, do not need so complicated at all. LoRaWAN is a complete protocol, and TTN has good support for it.

Now, let's look into the LoRaWAN protocol firstly, I think this sentence is clear enough:
image

Then, let's look into our code: (in LoRaWan_APP.cpp file)
image
Here are 5 arrays defined all channels of LoRaWAN protocol for AU915. In the channelsMaskTemp[0], 0x00FF means use the first 0-7 channels, they are 915.2MHz, 915.4MHz, 915.6MHz … 916.6MHz. When you set the value to 0xFF00, it means the upload channels changed to 8-15, they are 916.8MHz, 917.0MHz … 918.2MHz. More detail... see the below picture (Forgive me for my bad English writing😄):
image

Then, let's look back to the TTN's uplink/downlink define for AU915:
https://www.thethingsnetwork.org/docs/lorawan/frequency-plans.html
image

Generally speaking... we just need to change the channelsMaskTemp[0]=0xFF00;, the uplink frequency will be changed to TTN supported.

BTW. Also, the listening frequency in your LoRa gateway must the same as the TTN server. it's defined in your gateway's gloable_conf.json file.

@Bwooce

This comment has been minimized.

Copy link
Contributor

@Bwooce Bwooce commented Nov 25, 2019

Hey I agree Aaron.Lee, I think the mask change is all that's required. The additional complication that I've uncovered is the AU915 regional definition which (for the 4.4.1 release) insists on there being 20 channels for AU915 (only, this was an Australia specific thing). This is wrong and was changed in 4.4.2 but so was a lot of the API.

Check out the RegionAU915ChanMaskSet, the top few lines validate there should be 20 channels or it fails to do anything. I think that's what is happening here, see this bit of code

RegionAU915ChanMaskSet is called eventually from your LoRaMacMibSetRequestConfirm call in your code, if you trace it all the way down.

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 25, 2019

thanks Aaron for your help.

Using compile Option AU915SB2 now uses the normal AU915 files and switches the channelMaskTemp in LoRaWAN_APP

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 25, 2019

Would be great if someone could test this fix.

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 25, 2019

Ill give it a try (does it include Bwooce's suggestions above?)

  • on a side note trying to update the library from within Arduino times out, download is too slow, yet downloading a zip and unpacking it is fine
@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 26, 2019

Sorry might have got worse.

Does not join at all, just hangs trying, nothing seen on gateway, nothing in TTN Application and this is what Serial Monitor shows

image

With regards to my gateway setup.

This gateway has been operating flawlessly for about 3 years with hundreds of nodes operating and tested on it over that time using a mixture of LMIC and Microchip AU915 code.

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Nov 26, 2019

Can you please paste your gloable_conf.json file?

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 26, 2019

global_conf.txt

just converted to TXT so it would attach here

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 26, 2019

Using this installer from a TTN supporter

https://github.com/kersing/multitech-installer

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 27, 2019

I will test again tonight as there seems to be some issues with the TTN routers, just to rule out any TTN/application issues.

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Nov 27, 2019

@mutton74 Tomorrow I will test at my side.

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 27, 2019

OK thanks, just to confirm, I tested it again on a TTN handler that is known to be working and same result

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Nov 28, 2019

I did many tests tonight, the gateway is the HT-M02 made by us.
image

just simply fixed the channelsMaskTemp[0] = 0xFF00;, it's working stable after joined.
image
image

This is my global_conf.json, it's almost the same with @mutton74 's

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Nov 28, 2019

But this code still has a strange problem: not always join for the first time... I printed some debug info, shown the TX data been sent out more than one time, and some frequency not for AS915.
image

I also tested the SB2 define written by @raystream, it seems no data send out, but I didn't find any unsuitable. Hey, @raystream , can I reset the code to the point before you add AU915_SB2 (Indeed I don't know how to remove one commit 😭)? I need to look into the original source code to fix this bug. I think the problem is caused by some error initial config.

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 28, 2019

found a failure for using the Subband 2 and corrected it in

07dac0d

the changes are in the compiled firmware to. just flash the firmware with the AU915SB2 setting again.
the actual firmware will be downloaded and flashed

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 28, 2019

Hey, @raystream , can I reset the code to the point before you add AU915_SB2 (Indeed I don't know how to remove one commit 😭)? I need to look into the original source code to fix this bug. I think the problem is caused by some error initial config.

you can just type the following in your git bash (will make a new branch with the state before my commit):

git checkout -b before_AU915SB2 deaa4df65393d4239fc93675c9602e58be9070c5

or type the following to get to the state before my commit:

git reset --hard deaa4df65393d4239fc93675c9602e58be9070c5

to take back just that commit and hope there will be no conflicts you can try:

git revert deaa4df65393d4239fc93675c9602e58be9070c5

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Nov 29, 2019

@mutton74 have you found time to test the new compiled AU915SB2 version or the recent github version here?

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Nov 30, 2019

I have just tested it and it attempts to join but nothing seen on the gateway or the application

I downloaded a zip file and replaced what I had in my Arduino hardware folder - trying to update through the boards manager times out.

Keys checked twice to be sure

Does nothing more than this, hangs there

board settings

Serial Output

@Bwooce

This comment has been minimized.

Copy link
Contributor

@Bwooce Bwooce commented Dec 6, 2019

Hey Aaron Lee, did you make any progress? Need any help? (I know you've had some distractions)

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Dec 6, 2019

@Bwooce Yes, we are still working on this. Found some problem in the AU915 code and trying to solve it.

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Dec 10, 2019

Hi there

I found out the reason for the AU915 sub-band, the AU915 sub-band requires at least 20 125KHz channels... but normally, a gateway have 8 channels.
image
image

But my network is too bad, I will push the code tomorrow when I'm back to my office.

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Dec 27, 2019

Have you had a chance to progress this any further?

Can I test anything for you again?

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Dec 27, 2019

Had no time to look at it cause we are just now making our modular node ready for sale.
Hope to have time next week

@Heltec-Aaron-Lee

This comment has been minimized.

Copy link
Collaborator

@Heltec-Aaron-Lee Heltec-Aaron-Lee commented Jan 2, 2020

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Jan 5, 2020

No, this was the result from that suggestion - again just tested - same result

Sorry might have got worse.

Does not join at all, just hangs trying, nothing seen on gateway, nothing in TTN Application and this is what Serial Monitor shows

image

With regards to my gateway setup.

This gateway has been operating flawlessly for about 3 years with hundreds of nodes operating and tested on it over that time using a mixture of LMIC and Microchip AU915 code.

@Bwooce

This comment has been minimized.

Copy link
Contributor

@Bwooce Bwooce commented Feb 1, 2020

Back from a bit of a break now. I've just moved from my hacked up 0.4 release of Cubecell to the HEAD and my board has gone from OTAA Joining okay to not joining (as per mutton74's results).

It just sits after Joining. It is transmitting (LED is going BLUE/~GREEN(YELLOW?)/RED ) but I'm not seeing it on my gateway.

I'm not seeing the traffic on my gateway, and I was before, so this is a software issue somewhere. I'm going to be away from AU915 gateways for a week or so, but I'll have a dig around in the meantime.

@Bwooce

This comment has been minimized.

Copy link
Contributor

@Bwooce Bwooce commented Feb 1, 2020

I've compared my changes I did on r0.4 with the current HEAD and they're functionally ~equivalent. So this is a new problem introduced between then and now.

@Bwooce

This comment has been minimized.

Copy link
Contributor

@Bwooce Bwooce commented Feb 1, 2020

Resolved.

Maybe it's just that I'm using OTAA now. Putting this function prior to LoraWAN.Join() (I already had it prior to the subsequent LoRaWAN.Send()'s but I don't know if that's really required...hey it can't hurt).

@mutton74 mutton74 please try this?

Use the current HEAD (not r0.0.4 release from the library manager), then add

void setTTNBand() {

Serial.println("setTTNBand");

// Enabling only 2nd block of 8 channels (8-15) + channel 65
MibRequestConfirm_t mibReq;

uint16_t channelMask[] = { 0xFF00, 0x0000, 0x0000, 0x0000, 0x0002, 0x0000};
mibReq.Type = MIB_CHANNELS_MASK;
mibReq.Param.ChannelsMask = channelMask;
LoRaMacMibSetRequestConfirm( &mibReq );

}

into your sketch and call it before LoRaWAN.Join() in the loop()? Works for me like a charm.

I think this is TTN-specific as they're only using those 8 channels (of 16? available), so I'm not sure if/how that should be wedged into the CubeCell code -- we should have an example though :-)

@mutton74

This comment has been minimized.

Copy link
Author

@mutton74 mutton74 commented Feb 2, 2020

PERFECT thanks @Bwooce

I was beginning to doubt my setup - not sure why but there wasnt much left to try

Now to use this great little board

cheers
Paul

@wasn-eu

This comment has been minimized.

Copy link
Collaborator

@wasn-eu wasn-eu commented Feb 7, 2020

@Bwooce
and if you encapsulate it like this than you can have it in your code and it will only be active is you select the AU915 frequencyband:

 case DEVICE_STATE_JOIN:
  {
     #if (ACTIVE_REGION == 1)
     setSubBand2();
     #endif
     LoRaWAN.Join();
     break;
  }

and make a little function out of the code from @Bwooce :

void setSubBand2() {
  Serial.println("setSubBand2");
  // Enabling only 2nd block of 8 channels (8-15) + channel 65
  MibRequestConfirm_t mibReq;

  uint16_t channelMask[] = { 0xFF00, 0x0000, 0x0000, 0x0000, 0x0002, 0x0000};
  mibReq.Type = MIB_CHANNELS_MASK;
  mibReq.Param.ChannelsMask = channelMask;
  LoRaMacMibSetRequestConfirm( &mibReq );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.