forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jarkko Paso
authored
Aug 13, 2021
1 parent
e54231b
commit f1a65ec
Showing
8 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2021, Pelion 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 "string.h" | ||
#include "nsconfig.h" | ||
#include "ns_types.h" | ||
#include "ns_trace.h" | ||
#include "MAC/IEEE802_15_4/mac_defines.h" | ||
#include "MAC/IEEE802_15_4/mac_mode_switch.h" | ||
|
||
#define TRACE_GROUP "mswc" | ||
|
||
#define PHR_LEN 2 | ||
|
||
|
||
int8_t ms_build_mode_switch_phr(protocol_interface_rf_mac_setup_s *rf_ptr, uint8_t *data_ptr, uint8_t phy_mode_id) | ||
{ | ||
(void) rf_ptr, (void) phy_mode_id; | ||
if (!data_ptr) { | ||
return -1; | ||
} | ||
|
||
// - Write mode switch and PHY mode id fields | ||
// - Calculate checksum | ||
// - Calculate parity | ||
|
||
// - With successful return value, MAC should start CSMA-CA for a mode switch PHR | ||
return 0; | ||
} | ||
|
||
int8_t ms_parse_mode_switch_phr(protocol_interface_rf_mac_setup_s *rf_ptr, const uint8_t *data_ptr, uint16_t data_len) | ||
{ | ||
(void) rf_ptr; | ||
if (data_len != PHR_LEN) { | ||
return -1; | ||
} | ||
if (!data_ptr) { | ||
return -1; | ||
} | ||
tr_info("Received mode switch PHR %s", trace_array(data_ptr, data_len)); | ||
|
||
// - Validate checksum | ||
// - Validate parity | ||
// - Read PHY mode id | ||
// - Store current configuration | ||
// - Resolve new configuration | ||
// - Set new configuration | ||
// - Set timer/timeout for waiting the frame with new PHY mode | ||
|
||
// - With successful return value, MAC should not start new transmissions until a packet is received or reception timed out | ||
return 0; | ||
} | ||
|
||
void ms_update_mode_switch_state(protocol_interface_rf_mac_setup_s *rf_ptr) | ||
{ | ||
(void) rf_ptr; | ||
// MAC should call this after any transmission (TX done) and reception | ||
// When mode switch PHR was sent, change new configuration here before transmitting data packet | ||
// When data packet was sent, switch back to original configuration | ||
// When packet was received in new configuration, switch back to original configuration | ||
// When reception timeout occurs, switch back to original configuration | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2021, Pelion 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_MODE_SWITCH_H_ | ||
#define MAC_MODE_SWITCH_H_ | ||
|
||
/** | ||
* @brief Build mode switch PHR. | ||
* @param rf_ptr Pointer to MAC instance. | ||
* @param data_ptr Pointer to data buffer. | ||
* @param phy_mode_id Used PHY mode id. | ||
* @return 0 - success, -1 - failure. | ||
*/ | ||
int8_t ms_build_mode_switch_phr(protocol_interface_rf_mac_setup_s *rf_ptr, uint8_t *data_ptr, uint8_t phy_mode_id); | ||
|
||
/** | ||
* @brief Parse mode switch PHR. | ||
* @param rf_ptr Pointer to MAC instance. | ||
* @param data_ptr Pointer to data buffer. | ||
* @param data_len Data length. | ||
* @return 0 - mode switch PHR found, -1 - mode switch PHR not found. | ||
*/ | ||
int8_t ms_parse_mode_switch_phr(protocol_interface_rf_mac_setup_s *rf_ptr, const uint8_t *data_ptr, uint16_t data_len); | ||
|
||
#endif /* MAC_MODE_SWITCH_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2021, Pelion 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 "nsconfig.h" | ||
#include <string.h> | ||
#include "ns_types.h" | ||
#include "ns_list.h" | ||
#include "ns_trace.h" | ||
#include "mac_defines.h" | ||
|
||
int8_t ms_build_mode_switch_phr(protocol_interface_rf_mac_setup_s *rf_ptr, uint8_t *data_ptr, uint8_t phy_mode_id) | ||
{ | ||
return 0; | ||
} | ||
|
||
int8_t ms_parse_mode_switch_phr(protocol_interface_rf_mac_setup_s *rf_ptr, const uint8_t *data_ptr, uint16_t data_len) | ||
{ | ||
return -1; | ||
} | ||
|
||
void ms_update_mode_switch_state(protocol_interface_rf_mac_setup_s *rf_ptr) | ||
{ | ||
|
||
} |