Skip to content

Commit 9dc2789

Browse files
committed
data arrives as Big Endian, stored as Little Endian
1 parent 1df6541 commit 9dc2789

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

stack/modules/d7ap/d7ap_fs.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,25 @@ int d7ap_fs_read_access_class(uint8_t access_class_index, dae_access_profile_t *
343343
{
344344
assert(access_class_index < 15);
345345
assert(is_file_defined(D7A_FILE_ACCESS_PROFILE_ID + access_class_index));
346-
return (d7ap_fs_read_file(D7A_FILE_ACCESS_PROFILE_ID + access_class_index, 0,
347-
(uint8_t*)access_class, D7A_FILE_ACCESS_PROFILE_SIZE));
346+
int result = d7ap_fs_read_file(D7A_FILE_ACCESS_PROFILE_ID + access_class_index, 0, (uint8_t*)access_class, D7A_FILE_ACCESS_PROFILE_SIZE);
347+
for(int i=0; i<SUBBANDS_NB; i++) {
348+
access_class->subbands[i].channel_index_start = __builtin_bswap16(access_class->subbands[i].channel_index_start);
349+
access_class->subbands[i].channel_index_end = __builtin_bswap16(access_class->subbands[i].channel_index_end);
350+
}
351+
return result;
348352
}
349353

350354
int d7ap_fs_write_access_class(uint8_t access_class_index, dae_access_profile_t* access_class)
351355
{
352356
assert(access_class_index < 15);
353357
assert(is_file_defined(D7A_FILE_ACCESS_PROFILE_ID + access_class_index));
354-
return (d7ap_fs_write_file(D7A_FILE_ACCESS_PROFILE_ID + access_class_index, 0,
355-
(uint8_t*)access_class, D7A_FILE_ACCESS_PROFILE_SIZE));
358+
dae_access_profile_t* temp_access_class;
359+
memcpy(&temp_access_class, &access_class, sizeof(dae_access_profile_t));
360+
for(int i=0; i<SUBBANDS_NB; i++) {
361+
temp_access_class->subbands[i].channel_index_start = __builtin_bswap16(temp_access_class->subbands[i].channel_index_start);
362+
temp_access_class->subbands[i].channel_index_end = __builtin_bswap16(temp_access_class->subbands[i].channel_index_end);
363+
}
364+
return d7ap_fs_write_file(D7A_FILE_ACCESS_PROFILE_ID + access_class_index, 0, (uint8_t*)temp_access_class, D7A_FILE_ACCESS_PROFILE_SIZE);
356365
}
357366

358367
uint8_t d7ap_fs_read_dll_conf_active_access_class()

stack/modules/d7ap/engineering_mode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ static void em_file_change_callback(uint8_t file_id) {
180180

181181
d7ap_fs_read_file(D7A_FILE_ENGINEERING_MODE_FILE_ID, 0, data, D7A_FILE_ENGINEERING_MODE_SIZE);
182182

183-
d7ap_fs_engineering_mode_t* em_command = (d7ap_fs_engineering_mode_t*)data;
183+
d7ap_fs_engineering_mode_t* em_command = (d7ap_fs_engineering_mode_t*) data;
184+
em_command->channel_id.center_freq_index = __builtin_bswap16(em_command->channel_id.center_freq_index);
184185

185186
DPRINT("em_file_change_callback");
186187
DPRINT_DATA(data, D7A_FILE_ENGINEERING_MODE_SIZE);

0 commit comments

Comments
 (0)