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 ChirpStack v4 #112

Merged
merged 7 commits into from
Mar 13, 2024
Merged

Support ChirpStack v4 #112

merged 7 commits into from
Mar 13, 2024

Conversation

KrishnaIyer
Copy link
Member

@KrishnaIyer KrishnaIyer commented Feb 28, 2024

Summary

Closes #58 and replaces #75

Changes

  • Make the configuration block consistent with other sources.
  • Setup CSv4 API.
  • Fix issues and test

Testing

Locally

Exports
--------
export CHIRPSTACK_API_URL="localhost:8080"
export CHIRPSTACK_API_KEY="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJjaGlycHN0YWNrIiwiaXNzIjoiY2hpcnBzdGFjayIsInN1YiI6ImQ5MGVmOGE5LTMyZTYtNDk5ZC1hMDMzLWEzN2MyZTEyNjc2MSIsInR5cCI6ImtleSJ9.W_njhPCsd8KEPQd8IoWtTzmv5d_nWyFXYWWrKECZ5Ec"
export JOIN_EUI="1111111111111111"
export FREQUENCY_PLAN_ID="EU_863_870"
export CHIRPSTACK_INSECURE="true"
export CHIRPSTACK_EXPORT_SESSION="true"


1. Device with session
./main chirpstack device 0004a30b001bc8a7 --dry-run
{"ids":{"device_id":"eui-0004a30b001bc8a7","application_ids":{"application_id":"chirpstack-832587699d72"},"dev_eui":"0004A30B001BC8A7","join_eui":"1111111111111111"},"name":"The Things Uno C8A7","attributes":{"chirpstack-device-profile":"1490385e-6368-41f7-b01b-4902773cab60","chirpstack-application-id":"18e5c56e-ef06-4ea9-b005-832587699d72"},"lorawan_version":"MAC_V1_0_2","lorawan_phy_version":"PHY_V1_0_2_REV_A","frequency_plan_id":"EU_863_870","supports_join":true,"root_keys":{"app_key":{"key":"5105D918B6EEEF8A22AA92B39D9EC718"}},"mac_settings":{"rx1_delay":1,"status_time_periodicity":"0.000000001s"},"mac_state":{"current_parameters":{"max_eirp":16,"adr_nb_trans":1,"rx1_delay":1,"rx2_frequency":"869525000","ping_slot_frequency":"869525000","beacon_frequency":"869525000","channels":[{"uplink_frequency":"868100000","downlink_frequency":"868100000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"868300000","downlink_frequency":"868300000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"868500000","downlink_frequency":"868500000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867100000","downlink_frequency":"867100000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867300000","downlink_frequency":"867300000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867500000","downlink_frequency":"867500000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867700000","downlink_frequency":"867700000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867900000","downlink_frequency":"867900000","max_data_rate_index":5,"enable_uplink":true}],"adr_ack_limit_exponent":"ADR_ACK_LIMIT_64","adr_ack_delay_exponent":"ADR_ACK_DELAY_32","ping_slot_data_rate_index_value":3},"desired_parameters":{"max_eirp":16,"adr_nb_trans":1,"rx1_delay":1,"rx2_frequency":"869525000","ping_slot_frequency":"869525000","beacon_frequency":"869525000","channels":[{"uplink_frequency":"868100000","downlink_frequency":"868100000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"868300000","downlink_frequency":"868300000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"868500000","downlink_frequency":"868500000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867100000","downlink_frequency":"867100000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867300000","downlink_frequency":"867300000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867500000","downlink_frequency":"867500000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867700000","downlink_frequency":"867700000","max_data_rate_index":5,"enable_uplink":true},{"uplink_frequency":"867900000","downlink_frequency":"867900000","max_data_rate_index":5,"enable_uplink":true}],"adr_ack_limit_exponent":"ADR_ACK_LIMIT_64","adr_ack_delay_exponent":"ADR_ACK_DELAY_32","ping_slot_data_rate_index_value":3},"lorawan_version":"MAC_V1_0_2"},"session":{"dev_addr":"006F0616","keys":{"session_key_id":"5nU66wHfm5eWbm3qzwzcpQ==","f_nwk_s_int_key":{"key":"4B40A8805F4B758E21BEEFDE90C9F2EA"},"app_s_key":{"key":"4F5179E867B163FED02B8C734628CDA8"}},"last_f_cnt_up":61,"last_n_f_cnt_down":8,"started_at":"2024-02-28T09:57:13.811927Z"},"formatters":{}}

