1
0

add token

This commit is contained in:
Rémi Heredero 2024-04-17 17:09:48 +02:00
parent 85c26acd11
commit d00b873275
3 changed files with 149 additions and 103 deletions

1
.gitignore vendored
View File

@ -77,3 +77,4 @@
# To explicitly override the above, define any exceptions here; e.g.: # To explicitly override the above, define any exceptions here; e.g.:
# !my_customized_scatter_file.sct # !my_customized_scatter_file.sct
.idea

View File

@ -3,9 +3,7 @@ void MacSender(void *argument)
{ {
// TODO // TODO
struct queueMsg_t queueMsg; // queue message struct queueMsg_t queueMsg; // queue message
char* msg; uint8_t* msg;
char msgToSend[255];
uint8_t msgToSendPtr=0;
osStatus_t retCode; // return error code osStatus_t retCode; // return error code
for(;;) { for(;;) {
@ -18,11 +16,22 @@ void MacSender(void *argument)
NULL, NULL,
osWaitForever); osWaitForever);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
msg = queueMsg.anyPtr;
switch(queueMsg.type) { switch(queueMsg.type) {
case TOKEN: case TOKEN:
msg[gTokenInterface.myAddress] = gTokenInterface.station_list[gTokenInterface.myAddress];
for(uint8_t i = 1; i < TOKENSIZE-2; i++) {
gTokenInterface.station_list[i] = msg[i];
}
queueMsg.type = TO_PHY;
retCode = osMessageQueuePut(
queue_phyS_id,
&queueMsg,
osPriorityNormal,
osWaitForever);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
break; break;
@ -32,15 +41,24 @@ void MacSender(void *argument)
case NEW_TOKEN: case NEW_TOKEN:
for(uint8_t i = 0; i < 15; i++) { msg = osMemoryPoolAlloc(memPool, osWaitForever);
if(i == gTokenInterface.myAddress) { msg[0] = TOKEN_TAG;
gTokenInterface.station_list[i] = (0x1 << TIME_SAPI) & (gTokenInterface.connected << CHAT_SAPI);
} else { for(uint8_t i = 1; i < sizeof(TOKENSIZE-2); i++) {
gTokenInterface.station_list[i] = 0; msg[i] = 0;
} }
} gTokenInterface.station_list[gTokenInterface.myAddress] = (0x1 << TIME_SAPI) + (gTokenInterface.connected << CHAT_SAPI);
msg = osMemoryPollAlloc(memPool, osWaitForever); msg[gTokenInterface.myAddress+1] = gTokenInterface.station_list[gTokenInterface.myAddress];
queueMsg.type = TO_PHY; queueMsg.type = TO_PHY;
queueMsg.anyPtr = msg;
retCode = osMessageQueuePut(
queue_phyS_id,
&queueMsg,
osPriorityNormal,
osWaitForever);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
break; break;

File diff suppressed because one or more lines are too long