@@ -335,13 +335,17 @@ enum dtm_evt {
335335/** Upper bits of packet length */
336336static uint8_t upper_len ;
337337
338+ /** Currently configured PHY */
339+ static enum dtm_phy dtm_phy = DTM_PHY_1M ;
340+
338341static int reset_dtm (uint8_t parameter )
339342{
340343 if (parameter > LE_RESET_MAX_RANGE ) {
341344 return - EINVAL ;
342345 }
343346
344347 upper_len = 0 ;
348+ dtm_phy = DTM_PHY_1M ;
345349 return dtm_setup_reset ();
346350}
347351
@@ -357,18 +361,32 @@ static int upper_set(uint8_t parameter)
357361
358362static int phy_set (uint8_t parameter )
359363{
364+ int err ;
360365 switch (parameter ) {
361366 case LE_PHY_1M_MIN_RANGE ... LE_PHY_1M_MAX_RANGE :
362- return dtm_setup_set_phy (DTM_PHY_1M );
363-
367+ err = dtm_setup_set_phy (DTM_PHY_1M );
368+ if (err == 0 ) {
369+ dtm_phy = DTM_PHY_1M ;
370+ }
371+ return err ;
364372 case LE_PHY_2M_MIN_RANGE ... LE_PHY_2M_MAX_RANGE :
365- return dtm_setup_set_phy (DTM_PHY_2M );
366-
373+ err = dtm_setup_set_phy (DTM_PHY_2M );
374+ if (err == 0 ) {
375+ dtm_phy = DTM_PHY_2M ;
376+ }
377+ return err ;
367378 case LE_PHY_LE_CODED_S8_MIN_RANGE ... LE_PHY_LE_CODED_S8_MAX_RANGE :
368- return dtm_setup_set_phy (DTM_PHY_CODED_S8 );
369-
379+ err = dtm_setup_set_phy (DTM_PHY_CODED_S8 );
380+ if (err == 0 ) {
381+ dtm_phy = DTM_PHY_CODED_S8 ;
382+ }
383+ return err ;
370384 case LE_PHY_LE_CODED_S2_MIN_RANGE ... LE_PHY_LE_CODED_S2_MAX_RANGE :
371- return dtm_setup_set_phy (DTM_PHY_CODED_S2 );
385+ err = dtm_setup_set_phy (DTM_PHY_CODED_S2 );
386+ if (err == 0 ) {
387+ dtm_phy = DTM_PHY_CODED_S2 ;
388+ }
389+ return err ;
372390
373391 default :
374392 return - EINVAL ;
@@ -668,7 +686,10 @@ static uint16_t on_test_tx_cmd(uint8_t chan, uint8_t length, enum dtm_pkt_type t
668686 return LE_TEST_STATUS_EVENT_ERROR ;
669687 }
670688
671- length = (length & ~LE_UPPER_BITS_MASK ) | upper_len ;
689+ /* Add upper bits to length only if packet is not vendor specific */
690+ if (pkt != DTM_PACKET_FF_OR_VENDOR || (dtm_phy != DTM_PHY_1M && dtm_phy != DTM_PHY_2M )) {
691+ length = (length & ~LE_UPPER_BITS_MASK ) | upper_len ;
692+ }
672693
673694 err = dtm_test_transmit (chan , length , pkt );
674695
0 commit comments