Example #1
0
void main(void)
{
  uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];
  uint8_t packet_cnt = 0;
  uint8_t rx_packet_cnt = 0;
  uint8_t rx_packet_byte0 = 0;

  mcu_init();
  gzll_init();

  // Set P0 as output
  P0DIR = 0;    

  EA = 1;

  for(;;)
  {      
    // If gazell link layer idle
    if(gzll_get_state() == GZLL_IDLE)
    {
      if(gzll_rx_fifo_read(payload, NULL, NULL))
      {
        P0 = ~payload[0];
      }

      // Put P0 contents in payload[0]
      payload[0] = P2;
       
      // Transmits payload[] to pipe 0 address
      gzll_tx_data(payload, 1, 0);   
    }
  }  
}
Example #2
0
void main(void)
{
  uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];

  mcu_init();
  gzll_init();

  // Set P0 as output
  P0DIR = 0;                                          

  EA = 1;
  
  // Enter host mode (start monitoring for data)
  gzll_rx_start();                                          
  
  for(;;)
  {      
    // If data received
    if(gzll_rx_fifo_read(payload, NULL, NULL))
    {
      // Write received payload[0] to port 0
      P0 = payload[0];
    }
  } 
}
Example #3
0
/**
Gazell Link Layer Configuration tool main application.
*/
void main(void)
{
  bool radio_activity;
  uint8_t buttons;
  
  mcu_init();
 
  gzll_init();
  app_init();
  lcd_init();
     
  EA = 1;

  app_execute(0);

  while(1)
  {       
    buttons = buttons_read();
    radio_activity = com_execute();
   
    if(buttons || radio_activity)
    {
      app_execute(buttons);       
    }
  }
}
Example #4
0
void main(void)
{
  bool send_crypt_data = false;
  bool tx_success = false;
  gzp_id_req_res_t id_req_status;
  uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];
 
  mcu_init();
  
  // Initialize Gazell Link Layer
  gzll_init();
  
  // Initialize Gazell Pairing Library
  gzp_init();

  EA = 1;

  while(true)
  {      
    payload[0] = ~P0;
    
    // Send every other packet as encrypted data  
    if(send_crypt_data)
    {
      // Send encrypted packet using the Gazell pairing library
      tx_success = gzp_crypt_data_send(payload, GZP_ENCRYPTED_USER_DATA_MAX_LENGTH);
    }
    else
    {
      // Send packet as plaintext on pipe 2
      gzll_tx_data(payload, GZLL_MAX_FW_PAYLOAD_LENGTH, 2);   
      while(gzll_get_state() != GZLL_IDLE)
      ;
      tx_success = gzll_tx_success();
    }
    send_crypt_data = !send_crypt_data;

    // If data transfer failed
    if(!tx_success)
    {
      // Send "system address request". Needed for sending any user data to Host.
      gzp_address_req_send();
      
      // Send "Host ID request". Needed for sending encrypted user data to host.
      id_req_status = gzp_id_req_send();
    }

    // If waiting for Host to grant or reject ID request
    if(id_req_status == GZP_ID_RESP_PENDING)
    {
      // Send new ID request for fetching response
      id_req_status = gzp_id_req_send();
    }
  }  
}
Example #5
0
void main(void)
{
  uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];

  mcu_init();
  gzll_init();
  gzp_init();
  gzp_pairing_enable(true);

  // Open pipe 2. (Pipe 0 and 1 are reserved by pairing library).
  gzll_set_param(GZLL_PARAM_RX_PIPES, gzll_get_param(GZLL_PARAM_RX_PIPES) | (1 << 2));
  
  // Set P0 as output
  P0DIR = 0;                                          

  EA = 1;

  // Enter host mode (start monitoring for data)
  gzll_rx_start();                                          
  
  for(;;)
  { 
    // If gzpair_host_execute() returns true, a pairing request has been received
    gzp_host_execute();

    // If Host ID request received
    if(gzp_id_req_received())
    {
      // Always grant request
      gzp_id_req_grant();
    }
   
    // If any data received (plaintext on pipe 2 or encrypted through Gazell pairing library)
    if((gzll_get_rx_data_ready_pipe_number() == 2) || (gzp_crypt_user_data_received()))
    {
      // Plaintext data received? 
      if(gzll_rx_fifo_read(payload, NULL, NULL))
      {
        // Write received payload[0] to port 0
        P0 = payload[0];
      }
      else
      {
        // Read data from Gazell pairing library
        gzp_crypt_user_data_read(payload, NULL);
        // Write received payload[0] to port 0
        P0 = payload[0];
      }
    }   
  }          
}
Example #6
0
void main(void)
{
  uint8_t poll_cnt = 0;
  uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];

  mcu_init();
  gzll_init();

  // Always run on 16MHz crystal oscillator
  hal_clk_set_16m_source(HAL_CLK_XOSC16M);

  // Use Gazell Link Layer synchronous device mode 2 for minimizing 
  // transmit attempts
  gzll_set_param(GZLL_PARAM_DEVICE_MODE, 2);

  EA = 1;

  while(true)
  {      
    // If gazell link layer idle
    if(gzll_get_state() == GZLL_IDLE)
    {
      // Send a packet for every 20 wakeup, equals every ~20 ms  
      if(poll_cnt > 20)
      {
        // Read P0 and put in payload[0]
        payload[0] = ~P0;
        // Transmits 1 byte ( payload[0] ) to pipe 0 address
        gzll_tx_data(&payload[0], 1, 0);   
        poll_cnt = 0;
      }
    }

    EA = 0;
    // If radio not active, enter "register retention"
    if(!gzll_radio_active())
    {
      PWRDWN = 0x04; // Enter "register retention", will wake up on pre-tick
    }
    PWRDWN = 0x07;   // Enter "standby", will wake up on tick
    EA = 1; 
    
    poll_cnt++;
  }  
}
Example #7
0
void main(void)
{
    uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];
    
    mcu_init();

    gzll_init();
    
    usb_init();

    P0DIR &= ~(1 << 3);                                   

    EA = 1;
    P03 = 1;
    
    delay_ms(500);
    usb_send_data_sync(0x81, "SYS_UP!", 7);
    P03 = 0;

    // Enter host mode (start monitoring for data)
    gzll_rx_start();                                          

    for(;;)
    {      
        /*
        if(is_usb_data_ready && !is_usb_writing)
        {
            //P03 = 1;
            is_usb_data_ready = false;
            // usb_send_data_sync(0x81, usb_buf, usb_buf_len);
        }
        
        // If data received
        if(gzll_rx_fifo_read(payload, NULL, NULL))
        {
            // Write received payload[0] to port 0
            // P0 = payload[0];
            // P03 = ~P03;
        }
        */
    } 
}