@@ -418,14 +418,14 @@ err_t AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
418
418
VERIFY (_ble_event_sem, NRF_ERROR_NO_MEM);
419
419
420
420
TaskHandle_t ble_task_hdl;
421
- xTaskCreate ( adafruit_ble_task, " SD BLE" , CFG_BLE_TASK_STACKSIZE, NULL , TASK_PRIO_HIGH, &ble_task_hdl);
421
+ xTaskCreate ( adafruit_ble_task, " BLE" , CFG_BLE_TASK_STACKSIZE, NULL , TASK_PRIO_HIGH, &ble_task_hdl);
422
422
423
423
// Create RTOS Semaphore & Task for SOC Event
424
424
_soc_event_sem = xSemaphoreCreateBinary ();
425
425
VERIFY (_soc_event_sem, NRF_ERROR_NO_MEM);
426
426
427
427
TaskHandle_t soc_task_hdl;
428
- xTaskCreate ( adafruit_soc_task, " SD SOC" , CFG_SOC_TASK_STACKSIZE, NULL , TASK_PRIO_HIGH, &soc_task_hdl);
428
+ xTaskCreate ( adafruit_soc_task, " SOC" , CFG_SOC_TASK_STACKSIZE, NULL , TASK_PRIO_HIGH, &soc_task_hdl);
429
429
430
430
NVIC_SetPriority (SD_EVT_IRQn, 6 );
431
431
NVIC_EnableIRQ (SD_EVT_IRQn);
@@ -629,142 +629,6 @@ bool AdafruitBluefruit::setPIN(const char* pin)
629
629
}
630
630
)
631
631
632
- void Bluefruit_printInfo(void )
633
- {
634
- Bluefruit.printInfo ();
635
- }
636
-
637
- void AdafruitBluefruit::printInfo (void )
638
- {
639
- // Skip if Serial is not initialised
640
- if ( !Serial ) return ;
641
-
642
- // Skip if Bluefruit.begin() is not called
643
- if ( _ble_event_sem == NULL ) return ;
644
-
645
- Serial.println (" --------- SoftDevice Config ---------" );
646
-
647
- char const * title_fmt = " %-16s: " ;
648
-
649
- /* ------------- SoftDevice Config -------------*/
650
- // Max uuid128
651
- Serial.printf (title_fmt, " Max UUID128" );
652
- Serial.println (_sd_cfg.uuid128_max );
653
-
654
- // ATTR Table Size
655
- Serial.printf (title_fmt, " ATTR Table Size" );
656
- Serial.println (_sd_cfg.attr_table_size );
657
-
658
- // Service Changed
659
- Serial.printf (title_fmt, " Service Changed" );
660
- Serial.println (_sd_cfg.service_changed );
661
-
662
- if ( _prph_count )
663
- {
664
- Serial.println (" Peripheral Connect Setting" );
665
-
666
- Serial.print (" - " );
667
- Serial.printf (title_fmt, " Max MTU" );
668
- Serial.println (Gap._cfg_prph .mtu_max );
669
-
670
- Serial.print (" - " );
671
- Serial.printf (title_fmt, " Event Length" );
672
- Serial.println (Gap._cfg_prph .event_len );
673
-
674
- Serial.print (" - " );
675
- Serial.printf (title_fmt, " HVN Queue Size" );
676
- Serial.println (Gap._cfg_prph .hvn_tx_qsize );
677
-
678
- Serial.print (" - " );
679
- Serial.printf (title_fmt, " WrCmd Queue Size" );
680
- Serial.println (Gap._cfg_prph .wr_cmd_qsize );
681
- }
682
-
683
- if ( _central_count )
684
- {
685
- Serial.println (" Central Connect Setting" );
686
-
687
- Serial.print (" - " );
688
- Serial.printf (title_fmt, " Max MTU" );
689
- Serial.println (Gap._cfg_central .mtu_max );
690
-
691
- Serial.print (" - " );
692
- Serial.printf (title_fmt, " Event Length" );
693
- Serial.println (Gap._cfg_central .event_len );
694
-
695
- Serial.print (" - " );
696
- Serial.printf (title_fmt, " HVN Queue Size" );
697
- Serial.println (Gap._cfg_central .hvn_tx_qsize );
698
-
699
- Serial.print (" - " );
700
- Serial.printf (title_fmt, " WrCmd Queue Size" );
701
- Serial.println (Gap._cfg_central .wr_cmd_qsize );
702
- }
703
-
704
- /* ------------- Settings -------------*/
705
- Serial.println (" \n --------- BLE Settings ---------" );
706
- // Name
707
- Serial.printf (title_fmt, " Name" );
708
- {
709
- char name[32 ];
710
- memclr (name, sizeof (name));
711
- getName (name, sizeof (name));
712
- Serial.printf (name);
713
- }
714
- Serial.println ();
715
-
716
- // Max Connections
717
- Serial.printf (title_fmt, " Max Connections" );
718
- Serial.printf (" Peripheral = %d, " , _prph_count ? 1 : 0 );
719
- Serial.printf (" Central = %d " , _central_count ? BLE_CENTRAL_MAX_CONN : 0 );
720
- Serial.println ();
721
-
722
- // Address
723
- Serial.printf (title_fmt, " Address" );
724
- {
725
- char const * type_str[] = { " Public" , " Static" , " Private Resolvable" , " Private Non Resolvable" };
726
- uint8_t mac[6 ];
727
- uint8_t type = Gap.getAddr (mac);
728
-
729
- // MAC is in little endian --> print reverse
730
- Serial.printBufferReverse (mac, 6 , ' :' );
731
- Serial.printf (" (%s)" , type_str[type]);
732
- }
733
- Serial.println ();
734
-
735
- // Tx Power
736
- Serial.printf (title_fmt, " TX Power" );
737
- Serial.printf (" %d dBm" , _tx_power);
738
- Serial.println ();
739
-
740
- // Connection Intervals
741
- Serial.printf (title_fmt, " Conn Intervals" );
742
- Serial.printf (" min = %.2f ms, " , _ppcp_min_conn*1 .25f );
743
- Serial.printf (" max = %.2f ms" , _ppcp_max_conn*1 .25f );
744
- Serial.println ();
745
-
746
- Serial.printf (title_fmt, " Conn Timeout" );
747
- Serial.printf (" %.2f ms" , _ppcp_conn_sup_timeout*10 .0f );
748
- Serial.println ();
749
-
750
- /* ------------- List the paried device -------------*/
751
- if ( _prph_count )
752
- {
753
- Serial.printf (title_fmt, " Peripheral Paired Devices" );
754
- Serial.println ();
755
- bond_print_list (BLE_GAP_ROLE_PERIPH);
756
- }
757
-
758
- if ( _central_count )
759
- {
760
- Serial.printf (title_fmt, " Central Paired Devices" );
761
- Serial.println ();
762
- bond_print_list (BLE_GAP_ROLE_CENTRAL);
763
- }
764
-
765
- Serial.println ();
766
- }
767
-
768
632
/* ------------------------------------------------------------------*/
769
633
/* Thread & SoftDevice Event handler
770
634
*------------------------------------------------------------------*/
@@ -776,7 +640,7 @@ void SD_EVT_IRQHandler(void)
776
640
}
777
641
778
642
/* *
779
- * Handle SOC event such as FLASH opertion
643
+ * Handle SOC event such as FLASH operation
780
644
*/
781
645
void adafruit_soc_task (void * arg)
782
646
{
@@ -790,10 +654,8 @@ void adafruit_soc_task(void* arg)
790
654
uint32_t err = ERROR_NONE;
791
655
792
656
// until no more pending events
793
- while ( NRF_ERROR_NOT_FOUND != err )
657
+ while ( NRF_ERROR_NOT_FOUND != ( err = sd_evt_get (&soc_evt)) )
794
658
{
795
- err = sd_evt_get (&soc_evt);
796
-
797
659
if (ERROR_NONE == err)
798
660
{
799
661
switch (soc_evt)
@@ -805,8 +667,8 @@ void adafruit_soc_task(void* arg)
805
667
if ( flash_nrf5x_event_cb ) flash_nrf5x_event_cb (soc_evt);
806
668
break ;
807
669
670
+ #ifdef NRF52840_XXAA
808
671
/* ------------- usb power event handler -------------*/
809
- #ifdef NRF52840_XXAA
810
672
case NRF_EVT_POWER_USB_DETECTED:
811
673
case NRF_EVT_POWER_USB_POWER_READY:
812
674
case NRF_EVT_POWER_USB_REMOVED:
@@ -818,7 +680,7 @@ void adafruit_soc_task(void* arg)
818
680
if ( usbevt >= 0 ) tusb_hal_nrf_power_event (usbevt);
819
681
}
820
682
break ;
821
- #endif
683
+ #endif
822
684
823
685
default : break ;
824
686
}
@@ -998,3 +860,142 @@ void AdafruitBluefruit::clearBonds(void)
998
860
bond_clear_prph ();
999
861
}
1000
862
863
+ // --------------------------------------------------------------------+
864
+ //
865
+ // --------------------------------------------------------------------+
866
+
867
+ void Bluefruit_printInfo (void )
868
+ {
869
+ Bluefruit.printInfo ();
870
+ }
871
+
872
+ void AdafruitBluefruit::printInfo (void )
873
+ {
874
+ // Skip if Serial is not initialised
875
+ if ( !Serial ) return ;
876
+
877
+ // Skip if Bluefruit.begin() is not called
878
+ if ( _ble_event_sem == NULL ) return ;
879
+
880
+ Serial.println (" --------- SoftDevice Config ---------" );
881
+
882
+ char const * title_fmt = " %-16s: " ;
883
+
884
+ /* ------------- SoftDevice Config -------------*/
885
+ // Max uuid128
886
+ Serial.printf (title_fmt, " Max UUID128" );
887
+ Serial.println (_sd_cfg.uuid128_max );
888
+
889
+ // ATTR Table Size
890
+ Serial.printf (title_fmt, " ATTR Table Size" );
891
+ Serial.println (_sd_cfg.attr_table_size );
892
+
893
+ // Service Changed
894
+ Serial.printf (title_fmt, " Service Changed" );
895
+ Serial.println (_sd_cfg.service_changed );
896
+
897
+ if ( _prph_count )
898
+ {
899
+ Serial.println (" Peripheral Connect Setting" );
900
+
901
+ Serial.print (" - " );
902
+ Serial.printf (title_fmt, " Max MTU" );
903
+ Serial.println (Gap._cfg_prph .mtu_max );
904
+
905
+ Serial.print (" - " );
906
+ Serial.printf (title_fmt, " Event Length" );
907
+ Serial.println (Gap._cfg_prph .event_len );
908
+
909
+ Serial.print (" - " );
910
+ Serial.printf (title_fmt, " HVN Queue Size" );
911
+ Serial.println (Gap._cfg_prph .hvn_tx_qsize );
912
+
913
+ Serial.print (" - " );
914
+ Serial.printf (title_fmt, " WrCmd Queue Size" );
915
+ Serial.println (Gap._cfg_prph .wr_cmd_qsize );
916
+ }
917
+
918
+ if ( _central_count )
919
+ {
920
+ Serial.println (" Central Connect Setting" );
921
+
922
+ Serial.print (" - " );
923
+ Serial.printf (title_fmt, " Max MTU" );
924
+ Serial.println (Gap._cfg_central .mtu_max );
925
+
926
+ Serial.print (" - " );
927
+ Serial.printf (title_fmt, " Event Length" );
928
+ Serial.println (Gap._cfg_central .event_len );
929
+
930
+ Serial.print (" - " );
931
+ Serial.printf (title_fmt, " HVN Queue Size" );
932
+ Serial.println (Gap._cfg_central .hvn_tx_qsize );
933
+
934
+ Serial.print (" - " );
935
+ Serial.printf (title_fmt, " WrCmd Queue Size" );
936
+ Serial.println (Gap._cfg_central .wr_cmd_qsize );
937
+ }
938
+
939
+ /* ------------- Settings -------------*/
940
+ Serial.println (" \n --------- BLE Settings ---------" );
941
+ // Name
942
+ Serial.printf (title_fmt, " Name" );
943
+ {
944
+ char name[32 ];
945
+ memclr (name, sizeof (name));
946
+ getName (name, sizeof (name));
947
+ Serial.printf (name);
948
+ }
949
+ Serial.println ();
950
+
951
+ // Max Connections
952
+ Serial.printf (title_fmt, " Max Connections" );
953
+ Serial.printf (" Peripheral = %d, " , _prph_count ? 1 : 0 );
954
+ Serial.printf (" Central = %d " , _central_count ? BLE_CENTRAL_MAX_CONN : 0 );
955
+ Serial.println ();
956
+
957
+ // Address
958
+ Serial.printf (title_fmt, " Address" );
959
+ {
960
+ char const * type_str[] = { " Public" , " Static" , " Private Resolvable" , " Private Non Resolvable" };
961
+ uint8_t mac[6 ];
962
+ uint8_t type = Gap.getAddr (mac);
963
+
964
+ // MAC is in little endian --> print reverse
965
+ Serial.printBufferReverse (mac, 6 , ' :' );
966
+ Serial.printf (" (%s)" , type_str[type]);
967
+ }
968
+ Serial.println ();
969
+
970
+ // Tx Power
971
+ Serial.printf (title_fmt, " TX Power" );
972
+ Serial.printf (" %d dBm" , _tx_power);
973
+ Serial.println ();
974
+
975
+ // Connection Intervals
976
+ Serial.printf (title_fmt, " Conn Intervals" );
977
+ Serial.printf (" min = %.2f ms, " , _ppcp_min_conn*1 .25f );
978
+ Serial.printf (" max = %.2f ms" , _ppcp_max_conn*1 .25f );
979
+ Serial.println ();
980
+
981
+ Serial.printf (title_fmt, " Conn Timeout" );
982
+ Serial.printf (" %.2f ms" , _ppcp_conn_sup_timeout*10 .0f );
983
+ Serial.println ();
984
+
985
+ /* ------------- List the paried device -------------*/
986
+ if ( _prph_count )
987
+ {
988
+ Serial.printf (title_fmt, " Peripheral Paired Devices" );
989
+ Serial.println ();
990
+ bond_print_list (BLE_GAP_ROLE_PERIPH);
991
+ }
992
+
993
+ if ( _central_count )
994
+ {
995
+ Serial.printf (title_fmt, " Central Paired Devices" );
996
+ Serial.println ();
997
+ bond_print_list (BLE_GAP_ROLE_CENTRAL);
998
+ }
999
+
1000
+ Serial.println ();
1001
+ }
0 commit comments