示例#1
0
/* This function intializes network parameters */
void network_init(uint16_t uid)
{	
	uprintf("\r\n##########################################\r\n");
	uprintf("Network init called with UID = %d\r\n",uid);
	
	deviceType = get_device_type(uid);
	
	if(deviceType == DEVICE_TYPE_COORDINATOR)
	{
		uprintf("I'm a Cooridinator\r\n");
	}
	if(deviceType == DEVICE_TYPE_ROUTER)
	{
		uprintf("I'm a Router\r\n");
	}
	
	bool rx_on_idle = true;
	CS_WriteParameter(CS_RX_ON_WHEN_IDLE_ID, &rx_on_idle);

	/*False = random ID */
	/* True = static short address */
	bool unique_addr = true;
	CS_WriteParameter(CS_NWK_UNIQUE_ADDR_ID,&unique_addr);
	
	ExtAddr_t ownExtAddr = 0x1LL;
	CS_WriteParameter(CS_UID_ID, &ownExtAddr);

  	
  	CS_WriteParameter(CS_NWK_ADDR_ID, &uid);
	
	// Set the deviceType value to Config Server	
	CS_WriteParameter(CS_DEVICE_TYPE_ID, &deviceType);

	network_set_state(APP_NETWORK_JOIN_REQUEST);
}
示例#2
0
void Network_Init()
{
    DeviceType_t deviceType = APP_DEVICE_TYPE;
    uint16_t nwkAddr;
    ExtAddr_t extAddr;

    //#if deviceType == DEVICE_TYPE_COORDINATOR
    //	nwkAddr = 0;
    //	extAddr = 0xAAAAAAAAAAAAAAAALL;
    //#else
    nwkAddr = 1;
    extAddr = 0x00LL;
    //#endif

    // Set the NWK address value to Config Server
    CS_WriteParameter(CS_NWK_ADDR_ID, &nwkAddr);
    CS_WriteParameter(CS_NWK_UNIQUE_ADDR_ID, &(bool) {
        true
    });