2. Device without session
export CHIRPSTACK_EXPORT_SESSION="false"
{"ids":{"device_id":"eui-0004a30b001bc8a7","application_ids":{"application_id":"chirpstack-832587699d72"},"dev_eui":"0004A30B001BC8A7","join_eui":"1111111111111111"},"name":"The Things Uno C8A7","attributes":{"chirpstack-device-profile":"1490385e-6368-41f7-b01b-4902773cab60","chirpstack-application-id":"18e5c56e-ef06-4ea9-b005-832587699d72"},"lorawan_version":"MAC_V1_0_2","lorawan_phy_version":"PHY_V1_0_2_REV_A","frequency_plan_id":"EU_863_870","supports_join":true,"root_keys":{"app_key":{"key":"5105D918B6EEEF8A22AA92B39D9EC718"}},"mac_settings":{"status_time_periodicity":"0.000000001s"},"formatters":{}}


3. Application
./main chirpstack application 18e5c56e-ef06-4ea9-b005-832587699d72 --dry-run
{"ids":{"device_id":"eui-0004a30b001bc8a7","application_ids":{"application_id":"chirpstack-832587699d72"},"dev_eui":"0004A30B001BC8A7","join_eui":"1111111111111111"},"name":"The Things Uno C8A7","attributes":{"chirpstack-device-profile":"1490385e-6368-41f7-b01b-4902773cab60","chirpstack-application-id":"18e5c56e-ef06-4ea9-b005-832587699d72"},"lorawan_version":"MAC_V1_0_2","lorawan_phy_version":"PHY_V1_0_2_REV_A","frequency_plan_id":"EU_863_870","supports_join":true,"root_keys":{"app_key":{"key":"5105D918B6EEEF8A22AA92B39D9EC718"}},"mac_settings":{"status_time_periodicity":"0.000000001s"},"formatters":{}}
Regressions

NA. This is supporting a new API version.

Notes for Reviewers

Checklist

  • xx] Scope: The referenced issue is addressed, there are no unrelated changes.
  • Documentation: Relevant documentation is added or updated.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.

@KrishnaIyer KrishnaIyer added this to the Mar 2024 milestone Feb 28, 2024
@KrishnaIyer KrishnaIyer self-assigned this Feb 28, 2024
Base automatically changed from fix/chirpstack to master March 4, 2024 13:13
Comment on lines +23 to +28
## [v0.11.2] (2024-03-04)

### Fixed

- Exporting devices from ChirpStack v3.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mistake in the current (released) changelog that's fixed.

@KrishnaIyer KrishnaIyer marked this pull request as ready for review March 6, 2024 17:34
Copy link
Member

@johanstokking johanstokking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, is this tested for OTAA and ABP?

@KrishnaIyer
Copy link
Member Author

Now I did a test for ABP and made a couple of fixes. This is good to go.
Screenshot 2024-03-11 at 14 42 25
Screenshot 2024-03-11 at 14 42 31

Copy link
Member

@happyRip happyRip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

c.JoinEUI = &types.EUI64{}
if err := c.JoinEUI.UnmarshalText([]byte(c.joinEUI)); err != nil {
return errInvalidJoinEUI.WithAttributes("join_eui", c.joinEUI)
}
c.caCertPath = os.Getenv("CHIRPSTACK_CA_CERT_PATH")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this always override the CLI flags ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed. We do this for all the other sources the same currently. I think we should fix this separately for all the sources.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see this fixed everywhere before we make a new release, as it is very broken.

The change itself comes from #97 (comment) , but the idea is that only secrets shouldn't be initialized as flag defaults - the rest of the setup does not need this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. I'll file a follow up before we make a release.

@KrishnaIyer KrishnaIyer merged commit 6283d81 into master Mar 13, 2024
3 checks passed
@KrishnaIyer KrishnaIyer deleted the chirpstack-v4 branch March 13, 2024 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support migration from ChirpStack V4
4 participants