2 Commits
Author SHA1 Message Date
Gatsby Van b99d0bfca0 *bugfix: correct beam setup 2024-03-02 16:32:36 +08:00
Gatsby Van 3dedebbe79 miscellaneous update 2024-03-02 16:32:12 +08:00
5 changed files with 14 additions and 4 deletions
@@ -130,6 +130,10 @@ void L2_NodeList_Destroy(NODE_LIST *list)
NODE_ENTRY *L2_GetNodeById(NODE_LIST *list, uint8_t nodeId) NODE_ENTRY *L2_GetNodeById(NODE_LIST *list, uint8_t nodeId)
{ {
ASSERT(list != NULL); ASSERT(list != NULL);
if (nodeId == L2_BROADCAST_ID || nodeId == L2_NONE_ID)
{
return NULL;
}
util_entry.nodeInfo.nodeId = nodeId; util_entry.nodeInfo.nodeId = nodeId;
clist_node_t *node = clist_find(list, &util_entry); clist_node_t *node = clist_find(list, &util_entry);
if (node == NULL) if (node == NULL)
@@ -608,18 +608,19 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
if (rtneEntry->dst == L2_GetNodeId(instPtr) || rtneEntry->dst == L2_BROADCAST_ID) if (rtneEntry->dst == L2_GetNodeId(instPtr) || rtneEntry->dst == L2_BROADCAST_ID)
{ {
torState = L2_TOR_RX; torState = L2_TOR_RX;
commNode = L2_GetNodeById(instPtr->nodeList, rtneEntry->dst); commNode = L2_GetNodeById(instPtr->nodeList, rtneEntry->src);
} }
else if (rtneEntry->src == L2_GetNodeId(instPtr) || rtneEntry->src == L2_BROADCAST_ID) else if (rtneEntry->src == L2_GetNodeId(instPtr) || rtneEntry->src == L2_BROADCAST_ID)
{ {
torState = L2_TOR_TX; torState = L2_TOR_TX;
commNode = L2_GetNodeById(instPtr->nodeList, rtneEntry->src); commNode = L2_GetNodeById(instPtr->nodeList, rtneEntry->dst);
} }
else else
{ {
torState = L2_TOR_SUSPEND; torState = L2_TOR_SUSPEND;
} }
// Setup antenna beam
Phy_SetBeamWidth(instPtr->config.phyInstPtr, PHY_ANT_BEAM_25); Phy_SetBeamWidth(instPtr->config.phyInstPtr, PHY_ANT_BEAM_25);
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_25; instPtr->log.lastBeamWidth = PHY_ANT_BEAM_25;
if (commNode != NULL) if (commNode != NULL)
@@ -641,6 +642,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
{ {
torState = L2_TOR_SUSPEND; torState = L2_TOR_SUSPEND;
} }
// Setup antenna beam
Phy_SetBeamWidth(instPtr->config.phyInstPtr, PHY_ANT_BEAM_120); Phy_SetBeamWidth(instPtr->config.phyInstPtr, PHY_ANT_BEAM_120);
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_120; instPtr->log.lastBeamWidth = PHY_ANT_BEAM_120;
} }
@@ -373,7 +373,7 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
if (rtneEntry->src == L2_GetNodeId(instPtr)) if (rtneEntry->src == L2_GetNodeId(instPtr))
{ {
torState = L2_TOR_TX; torState = L2_TOR_TX;
commNode = L2_GetNodeById(instPtr->nodeList, rtneEntry->src); commNode = L2_GetNodeById(instPtr->nodeList, rtneEntry->dst);
} }
else if (rtneEntry->dst == L2_GetNodeId(instPtr)) else if (rtneEntry->dst == L2_GetNodeId(instPtr))
{ {
@@ -385,6 +385,7 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
torState = L2_TOR_SUSPEND; torState = L2_TOR_SUSPEND;
} }
// Setup antenna beam
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD && commNode != NULL) if (L2_GetNodeType(instPtr) != L2_NODE_HEAD && commNode != NULL)
{ {
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_25); Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_25);
@@ -308,6 +308,8 @@ void Phy_UpdateState(PHY_INST *instPtr)
{ {
instPtr->isValid = false; instPtr->isValid = false;
} }
// Logging
instPtr->recvSlotTime.int_part = PhyRead(instPtr, TM_TARGET_H); instPtr->recvSlotTime.int_part = PhyRead(instPtr, TM_TARGET_H);
instPtr->recvSlotTime.frac_part = PhyRead(instPtr, TM_TARGET_L); instPtr->recvSlotTime.frac_part = PhyRead(instPtr, TM_TARGET_L);
instPtr->recvFsTime.int_part = PhyRead(instPtr, FSTIME_H); instPtr->recvFsTime.int_part = PhyRead(instPtr, FSTIME_H);
@@ -334,7 +336,7 @@ void Phy_UpdateState(PHY_INST *instPtr)
instPtr->phyLog.fsyncFreqCh = (PhyRead(instPtr, PHY_FRAME_SYNC_FREQEST) & PHY_FRAME_SYNC_FREQEST_CHANNEL_MASK) >> PHY_FRAME_SYNC_FREQEST_CHANNEL_SHIFT; instPtr->phyLog.fsyncFreqCh = (PhyRead(instPtr, PHY_FRAME_SYNC_FREQEST) & PHY_FRAME_SYNC_FREQEST_CHANNEL_MASK) >> PHY_FRAME_SYNC_FREQEST_CHANNEL_SHIFT;
instPtr->phyLog.deintlvAmpEst = PhyRead(instPtr, PHY_DEINTLV_AMPEST) & PHY_DEINTLV_AMPEST_MASK; instPtr->phyLog.deintlvAmpEst = PhyRead(instPtr, PHY_DEINTLV_AMPEST) & PHY_DEINTLV_AMPEST_MASK;
memset(instPtr->phyLog.reserve, 0x00, sizeof(instPtr->phyLog.reserve)); memset(instPtr->phyLog.reserve, 0x00, sizeof(instPtr->phyLog.reserve));
// Sync logs to system monitor
SysMonitor_UpdatePhysicalLayerLog(&(instPtr->phyLog)); SysMonitor_UpdatePhysicalLayerLog(&(instPtr->phyLog));
} }
@@ -30,6 +30,7 @@
#ifndef EMULATION #ifndef EMULATION
#include "xbram.h" #include "xbram.h"
#include "xadcps.h" #include "xadcps.h"
#include "../config/app_config.h"
#endif #endif
#include "../../system_monitor.h" #include "../../system_monitor.h"
#include "../../time_ctrl/time_ctrl.h" #include "../../time_ctrl/time_ctrl.h"