본문으로 바로가기

[nRF52 ] gzll_ack_payload device 프로젝트

category Nordic_nRF52 2023. 1. 2. 19:46

 

목차

     

    0> 개요

       : gzll host 프로그램이 실행이 되어 있는 상태에서  동작합니다.

         기능은 device에서 1바이트 데이타를 tx_fifo 로 전송을 하고  host 에서 ack 1바이트를 보내주는  프로그램으로

         보내는 데이타는 버튼의 상태를 읽어서 보내주고 ack 데이타는 LED 에 표시해 줍니다.

         1개의 호스트에 8개의 디바이스가 연결 가능합니다.

     

     

    1> 프로젝트 위치

    <InstallFolder>\examples\proprietary_rf\gzll\gzll_ack_payload\device

     

    2> 노르딕 다큐먼트

    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/gzll_examples_device_and_host.html

     

    nRF5 SDK v17.1.0: Device/Host example

    This example shows basic Gazell communication and demonstrates how to send payloads and acknowledgments. The example consists of two applications, one running on the device and one running on the host. The example also supports more advanced Gazell feature

    infocenter.nordicsemi.com

     

     

    3> 상세분석

     3-1> gzll  초기화 Enable 하기

        // Initialize Gazell.
        nrf_gzll_init(NRF_GZLL_MODE_DEVICE);      // gazell device 모드로 초기화
    
        // Attempt sending every packet up to MAX_TX_ATTEMPTS times.
        nrf_gzll_set_max_tx_attempts(MAX_TX_ATTEMPTS);  // tx ack 없을 경우 재전송 시도횟수 설정 
        
        // Load data into TX queue. (전송 데이타를 tx_fifo에 넣기)
        nrf_gzll_add_packet_to_tx_fifo(PIPE_NUMBER, m_data_payload, TX_PAYLOAD_LENGTH); 
     
        // Enable Gazell to start sending over the air.
        result_value = nrf_gzll_enable();

     

     3-2> callback 함수 분석

      ==> device 프로젝트는 데이타 전송및 ack 처리만 하면 됩니다.

     

    // tx_fifo 의 데이타 전송후 HOST 로 부터 ACK 받을 경우 호출됨
    void nrf_gzll_device_tx_success(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info)
    {
       // rx_fifo 에서 데이타 읽기
       nrf_gzll_fetch_packet_from_rx_fifo(pipe, m_ack_payload, &m_ack_payload_length);
       
       // LED 상태 표시
       output_present(m_ack_payload[0]);
    }
    
    //tx_fifo 의 데이타 전송에 대한 ACK 를 못받아서 재전송 횟수를 초과할 경우 호출됨.
    //  재전송 횟수를 100으로 설정시 100번의 전송 실패시 호출됨. 
    //  재전송 로직은 내부적으로 자동으로 호출됩니다.
    void nrf_gzll_device_tx_failed(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info)
    {
      // 버튼 상태 읽기
      m_data_payload[0] = input_get();
      
      // 데이타를 다시 tx_fifo 에 집어 넣기
      nrf_gzll_add_packet_to_tx_fifo(pipe, m_data_payload, TX_PAYLOAD_LENGTH);
    }

     

    <기타> 

    ▶ Serial log  (host 와 근접할경우)

    <info> app_timer: RTC: initialized.
    <info> app: Gazell ACK payload example. Device mode.
    <info> app: Gzll ack payload device example started.
    
    <info> app: Total transmitted packets:   1000
    <info> app: Total transmission time-outs: 001
    
    <info> app: Channel 0: 1000 packets transmitted, 001 transmissions failed.
    <info> app: Channel 1: 000 packets transmitted, 000 transmissions failed.
    <info> app: Channel 2: 000 packets transmitted, 000 transmissions failed.
    <info> app: Channel 3: 000 packets transmitted, 000 transmissions failed.
    <info> app: Channel 4: 000 packets transmitted, 000 transmissions failed.
    
    <info> app: Total transmitted packets:   1000
    <info> app: Total transmission time-outs: 002
    
    <info> app: Channel 0: 1000 packets transmitted, 002 transmissions failed.
    <info> app: Channel 1: 000 packets transmitted, 000 transmissions failed.
    <info> app: Channel 2: 000 packets transmitted, 000 transmissions failed.
    <info> app: Channel 3: 000 packets transmitted, 000 transmissions failed.
    <info> app: Channel 4: 000 packets transmitted, 000 transmissions failed.

        Host 와 아무리 가까워도 전송 패킷 1000개중 한번이상 timeout 이 발생해 재전송이 나오네요.

         < nRF52 DK 보드 2개로 테스트>

     

     

    ▶ Serial log  ((host 와 멀어질 경우)

    <info> app: Total transmitted packets:   1000
    <info> app: Total transmission time-outs: 009
    
    <info> app: Channel 0: 046 packets transmitted, 002 transmissions failed.
    <info> app: Channel 1: 023 packets transmitted, 002 transmissions failed.
    <info> app: Channel 2: 013 packets transmitted, 002 transmissions failed.
    <info> app: Channel 3: 417 packets transmitted, 002 transmissions failed.
    <info> app: Channel 4: 501 packets transmitted, 001 transmissions failed.
    
    <info> app: Total transmitted packets:   1000
    <info> app: Total transmission time-outs: 018
    
    <info> app: Channel 0: 064 packets transmitted, 004 transmissions failed.
    <info> app: Channel 1: 039 packets transmitted, 004 transmissions failed.
    <info> app: Channel 2: 097 packets transmitted, 002 transmissions failed.
    <info> app: Channel 3: 101 packets transmitted, 002 transmissions failed.
    <info> app: Channel 4: 699 packets transmitted, 006 transmissions failed.

       ==> 로그를 보면 재전송 되는 확률이 많이 올라간 것을 알수 있습니다.

     

     

    Packet Transaction  그림

    패킷 처리 과정 (성공시)

     

     

     

    패킷 처리 과정 (실패시)

     

    ▶ Gazell Link Layer Userguide

    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/gzll_02_user_guide.html

     

    nRF5 SDK v17.1.0: Gazell Link Layer User Guide

    Introduction Gazell is a protocol for setting up a robust wireless link between a single Host and up to eight Devices in a star network topology. It is designed to minimize power consumption in power-sensitive wireless desktop products and is also suitable

    infocenter.nordicsemi.com

     

    ▶ Gazell 라이브러리 위치  

          .emProject 파일 내 검색
        <folder Name="nRF_Properitary_RF">
          <file file_name="../../../../../../../../components/proprietary_rf/gzll/gcc/gzll_nrf52_sd_resources_gcc.a" />
        </folder>

     

     

     

     

    그럼 수고하세요.

     

     

     

     

    반응형