Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit c9fb00a

Browse files
committed
enable reading out region from d7
1 parent 5e7f244 commit c9fb00a

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

stack/modules/d7ap/d7ap.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,19 @@ uint8_t d7ap_get_access_class(void)
235235
{
236236
return d7ap_fs_read_dll_conf_active_access_class();
237237
}
238+
239+
/**
240+
* @brief Gets the region configured in the active access class
241+
*
242+
* @param region the region variable to store the value
243+
* @return error_t an error in case of failure
244+
*/
245+
error_t d7ap_get_modem_region(modem_region_t* region)
246+
{
247+
channel_header_t channel_header;
248+
uint32_t length = 1;
249+
250+
error_t err = d7ap_fs_read_file(D7A_FILE_ACCESS_PROFILE_ID + (d7ap_get_access_class() >> 4), D7A_FILE_ACCESS_PROFILE_CHANNEL_HEADER_IDX, (uint8_t*)&channel_header, &length, ROOT_AUTH);
251+
*region = (channel_header.ch_freq_band == PHY_BAND_868) ? MODEM_REGION_EU868 : MODEM_REGION_US915;
252+
return err;
253+
}

stack/modules/d7ap/inc/d7ap.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "types.h"
3737
#include "debug.h"
3838
#include "hwblockdevice.h"
39+
#include "modem_region.h"
3940

4041
#define ID_TYPE_NBID_ID_LENGTH 1
4142
#define ID_TYPE_NOID_ID_LENGTH 0
@@ -303,6 +304,14 @@ static inline uint8_t d7ap_session_config_length(d7ap_session_config_t* itf_conf
303304
*/
304305
void d7ap_add_result_to_array(d7ap_session_result_t* result, uint8_t* array);
305306

307+
/**
308+
* @brief Gets the region configured in the active access class
309+
*
310+
* @param region the region variable to store the value
311+
* @return error_t an error in case of failure
312+
*/
313+
error_t d7ap_get_modem_region(modem_region_t* region);
314+
306315
#endif // D7AP_H
307316

308317
/** @}*/

stack/modules/d7ap_fs/inc/d7ap_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#define D7A_FILE_ACCESS_PROFILE_ID 0x20 // the first access class file
7676
#define D7A_FILE_ACCESS_PROFILE_SIZE 65
7777
#define D7A_FILE_ACCESS_PROFILE_COUNT 15
78+
#define D7A_FILE_ACCESS_PROFILE_CHANNEL_HEADER_IDX 0
7879

7980
#define D7A_FILE_NWL_SECURITY 0x0D
8081
#define D7A_FILE_NWL_SECURITY_SIZE 5

0 commit comments

Comments
 (0)