HI,
I'm using CC1110 to try this example. The example is the message send from ED to AP when button is pressed.
Now I change the code by sending message from AP to ED.
It doesn't work.
AP code as below:
void main (void)
{
uint8_t i;
bspIState_t intState;
uint8_t msg[2];
uint8_t button, misses, done;
BSP_Init();
SMPL_Init(sCB);
if (!BSP_LED2_IS_ON())
{
toggleLED(2);
}
if (!BSP_LED1_IS_ON())
{
toggleLED(1);
}
while (1)
{
uint8_t noAck;
smplStatus_t rc;
button = 0;
if (sJoinSem && (sNumCurrentPeers < NUM_CONNECTIONS))
{
while (1)
{
if (SMPL_SUCCESS == SMPL_LinkListen(&sLID[sNumCurrentPeers]))
{
break;
}
}
sNumCurrentPeers++;
BSP_ENTER_CRITICAL_SECTION(intState);
sJoinSem--;
BSP_EXIT_CRITICAL_SECTION(intState);
}
if (BSP_BUTTON1())
{ /* Message to toggle LED 1. */
button = 1;
}
if (button)
{
msg[0] = button;
done = 0;
while (!done)
{
for (i=0; i<sNumCurrentPeers; ++i)
{
noAck = 0;
/* Try sending message MISSES_IN_A_ROW times looking for ack */
for (misses=0; misses < MISSES_IN_A_ROW; ++misses)
{
if (SMPL_SUCCESS == (rc=SMPL_SendOpt(sLID[i], msg, sizeof(msg), SMPL_TXOPTION_ACKREQ)))
{
toggleLED(1);
break;
}
if (SMPL_NO_ACK == rc)
{
noAck++;
}
}
if (MISSES_IN_A_ROW == noAck)
{
toggleLED(2);
}
else
{
done = 1;
}
}
}
}
}
}
void toggleLED(uint8_t which)
{
if (1 == which)
{
BSP_TOGGLE_LED1();
}
else if (2 == which)
{
BSP_TOGGLE_LED2();
}
return;
}
static uint8_t sCB(linkID_t lid)
{
if (~lid)
{
sJoinSem++;
}
return 0;
}