Import Mbed OS hard-float snapshot
This commit is contained in:
1654
TEST_APPS/device/nanostack_mac_tester/source/mac_commands.cpp
Normal file
1654
TEST_APPS/device/nanostack_mac_tester/source/mac_commands.cpp
Normal file
File diff suppressed because it is too large
Load Diff
65
TEST_APPS/device/nanostack_mac_tester/source/mac_commands.h
Normal file
65
TEST_APPS/device/nanostack_mac_tester/source/mac_commands.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MAC_COMMANDS_H_
|
||||
#define MAC_COMMANDS_H_
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ns_cmdline.h"
|
||||
#include "nsdynmemLIB.h"
|
||||
#include "mbed_trace.h"
|
||||
#include "mac_api.h"
|
||||
#include "mlme.h"
|
||||
#include "mac_mcps.h"
|
||||
#include "mac_common_defines.h"
|
||||
#include "mac_filter_api.h"
|
||||
#include "mac_tester_util.h"
|
||||
|
||||
#define LOOKUP_DESCRIPTOR_TABLE_SIZE 2
|
||||
#define DEVICE_DESCRIPTOR_TABLE_SIZE 2
|
||||
#define USAGE_DESCRIPTOR_TABLE_SIZE 2
|
||||
#define KEY_DESCRIPTOR_TABLE_SIZE 2
|
||||
|
||||
void mac_commands_init(void);
|
||||
|
||||
void mac_data_confirm_handler(const mac_api_t *api, const mcps_data_conf_t *data);
|
||||
void mac_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *data);
|
||||
void mac_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data);
|
||||
void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const void *data);
|
||||
void mac_mlme_indication_handler(const mac_api_t *api, mlme_primitive id, const void *data);
|
||||
|
||||
int mac_start_command(int argc, char *argv[]);
|
||||
int mac_scan_command(int argc, char *argv[]);
|
||||
int mac_data_command(int argc, char *argv[]);
|
||||
int mac_poll_command(int argc, char *argv[]);
|
||||
int mac_purge_command(int argc, char *argv[]);
|
||||
int mac_set_command(int argc, char *argv[]);
|
||||
int mac_get_command(int argc, char *argv[]);
|
||||
int mac_reset_command(int argc, char *argv[]);
|
||||
int mac_address_command(int argc, char *argv[]);
|
||||
int mac_key_command(int argc, char *argv[]);
|
||||
int mac_add_neighbour_command(int argc, char *argv[]);
|
||||
int mac_filter_command(int argc, char *argv[]);
|
||||
int mac_config_status_command(int argc, char *argv[]);
|
||||
int mac_find_beacon_command(int argc, char *argv[]);
|
||||
int mac_wait_command(int argc, char *argv[]);
|
||||
int mac_analyze_ed_command(int argc, char *argv[]);
|
||||
int reset_command(int argc, char *argv[]);
|
||||
int silent_mode_command(int argc, char *argv[]);
|
||||
|
||||
#endif
|
||||
124
TEST_APPS/device/nanostack_mac_tester/source/mac_tester_util.cpp
Normal file
124
TEST_APPS/device/nanostack_mac_tester/source/mac_tester_util.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "mac_tester_util.h"
|
||||
|
||||
int string_to_bytes(const char *str, uint8_t *buf, int bytes)
|
||||
{
|
||||
int len = strlen(str);
|
||||
|
||||
if (len <= (3 * bytes - 1)) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < bytes; ++i) {
|
||||
if (i * 3 < len) {
|
||||
buf[i] = (uint8_t)strtoul(str + i * 3, NULL, 16);
|
||||
} else {
|
||||
buf[i] = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *mlme_status_string(uint8_t status)
|
||||
{
|
||||
switch (status) {
|
||||
case MLME_SUCCESS:
|
||||
return "MLME_SUCCESS";
|
||||
case MLME_BUSY_CHAN:
|
||||
return "MLME_BUSY_CHAN";
|
||||
case MLME_BUSY_RX:
|
||||
return "MLME_BUSY_RX";
|
||||
case MLME_BUSY_TX:
|
||||
return "MLME_BUSY_TX";
|
||||
case MLME_FORCE_TRX_OFF:
|
||||
return "MLME_FORCE_TRX_OFF";
|
||||
case MLME_IDLE:
|
||||
return "MLME_IDLE";
|
||||
case MLME_RX_ON:
|
||||
return "MLME_RX_ON";
|
||||
case MLME_TRX_OFF:
|
||||
return "MLME_TRX_OFF";
|
||||
case MLME_TX_ON:
|
||||
return "MLME_TX_ON";
|
||||
case MLME_COUNTER_ERROR:
|
||||
return "MLME_COUNTER_ERROR";
|
||||
case MLME_IMPROPER_KEY_TYPE:
|
||||
return "MLME_IMPROPER_KEY_TYPE";
|
||||
case MLME_IMPROPER_SECURITY_LEVEL:
|
||||
return "MLME_IMPROPER_SECURITY_LEVEL";
|
||||
case MLME_UNSUPPORTED_LEGACY:
|
||||
return "MLME_UNSUPPORTED_LEGACY";
|
||||
case MLME_UNSUPPORTED_SECURITY:
|
||||
return "MLME_UNSUPPORTED_SECURITY";
|
||||
case MLME_SECURITY_FAIL:
|
||||
return "MLME_SECURITY_FAIL";
|
||||
case MLME_FRAME_TOO_LONG:
|
||||
return "MLME_FRAME_TOO_LONG";
|
||||
case MLME_INVALID_HANDLE:
|
||||
return "MLME_INVALID_HANDLE";
|
||||
case MLME_INVALID_PARAMETER:
|
||||
return "MLME_INVALID_PARAMETER";
|
||||
case MLME_TX_NO_ACK:
|
||||
return "MLME_TX_NO_ACK";
|
||||
case MLME_NO_BEACON:
|
||||
return "MLME_NO_BEACON";
|
||||
case MLME_NO_DATA:
|
||||
return "MLME_NO_DATA";
|
||||
case MLME_NO_SHORT_ADDRESS:
|
||||
return "MLME_NO_SHORT_ADDRESS";
|
||||
case MLME_PAN_ID_CONFLICT:
|
||||
return "MLME_PAN_ID_CONFLICT";
|
||||
case MLME_TRANSACTION_EXPIRED:
|
||||
return "MLME_TRANSACTION_EXPIRED";
|
||||
case MLME_TRANSACTION_OVERFLOW:
|
||||
return "MLME_TRANSACTION_OVERFLOW";
|
||||
case MLME_UNAVAILABLE_KEY:
|
||||
return "MLME_UNAVAILABLE_KEY";
|
||||
case MLME_UNSUPPORTED_ATTRIBUTE:
|
||||
return "MLME_UNSUPPORTED_ATTRIBUTE";
|
||||
case MLME_INVALID_ADDRESS:
|
||||
return "MLME_INVALID_ADDRESS";
|
||||
case MLME_INVALID_INDEX:
|
||||
return "MLME_INVALID_INDEX";
|
||||
case MLME_LIMIT_REACHED:
|
||||
return "MLME_LIMIT_REACHED";
|
||||
case MLME_READ_ONLY:
|
||||
return "MLME_READ_ONLY";
|
||||
case MLME_SCAN_IN_PROGRESS:
|
||||
return "MLME_SCAN_IN_PROGRESS";
|
||||
case MLME_DATA_POLL_NOTIFICATION:
|
||||
return "MLME_DATA_POLL_NOTIFICATION";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int channel_from_mask(uint32_t channel_mask, int index)
|
||||
{
|
||||
int expected_index = 0;
|
||||
for (int i = 0; i < 27; ++i) {
|
||||
if ((channel_mask >> i) & 1) {
|
||||
if (expected_index == index) {
|
||||
return i;
|
||||
}
|
||||
++expected_index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef UTIL_H_
|
||||
#define UTIL_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "mbed.h"
|
||||
#include "mlme.h"
|
||||
|
||||
int string_to_bytes(const char *str, uint8_t *buf, int bytes);
|
||||
const char *mlme_status_string(uint8_t status);
|
||||
int channel_from_mask(uint32_t channel_mask, int index);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user