@@ -617,6 +617,139 @@ static uint8_t dfu_srv_apply(const void *cmd, uint16_t cmd_len,
617
617
}
618
618
#endif
619
619
620
+ #ifdef CONFIG_BT_MESH_PRIV_BEACON_CLI
621
+ static struct bt_mesh_priv_beacon_cli priv_beacon_cli ;
622
+
623
+ static uint8_t priv_beacon_get (const void * cmd , uint16_t cmd_len ,
624
+ void * rsp , uint16_t * rsp_len )
625
+ {
626
+ const struct btp_priv_beacon_get_cmd * cp = cmd ;
627
+
628
+ struct bt_mesh_priv_beacon val ;
629
+ int err ;
630
+
631
+ err = bt_mesh_priv_beacon_cli_get (net .net_idx , cp -> dst , & val );
632
+ if (err ) {
633
+ LOG_ERR ("Failed to send Private Beacon Get (err %d)" , err );
634
+ return BTP_STATUS_FAILED ;
635
+ }
636
+
637
+ LOG_DBG ("Private Beacon state: %u, %u" , val .enabled , val .rand_interval );
638
+ return BTP_STATUS_SUCCESS ;
639
+ }
640
+
641
+ static uint8_t priv_beacon_set (const void * cmd , uint16_t cmd_len ,
642
+ void * rsp , uint16_t * rsp_len )
643
+ {
644
+ const struct btp_priv_beacon_set_cmd * cp = cmd ;
645
+ struct bt_mesh_priv_beacon val ;
646
+ int err ;
647
+
648
+ val .enabled = cp -> enabled ;
649
+ val .rand_interval = cp -> rand_interval ;
650
+
651
+ err = bt_mesh_priv_beacon_cli_set (net .net_idx , cp -> dst , & val );
652
+ if (err ) {
653
+ LOG_ERR ("Failed to send Private Beacon Set (err %d)" , err );
654
+ return BTP_STATUS_FAILED ;
655
+ }
656
+
657
+ return BTP_STATUS_SUCCESS ;
658
+ }
659
+
660
+ static uint8_t priv_gatt_proxy_get (const void * cmd , uint16_t cmd_len ,
661
+ void * rsp , uint16_t * rsp_len )
662
+ {
663
+ const struct btp_priv_gatt_proxy_get_cmd * cp = cmd ;
664
+
665
+ uint8_t state ;
666
+ int err ;
667
+
668
+ err = bt_mesh_priv_beacon_cli_gatt_proxy_get (net .net_idx , cp -> dst , & state );
669
+ if (err ) {
670
+ LOG_ERR ("Failed to send Private GATT Proxy Get (err %d)" , err );
671
+ return BTP_STATUS_FAILED ;
672
+ }
673
+
674
+ LOG_DBG ("Private GATT Proxy state: %u" , state );
675
+ return BTP_STATUS_SUCCESS ;
676
+ }
677
+
678
+ static uint8_t priv_gatt_proxy_set (const void * cmd , uint16_t cmd_len ,
679
+ void * rsp , uint16_t * rsp_len )
680
+ {
681
+ const struct btp_priv_gatt_proxy_set_cmd * cp = cmd ;
682
+
683
+ uint8_t state ;
684
+ int err ;
685
+
686
+ state = cp -> state ;
687
+
688
+ err = bt_mesh_priv_beacon_cli_gatt_proxy_set (net .net_idx , cp -> dst , & state );
689
+ if (err ) {
690
+ LOG_ERR ("Failed to send Private GATT Proxy Set (err %d)" , err );
691
+ return BTP_STATUS_FAILED ;
692
+ }
693
+
694
+ return BTP_STATUS_SUCCESS ;
695
+ }
696
+
697
+ static uint8_t priv_node_id_get (const void * cmd , uint16_t cmd_len ,
698
+ void * rsp , uint16_t * rsp_len )
699
+ {
700
+ const struct btp_priv_node_id_get_cmd * cp = cmd ;
701
+ struct bt_mesh_priv_node_id val ;
702
+ uint16_t key_net_idx ;
703
+ int err ;
704
+
705
+ key_net_idx = cp -> key_net_idx ;
706
+
707
+ err = bt_mesh_priv_beacon_cli_node_id_get (net .net_idx , cp -> dst , key_net_idx , & val );
708
+ if (err ) {
709
+ LOG_ERR ("Failed to send Private Node Identity Get (err %d)" , err );
710
+ return BTP_STATUS_FAILED ;
711
+ }
712
+
713
+ LOG_DBG ("Private Node Identity state: %u %u %u" , val .net_idx , val .state , val .status );
714
+ return BTP_STATUS_SUCCESS ;
715
+ }
716
+
717
+ static uint8_t priv_node_id_set (const void * cmd , uint16_t cmd_len ,
718
+ void * rsp , uint16_t * rsp_len )
719
+ {
720
+ const struct btp_priv_node_id_set_cmd * cp = cmd ;
721
+ struct bt_mesh_priv_node_id val ;
722
+ int err ;
723
+
724
+ val .net_idx = cp -> net_idx ;
725
+ val .state = cp -> state ;
726
+
727
+ err = bt_mesh_priv_beacon_cli_node_id_set (net .net_idx , cp -> dst , & val );
728
+ if (err ) {
729
+ LOG_ERR ("Failed to send Private Node Identity Set (err %d)" , err );
730
+ return BTP_STATUS_FAILED ;
731
+ }
732
+
733
+ return BTP_STATUS_SUCCESS ;
734
+ }
735
+
736
+ static uint8_t proxy_private_identity_enable (const void * cmd , uint16_t cmd_len ,
737
+ void * rsp , uint16_t * rsp_len )
738
+ {
739
+ int err ;
740
+
741
+ LOG_DBG ("" );
742
+
743
+ err = bt_mesh_proxy_private_identity_enable ();
744
+ if (err ) {
745
+ LOG_ERR ("Failed to enable proxy private identity (err %d)" , err );
746
+ return BTP_STATUS_FAILED ;
747
+ }
748
+
749
+ return BTP_STATUS_SUCCESS ;
750
+ }
751
+ #endif
752
+
620
753
static struct bt_mesh_model root_models [] = {
621
754
BT_MESH_MODEL_CFG_SRV ,
622
755
BT_MESH_MODEL_CFG_CLI (& cfg_cli ),
@@ -655,6 +788,12 @@ static struct bt_mesh_model root_models[] = {
655
788
#if defined(CONFIG_BT_MESH_BLOB_CLI ) && !defined (CONFIG_BT_MESH_DFD_SRV )
656
789
BT_MESH_MODEL_BLOB_CLI (& blob_cli ),
657
790
#endif
791
+ #if defined(CONFIG_BT_MESH_PRIV_BEACON_SRV )
792
+ BT_MESH_MODEL_PRIV_BEACON_SRV ,
793
+ #endif
794
+ #if defined(CONFIG_BT_MESH_PRIV_BEACON_CLI )
795
+ BT_MESH_MODEL_PRIV_BEACON_CLI (& priv_beacon_cli ),
796
+ #endif
658
797
};
659
798
struct model_data * lookup_model_bound (uint16_t id )
660
799
{
@@ -4576,6 +4715,44 @@ static const struct btp_handler handlers[] = {
4576
4715
.expect_len = sizeof (struct btp_rpr_reprov_remote_cmd ),
4577
4716
.func = rpr_reprov_remote
4578
4717
},
4718
+ #endif
4719
+ #if defined(CONFIG_BT_MESH_PRIV_BEACON_CLI )
4720
+ {
4721
+ .opcode = BTP_MESH_PRIV_BEACON_GET ,
4722
+ .expect_len = sizeof (struct btp_priv_beacon_get_cmd ),
4723
+ .func = priv_beacon_get
4724
+ },
4725
+ {
4726
+ .opcode = BTP_MESH_PRIV_BEACON_SET ,
4727
+ .expect_len = sizeof (struct btp_priv_beacon_set_cmd ),
4728
+ .func = priv_beacon_set
4729
+ },
4730
+ {
4731
+ .opcode = BTP_MESH_PRIV_GATT_PROXY_GET ,
4732
+ .expect_len = sizeof (struct btp_priv_gatt_proxy_get_cmd ),
4733
+ .func = priv_gatt_proxy_get
4734
+ },
4735
+ {
4736
+ .opcode = BTP_MESH_PRIV_GATT_PROXY_SET ,
4737
+ .expect_len = sizeof (struct btp_priv_gatt_proxy_set_cmd ),
4738
+ .func = priv_gatt_proxy_set
4739
+ },
4740
+ {
4741
+ .opcode = BTP_MESH_PRIV_NODE_ID_GET ,
4742
+ .expect_len = sizeof (struct btp_priv_node_id_get_cmd ),
4743
+ .func = priv_node_id_get
4744
+ },
4745
+ {
4746
+ .opcode = BTP_MESH_PRIV_NODE_ID_SET ,
4747
+ .expect_len = sizeof (struct btp_priv_node_id_set_cmd ),
4748
+ .func = priv_node_id_set
4749
+ },
4750
+ {
4751
+ .opcode = BTP_MESH_PROXY_PRIVATE_IDENTITY ,
4752
+ .expect_len = 0 ,
4753
+ .func = proxy_private_identity_enable
4754
+ },
4755
+ #endif
4579
4756
};
4580
4757
4581
4758
0 commit comments