SMAC state diagram

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SMAC state diagram

1,150 Views
salah
Contributor III

Hi Can anyone help me to find @SMAC state diagram? I read SMAC documents but there is none. Thanks!

Tags (3)
5 Replies

977 Views
VictorLorenzo
Contributor IV

AngelC. Thanks for your comments to salah, they are usefull for many of us too. Protocols stack states machine understanding can bring some clarity over the callbacks mechanism so we can add our own functionalities with easy, but for the sake of portability amongst stack revisions it is a bad idea to mess with them. Totally agree with you.

Thanks for your hints again.

Regards, Victor

977 Views
AngelC
Senior Contributor I

Dear Salah,

In SMAC Wireless UART application, you may see in main() function that, after initialization, only some functions are called periodically. The functions would correspond to the specific application’s state machine (Wireless UART in this case), the processing of UART buffers and the change of 802.15.4 channel.

  for(;;)

  {

    WUApp_MainStateMachine();

    WUApp_ProcessCommRxBuffer();

    WUApp_ProcessChangeChannel();

  }

Inside Wireless UART state machine there are several states possible. I will try to explain them using the enum defining the different states possible. Please just notice that the transitions form one to another may come from either a previous state or internal/external events. Running the demo and checking the source code is the best way to understand this is done.

typedef enum wuAppState_tag

{

  gWUAppStateStart_c,                // only used as start point, goes directly to Idle state

  gWUAppStateIdle_c,                 // If menus are active, go to configuration state. Otherwise, go to RX always on

  gWUAppStateRxAlwaysOn_c,   // listen for incoming Over-the-air packets

  gWUAppStateSendDataComm_c, //print received data to UART, set from MCPSDataIndication

  gWUAppStateSendDataOta_c, // Send data over the air, set after typing characters in demo mode

  gWUAppStateWaitAckOta_c,    // Wait for ACK after sending a packet. Only if these are enabled.

  gWUAppStateSendAckOta_c,   // Send ACK if enabled.

  gWUAppStateRetryDataOta_c, // Retry packet transmission (If ACK is enabled and was not received)

  gWUAppStateMax_c                 // max value of states

}wuAppState_t;

I hope this helps.

Regards,

AngelC

977 Views
VictorLorenzo
Contributor IV

Hi AngelC,

Are the SMAC implementations for KW01 and for MC1319x, MC1320x and MC1321x (targeted for the S08 core) similar?

I use the SMAC implementation for the KW01 and, IMO, it does implement kind of a states machine in the protocol stack for controlling the transceiver. In file SMAC.h, look for:

typedef enum smacStates_tag {

  mSmacStateIdle_c,

  mSmacStateTransmitting_c,

  mSmacStateReceiving_c,

  mSmacStateScanningChannels_c,

  mSmacStatePerformingTest_c,

  mSmacStateHibernate_c,

  mSmacStateDoze_c  

} smacStates_t;

In file SMAC.c it is instantiated in a local (static) variable and used in several functions throughout the code. The states machine is not implemented in the traditional way with a centralized events processing function and all of that fancy flavour we tend to like so much in the academic world, it is implemented more like an asynchronous and rudimentary events processing strategy for avoiding collitions in transceiver usage. But it resembles a states machine.

From my point of view, States machine and RTOS are two independen concepts so perhaps your point "SMAC does not use any sort of RTOS and therefore it does not has a state machine at stack level at all" could somehow be inaccurate.

Best regards, Victor

977 Views
AngelC
Senior Contributor I

Thanks for the heads up Victor. You are right; I edited the comment not to cause any misunderstanding regarding SMAC stack at all. There is a state machine for radio management at stack level indeed.  However, since Salah is looking to implement the CCA/ED functionality, then I consider that messing up with SMAC state machine would not be the best way to go.

In this particular case, it would be better to keep such state machine unchanged (not modifying SMAC.c or SMAC.h) and use SMAC API’s at application level to perform a CCA/ED scan and then transmit or do whatever intended by the final application. These commands would be called at application state machine either by adding additional states or calling functions inline in the actual ones.

salah, to implement the ED you could use the MLMEEnergyDetect() function and then, based in the results, decide whether to transmit in such channel or not.  This is only one approach; you may implement it in any different way you would like to. For further details about the available API’s please refer to SMAC for MKW2x Reference manual included in Beekit’s Documentation folder.

Please also notice the MAC (802.15.4) already performs the CSMA-CA automatically. You may also consider using such software stack instead.

Regards,

AngelC

977 Views
salah
Contributor III

Thanks Angelc! I liked your answer. I will explain what I was trying to do. Basically, I am trying to understand SMAC in terms of as a MAC protocol. So if I want to implement CSMA technique I need to understand SMAC state diagram so I can implement CSMA by modifying SMAC for sake of experiment. You have mentioned long time ago, I can use CCA and ED to achieve that. I am still struggling to understand how I can accomplish that. If you have an example I can see may help.

Thanks! a lot again.

Salah

0 Kudos