28
28
#include "fhss_callbacks_stub.h"
29
29
#include "fhss_platform_stub.h"
30
30
#include "channel_functions_stub.h"
31
- #include "common_functions_stub.h"
32
31
33
32
#define VENDOR_CHANNEL 89
34
33
#define DEFAULT_CHANNEL 99
@@ -50,6 +49,22 @@ static fhss_api_t fhss_api;
50
49
static fhss_ws_t ws ;
51
50
static fhss_ws_neighbor_timing_info_t neighbor_info ;
52
51
52
+ uint16_t common_read_16_bit_inverse (const uint8_t data_buf [__static 2 ])
53
+ {
54
+ uint16_t temp_16 ;
55
+ temp_16 = * data_buf ++ ;
56
+ temp_16 += (uint16_t )(* data_buf ++ ) << 8 ;
57
+ return temp_16 ;
58
+ }
59
+
60
+ uint8_t * common_write_24_bit_inverse (uint_fast24_t value , uint8_t ptr [__static 3 ])
61
+ {
62
+ * ptr ++ = value ;
63
+ * ptr ++ = value >> 8 ;
64
+ * ptr ++ = value >> 16 ;
65
+ return ptr ;
66
+ }
67
+
53
68
static int32_t app_channel_function (const fhss_api_t * api , uint16_t slot , uint8_t eui64 [8 ], uint16_t bsi , uint16_t number_of_channels )
54
69
{
55
70
return VENDOR_CHANNEL ;
@@ -77,6 +92,17 @@ static void enable_fhss_struct(void)
77
92
fhss_common_stub .bool_value = true;
78
93
}
79
94
95
+ static bool test_ufsi (uint8_t * ufsi_ptr , uint_fast24_t test_value )
96
+ {
97
+ uint_fast24_t ufsi = * ufsi_ptr ++ ;
98
+ ufsi += (uint_fast24_t )(* ufsi_ptr ++ ) << 8 ;
99
+ ufsi += (uint_fast24_t )(* ufsi_ptr ++ ) << 16 ;
100
+ if (test_value != ufsi ) {
101
+ return false;
102
+ }
103
+ return true;
104
+ }
105
+
80
106
static void test_set_platform_api (fhss_timer_t * fhss_timer )
81
107
{
82
108
fhss_timer -> fhss_resolution_divider = 1 ;
@@ -97,6 +123,7 @@ static fhss_api_t *test_generate_fhss_api(void)
97
123
neighbor_info .uc_timing_info .utt_rx_timestamp = 100000 ;
98
124
fhss_common_stub .fhss_struct .fhss_api = & fhss_api ;
99
125
fhss_common_stub .fhss_struct .ws = & ws ;
126
+ fhss_common_stub .fhss_struct .ws -> uc_slot = 3 ;
100
127
fhss_common_stub .fhss_struct .ws -> fhss_configuration .fhss_uc_dwell_interval = 200 ;
101
128
fhss_common_stub .fhss_struct .ws -> fhss_configuration .fhss_bc_dwell_interval = 250 ;
102
129
fhss_common_stub .fhss_struct .ws -> fhss_configuration .fhss_broadcast_interval = 1000 ;
@@ -195,7 +222,7 @@ bool test_fhss_ws_tx_handle_callback()
195
222
/* Test TR51 channel function
196
223
* Dest. slot: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
197
224
* |dest. ufsi| 900ms |
198
- * timestamps: 100000us| 1000000us|
225
+ * timestamps: 100000us| 1000000us|
199
226
*/
200
227
fhss_common_stub .fhss_struct .ws -> fhss_configuration .ws_channel_function = WS_TR51CF ;
201
228
if ((fhss_common_stub .fhss_struct .fhss_api -> tx_handle (api , DEFAULT_IS_BC_DEST , dest_address , DEFAULT_FRAME_TYPE , DEFAULT_FRAME_LENGTH , DEFAULT_PHY_HEAD_LENGTH , DEFAULT_PHY_TAIL_LENGTH , DEFAULT_TX_TIME ) != 0 )
@@ -243,8 +270,6 @@ bool test_fhss_ws_tx_handle_callback()
243
270
return false;
244
271
}
245
272
246
- // TODO: Test own_ceil with decimal number
247
-
248
273
return true;
249
274
}
250
275
@@ -340,13 +365,31 @@ bool test_fhss_ws_write_synch_info_callback()
340
365
if (fhss_common_stub .fhss_struct .fhss_api -> write_synch_info (api , synch_info , sizeof (synch_info ), FHSS_SYNCH_FRAME , DEFAULT_TX_TIME ) != -1 ) {
341
366
return false;
342
367
}
343
- // Test when IE element not found
344
- common_functions_stub .uint16_value = 0 ;
345
- if (fhss_common_stub .fhss_struct .fhss_api -> write_synch_info (api , synch_info , sizeof (synch_info ), DEFAULT_FRAME_TYPE , DEFAULT_TX_TIME ) != 0 ) {
368
+ fhss_platform_stub .remaining_slots_value = 100000 ;
369
+ fhss_common_stub .uint32_value = 1000000 ;
370
+ /* Test the UFSI field in synch info
371
+ * slot: | 0(200ms) | 1(200ms) | 2(200ms) | 3(200ms) |
372
+ * | ufsi(597ms) -> 1001599 |
373
+ * timestamps: written at 1000000us|TX at 1097000us|
374
+ */
375
+ if ((fhss_common_stub .fhss_struct .fhss_api -> write_synch_info (api , synch_info , sizeof (synch_info ), DEFAULT_FRAME_TYPE , fhss_common_stub .uint32_value + 97000 ) != 0 )
376
+ || (test_ufsi (& synch_info [11 ], 1001599 ) != true)) {
346
377
return false;
347
378
}
348
- // Test when IE element found
349
- common_functions_stub .uint16_value = 0x1505 ;
379
+ // Test when timestamp overflows
380
+ fhss_common_stub .uint32_value = 4294960000 ;
381
+ /* Test the UFSI field in synch info
382
+ * slot: | 0(200ms) | 1(200ms) | 2(200ms) | 3(200ms) |
383
+ * | ufsi(597ms) -> 1001599 |
384
+ * timestamps: written at 4294960000us| TX at 89704us|
385
+ */
386
+ if ((fhss_common_stub .fhss_struct .fhss_api -> write_synch_info (api , synch_info , sizeof (synch_info ), DEFAULT_FRAME_TYPE , fhss_common_stub .uint32_value + 97000 ) != 0 )
387
+ || (test_ufsi (& synch_info [11 ], 1001599 ) != true)) {
388
+ return false;
389
+ }
390
+
391
+ // Test when IE element not found
392
+ memset (synch_info , 0 , sizeof (synch_info ));
350
393
if (fhss_common_stub .fhss_struct .fhss_api -> write_synch_info (api , synch_info , sizeof (synch_info ), DEFAULT_FRAME_TYPE , DEFAULT_TX_TIME ) != 0 ) {
351
394
return false;
352
395
}
0 commit comments