To whom it may concern,
I wanna do an experiment with CC1110 and SimpliciTI. The experiment should achieve such result as below:
There are 1 AP, 2 REs(I call them R1 and R2), 1 ED.
At first R1 is transmitiing the packet while R2 is sleeping. Then, if I turn off R1(in practice, it simulate the stuation of break down), R2 will be woken up and take on the responsibility of transmitting the data to ED.
At first, My idea is that I make R2 turn into the power mode 2 and wake up every two seconds with sleep timer, and I put the
Init_SLEEP_TIMER(); SET_POWER_MODE(2);
before while (SMPL_NO_JOIN == SMPL_Init((uint8_t (*)(linkID_t))0)), but it cannot be woken up.
So my question is :
1 Whether the RE must SMPL_Init and Linkto successfully before it turn into the sleeping mode or not?
2 Whether I could only make it sleep before it implement the send() funcition and cannot reinit and relink it to the other node after it wakes up?
3 If the anwser to the question2 is negative, could you tell me how can I make the R2 init the SMPL_Init and linkto() again after it waken up, because I think that the way of just make it intermittent sleep between then send action cannot save much energy.
4 How to make the R2 would not retransmit the packet if the R1 is still working well since R2 would wake up intermittently to listen the link from ED?
Thanks very much for your consideration!
There are some codes in my procedure below:
#include "bsp.h"
#include "mrfi.h"
#include "bsp_leds.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "bsp_buttons.h"
#include "mydefine.h"
#include "string.h"
//YY
#include "stdio.h"
extern uchar display[4];
//YY
extern addr_t sMyRAMAddress;
extern void initTempSensor(void);
extern INT8 getTemperature(void);
char temperature[10];
void initUARTtest(void);
static void linkTo(void);
//static void processMessage(uint8_t *msg, uint8_t len);
void toggleLED(uint8_t);
const __root uint8_t date[] = __DATE__;
const __root uint8_t time[] = __TIME__;
#define SPIN_ABOUT_A_SECOND do { uint16_t spin; for (spin=20; spin; --spin) NWK_DELAY(0xFFFF); } while (0)
void Init_SLEEP_TIMER(void)
{
WORCTL |= 0x00; //1 period
WOREVT1=0xFF;
WOREVT0=0x4C;
EA = 1;
IEN0 |= 0X20; //
WORIRQ |= 0X10; //
}
void main (void)
{
//YY
BSP_Init();
if (BSP_LED1_IS_ON())
{
toggleLED(1);
}
if(BSP_LED2_IS_ON())
{
toggleLED(2);
}
//初始化串口
initUART(19200);
UARTxISRopen();
ENABLE_ALL_INTERRUPT();
nixie_light_int();
//YY
while(1)
{ //Init_SLEEP_TIMER();
while (SMPL_NO_JOIN == SMPL_Init((uint8_t (*)(linkID_t))0))
{
toggleLED(1);
SPIN_ABOUT_A_SECOND;
}
linkID_t linkID1;
uint8_t MSGleth = FRAMELENTH;
while (SMPL_SUCCESS != SMPL_Link(&linkID1))
{
toggleLED(1);
SPIN_ABOUT_A_SECOND;
}
uart_state_int();//
Init_SLEEP_TIMER();
SET_POWER_MODE(2);
linkTo();
//SET_POWER_MODE(2);
}//
}//
static void linkTo()
{
//YY
while (1)
{
// send a message every second. this could be emulating a sleep.
Uart_R.Buf[0] = 0x68;
Uart_R.Buf[1] = 0xaa;
Uart_R.Buf[2] = 'B';
Uart_R.Buf[3] = 'C';
Uart_R.Buf[4] = 'O';
memcpy((void *)(Uart_R.Buf+5),&sMyRAMAddress,4);
Uart_S = RXOVER;
if((Uart_S == RXOVER)||(Uart_S == TIMEROVER))
{
uart_state_int();
if (SMPL_SUCCESS == SMPL_Send(linkID1, Uart_R.Buf, sizeof(Uart_R.Buf)))
{
toggleLED(2);
}
}
if(SMPL_SUCCESS == SMPL_Receive(linkID1,AF_Data.RxBuf,&MSGleth))
{
//toggleLED(1);
//processMessage(AF_Data.RxBuf,MSGleth);
}
}
}
void toggleLED(uint8_t which)
{
if (1 == which)
{
BSP_TOGGLE_LED1();
}
else if ((2 == which) || (4 == which))
{
BSP_TOGGLE_LED2();
}
return;
}
#pragma vector = ST_VECTOR
__interrupt void ST_ISR(void)
{
IRCON &= ~0x80;
WORIRQ &= ~0X01;
}