Hi,
I've some problems with my program. I just triying link two end devices i dont know where is the problem because i dont have errors compiling and i have all the libraries.
ED1 Code : Linklisten
--------------------------------------------------------------------------------------------
#include "bsp.h"
#include "mrfi.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "bsp_leds.h"
#include "bsp_buttons.h"
static uint8_t sRxCallback(linkID_t);
static linkID_t LinkID2;
void toggleLED(uint8_t);
unsigned int delay (unsigned int x)
{
unsigned int i,j;
for (i = 0; i<= x; i++)
{
for(j=0;j<=1000; j++);
}
return 0;
}
void programa(void);
int x,y,j;
void main(void)
{
uint8_t msg[2], len;
WDTCTL = WDTPW + WDTHOLD;
BSP_Init();
#ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
{
addr_t lAddr;
createRandomAddress(&lAddr);
SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
}
#endif /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */
SMPL_Init(sRxCallback); //inicializamos el protocolo
while(1)
{
if(SMPL_SUCCESS == SMPL_LinkListen(&LinkID2)) // this part is working fine i think, Because im proving with LinkTo example SImple_Peer_to_Peer" and work fine with my proyect.
{
toggleLED(2);
NWK_DELAY(100);
break;
}
toggleLED(1);
}
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0); //encendemos el radio que por default esta apagado
while(1)
{
if(SMPL_SUCCESS == SMPL_Receive(LinkID2, msg, &len))
{
programa();
}
}
}
void programa(void)
{
//do something
}
static uint8_t sRxCallback(linkID_t port)
{
uint8_t msg[2], len ;
//check if sent port matches our assigned port (sLinkID1)
if (port==LinkID2)
{
//yep. proceed
if(SMPL_Receive(LinkID2, msg, &len)==SMPL_SUCCESS)
{
//do something useful
//troubleshooting. if led toggles, we were sent the correct port #
BSP_TOGGLE_LED2();//green
return 1 ; //kill frame. no longer needed
}
}
return 0 ; //preserve frame
}
void toggleLED(uint8_t which)
{
if (1 == which)
{
BSP_TOGGLE_LED1();
}
else if (2 == which)
{
BSP_TOGGLE_LED2();
}
return;
}
-------------------------------------------------------------------------------------------
ED2 Code : link
------------------------------------------------------------------------------------------
#include "bsp.h"
#include "mrfi.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "bsp_leds.h"
#include "bsp_buttons.h"
static uint8_t sRxCallback(linkID_t);
static linkID_t LinkID1;
void toggleLED(uint8_t);
unsigned int delay (unsigned int x)
{
unsigned int i,j;
for (i = 0; i<= x; i++)
{
for(j=0;j<=1000; j++);
}
return 0;
}
void programa(void);
int x,y,j;
void main(void)
{
uint8_t msg[2], len;
WDTCTL = WDTPW + WDTHOLD;
BSP_Init();
#ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
{
addr_t lAddr;
createRandomAddress(&lAddr);
SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
}
#endif /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */
SMPL_Init(sRxCallback); //inicializamos el protocolo
while (SMPL_SUCCESS != SMPL_Link(&LinkID1)) // in this part when im debuggin never pass form here whith the 2 ED working SMPL_Link() never is SMPL_SUCCESS
{
toggleLED(2);
toggleLED(1);
NWK_DELAY(100);
}
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
msg[0] = 0x01;
while(1)
{
SMPL_Send(sLinkID1, msg, sizeof(msg));
}
}
static uint8_t sRxCallback(linkID_t port)
{
uint8_t msg[2], len ;
//check if sent port matches our assigned port (sLinkID1)
if (port==LinkID1)
{
//yep. proceed
if(SMPL_Receive(LinkID1, msg, &len)==SMPL_SUCCESS)
{
//do something useful
//troubleshooting. if led toggles, we were sent the correct port #
BSP_TOGGLE_LED2();//green
return 1 ; //kill frame. no longer needed
}
}
return 0 ; //preserve frame
}
void toggleLED(uint8_t which)
{
if (1 == which)
{
BSP_TOGGLE_LED1();
}
else if (2 == which)
{
BSP_TOGGLE_LED2();
}
return;
}
------------------------------------------------------------------------
Im sorry for a lot of code, principally I have problems with "ED2 code : link" in the part with red, i dont know what is happen, maybe a variable, configuration.....If some can help me.
Additionaly I don't have any problem compiling the program, just is the communication that is unsuccesful