Skip to content

Commit a833421

Browse files
KKopyscinskijhedberg
authored andcommitted
tests: Bluetooth: tester: add support for Proxy Solicitation
Adds BTP commands implemantation needed to pass tests for Proxy Solicitation. Signed-off-by: Krzysztof Kopyściński <[email protected]>
1 parent 2ad0eaa commit a833421

File tree

2 files changed

+165
-0
lines changed

2 files changed

+165
-0
lines changed

tests/bluetooth/tester/src/btp/btp_mesh.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,33 @@ struct btp_priv_node_id_set_cmd {
10091009

10101010
#define BTP_MESH_PROXY_PRIVATE_IDENTITY 0x72
10111011

1012+
#define BTP_MESH_OD_PRIV_PROXY_GET 0x73
1013+
struct btp_od_priv_proxy_get_cmd {
1014+
uint16_t dst;
1015+
} __packed;
1016+
1017+
#define BTP_MESH_OD_PRIV_PROXY_SET 0x74
1018+
1019+
struct btp_od_priv_proxy_set_cmd {
1020+
uint16_t dst;
1021+
uint8_t val;
1022+
} __packed;
1023+
1024+
#define BTP_MESH_SRPL_CLEAR 0x75
1025+
1026+
struct btp_srpl_clear_cmd {
1027+
uint16_t dst;
1028+
uint16_t range_start;
1029+
uint8_t range_len;
1030+
uint8_t acked;
1031+
} __packed;
1032+
1033+
#define BTP_MESH_PROXY_SOLICIT 0x76
1034+
1035+
struct btp_proxy_solicit_cmd {
1036+
uint16_t net_idx;
1037+
} __packed;
1038+
10121039
/* events */
10131040
#define BTP_MESH_EV_OUT_NUMBER_ACTION 0x80
10141041
struct btp_mesh_out_number_action_ev {

tests/bluetooth/tester/src/btp_mesh.c

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,108 @@ static uint8_t proxy_private_identity_enable(const void *cmd, uint16_t cmd_len,
773773
}
774774
#endif
775775

776+
#if defined(CONFIG_BT_MESH_SOL_PDU_RPL_CLI)
777+
static struct bt_mesh_sol_pdu_rpl_cli srpl_cli;
778+
#endif
779+
780+
781+
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)
782+
static struct bt_mesh_od_priv_proxy_cli od_priv_proxy_cli;
783+
784+
static uint8_t od_priv_proxy_get(const void *cmd, uint16_t cmd_len,
785+
void *rsp, uint16_t *rsp_len)
786+
{
787+
const struct btp_od_priv_proxy_get_cmd *cp = cmd;
788+
uint8_t val_rsp;
789+
int err;
790+
791+
LOG_DBG("");
792+
793+
err = bt_mesh_od_priv_proxy_cli_get(net.net_idx, cp->dst, &val_rsp);
794+
if (err) {
795+
LOG_ERR("Failed to get On-Demand Private Proxy state (err %d)", err);
796+
return BTP_STATUS_FAILED;
797+
}
798+
799+
LOG_DBG("On-Demand Private Proxy state: %u", val_rsp);
800+
801+
return BTP_STATUS_SUCCESS;
802+
}
803+
804+
static uint8_t od_priv_proxy_set(const void *cmd, uint16_t cmd_len,
805+
void *rsp, uint16_t *rsp_len)
806+
{
807+
const struct btp_od_priv_proxy_set_cmd *cp = cmd;
808+
uint8_t val_rsp;
809+
int err;
810+
811+
LOG_DBG("");
812+
813+
err = bt_mesh_od_priv_proxy_cli_set(net.net_idx, cp->dst, cp->val, &val_rsp);
814+
if (err) {
815+
LOG_ERR("Failed to set On-Demand Private Proxy state (err %d)", err);
816+
return BTP_STATUS_FAILED;
817+
}
818+
819+
LOG_DBG("On-Demand Private Proxy set state: %u", val_rsp);
820+
821+
return BTP_STATUS_SUCCESS;
822+
}
823+
824+
#endif
825+
826+
#if defined(CONFIG_BT_MESH_SOL_PDU_RPL_CLI)
827+
static uint8_t srpl_clear(const void *cmd, uint16_t cmd_len,
828+
void *rsp, uint16_t *rsp_len)
829+
{
830+
const struct btp_srpl_clear_cmd *cp = cmd;
831+
uint16_t app_idx = BT_MESH_KEY_UNUSED;
832+
uint16_t start_rsp;
833+
uint8_t len_rsp;
834+
int err;
835+
836+
/* Lookup source address */
837+
for (int i = 0; i < ARRAY_SIZE(model_bound); i++) {
838+
if (model_bound[i].model->id == BT_MESH_MODEL_ID_SOL_PDU_RPL_CLI) {
839+
app_idx = model_bound[i].appkey_idx;
840+
break;
841+
}
842+
}
843+
844+
struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(app_idx, cp->dst);
845+
846+
if (cp->acked) {
847+
err = bt_mesh_sol_pdu_rpl_clear(&ctx, cp->range_start, cp->range_len, &start_rsp,
848+
&len_rsp);
849+
} else {
850+
err = bt_mesh_sol_pdu_rpl_clear_unack(&ctx, cp->range_start, cp->range_len);
851+
}
852+
if (err) {
853+
LOG_ERR("Failed to clear SRPL (err %d)", err);
854+
return BTP_STATUS_FAILED;
855+
}
856+
857+
return BTP_STATUS_SUCCESS;
858+
}
859+
#endif
860+
861+
#if defined(CONFIG_BT_MESH_PROXY_SOLICITATION)
862+
static uint8_t proxy_solicit(const void *cmd, uint16_t cmd_len,
863+
void *rsp, uint16_t *rsp_len)
864+
{
865+
const struct btp_proxy_solicit_cmd *cp = cmd;
866+
int err;
867+
868+
err = bt_mesh_proxy_solicit(cp->net_idx);
869+
if (err) {
870+
LOG_ERR("Failed to advertise solicitation PDU (err %d)", err);
871+
return BTP_STATUS_FAILED;
872+
}
873+
874+
return BTP_STATUS_SUCCESS;
875+
}
876+
#endif /* CONFIG_BT_MESH_PROXY_SOLICITATION */
877+
776878
static struct bt_mesh_model root_models[] = {
777879
BT_MESH_MODEL_CFG_SRV,
778880
BT_MESH_MODEL_CFG_CLI(&cfg_cli),
@@ -817,6 +919,16 @@ static struct bt_mesh_model root_models[] = {
817919
#if defined(CONFIG_BT_MESH_PRIV_BEACON_CLI)
818920
BT_MESH_MODEL_PRIV_BEACON_CLI(&priv_beacon_cli),
819921
#endif
922+
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)
923+
BT_MESH_MODEL_OD_PRIV_PROXY_CLI(&od_priv_proxy_cli),
924+
#endif
925+
#if defined(CONFIG_BT_MESH_SOL_PDU_RPL_CLI)
926+
BT_MESH_MODEL_SOL_PDU_RPL_CLI(&srpl_cli),
927+
#endif
928+
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_SRV)
929+
BT_MESH_MODEL_OD_PRIV_PROXY_SRV,
930+
#endif
931+
820932
};
821933
struct model_data *lookup_model_bound(uint16_t id)
822934
{
@@ -4783,6 +4895,32 @@ static const struct btp_handler handlers[] = {
47834895
.func = proxy_private_identity_enable
47844896
},
47854897
#endif
4898+
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)
4899+
{
4900+
.opcode = BTP_MESH_OD_PRIV_PROXY_GET,
4901+
.expect_len = sizeof(struct btp_od_priv_proxy_get_cmd),
4902+
.func = od_priv_proxy_get
4903+
},
4904+
{
4905+
.opcode = BTP_MESH_OD_PRIV_PROXY_SET,
4906+
.expect_len = sizeof(struct btp_od_priv_proxy_set_cmd),
4907+
.func = od_priv_proxy_set
4908+
},
4909+
#endif
4910+
#if defined(CONFIG_BT_MESH_SOL_PDU_RPL_CLI)
4911+
{
4912+
.opcode = BTP_MESH_SRPL_CLEAR,
4913+
.expect_len = sizeof(struct btp_srpl_clear_cmd),
4914+
.func = srpl_clear
4915+
},
4916+
#endif
4917+
#if defined(CONFIG_BT_MESH_SOLICITATION)
4918+
{
4919+
.opcode = BTP_MESH_PROXY_SOLICIT,
4920+
.expect_len = sizeof(struct btp_proxy_solicit_cmd),
4921+
.func = proxy_solicit
4922+
},
4923+
#endif
47864924
};
47874925

47884926

0 commit comments

Comments
 (0)