[ANT+][nrf51422][s210] Bicycle Light General Page 70 (0x46): Request Data Page

Publisher:MysticEssenceLatest update time:2022-09-13 Source: csdnKeywords:nrf51422 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Generic Data Page 70 allows an ANT+ device to request a specific data page from another ANT+ device. In this device profile:

• Page 70 allows the controller to request a specific data page from an ANT+ bike light. The requested data page shall be sent using a recognized MES DROP by the ANT+ controller and shall be formatted as shown in Table 7-45.

• As described in Section 7.3.3.2, the primary indicator uses the shared format of Page 70 to request the data page for the secondary indicator. It is recommended that this page be sent as a broadcast message (to reduce power consumption), but acknowledgement messages are also allowed. The format of the request data page shall be as shown in Table 7-46.

insert image description here

7.22.3.1 Light Index

When a data page containing a light index field is requested, the light index field should be used to specify the light index, otherwise it should be set to invalid.


7.22.3.2 Descriptor Bytes 1 & 2

The Descriptor Bytes field is used to describe the requested subpage.

Descriptor byte 1 should be used to specify:

• Minor light index when requesting a data page containing a minor light index (1-4, 6, 16, 17)

• Mode number, when requesting data Page 5 – Mode Description

Otherwise set to invalid.

Descriptor byte 2 should be set to invalid.


7.22.3.3 Request transmission response

ANT+ Bike Lights SHOULD be able to support all requested transport response types, however, the ANT+ Bike Light Device Profile further specifies that ANT+ controllers MAY only request broadcast messages.

Note that some ANT+ bike lights do not support sending acknowledged messages and will respond with a broadcast message regardless of the requested response type.


ANT+ bike lights only need to support a maximum of two transmit response repetitions to minimize polling memory requirements on a shared network.

For more details on the Request Data page and possible Request Transport response types, see the ANT+ Common Pages documentation.


/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.

 *

 * The information contained herein is property of Nordic Semiconductor ASA.

 * Terms and conditions of usage are described in detail in NORDIC

 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.

 *

 * Licensees are granted free, non-transferable use of the information. NO

 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from

 * the file.

 *

 */


#include "ant_BikeLight_page_70.h"

#include "ant_BikeLight_utils.h"

#include "ant_BikeLight_page_logger.h"

#include "SEGGER_RTT.h"

#include "SEGGER_RTT_Conf.h"

#include "main.h"

/**@brief BikeLight request data page (0x46) Page 70 data layout structure. */

typedef struct

{

    uint8_t Light_Index; //Light index 0-63

    uint8_t reserved; //reserved

    uint8_t descriptor[2]; //Descriptor: allows specifying data within the requested data page. Valid values: 0–254 Invalid: 255 (0xFF)

    uint8_t req_trans_response_Repetitions: 6; //Requested data page, test that needs to be sent.

    uint8_t req_trans_response_MSB: 1; //Requested data page, whether to wait for sending successfully

    uint8_t req_page_number; //Requested page number

    uint8_t command_type; /*Value for requesting data page = 1 (0x01) Value for requesting ANT-FS session = 2 (0x02)

                                               The value of the slave request data page = 3 (0x03) The value of the request data page set = 4 (0x04) */

} ant_BikeLight_page70_data_layout_t;


//static void page70_data_log(ant_BikeLight_page70_data_t const *p_page_data)

//{

    SEGGER_RTT_printf(0, "command_type: %drn", (uint8_t)p_page_data->command_type);

    SEGGER_RTT_printf(0, "req_page_number: %drn", (uint8_t)p_page_data->req_page_number);

//}


void ant_BikeLight_page_70_encode(uint8_t *p_page_buffer,

                                  ant_BikeLight_page70_data_t const *p_page_data)

{

    ant_BikeLight_page70_data_layout_t *p_outcoming_data = (ant_BikeLight_page70_data_layout_t *)p_page_buffer;

    memcpy(p_outcoming_data, p_page_data, sizeof(ant_BikeLight_page70_data_layout_t));

// ANT_PAGE_NEW = 0;

// page70_data_log(p_page_data);

}


void ant_BikeLight_page_70_decode(uint8_t const *p_page_buffer,

                                  ant_BikeLight_page70_data_t *p_page_data,

                                  uint8_t const Channel)

{

    ant_BikeLight_page70_data_layout_t const *p_incoming_data = (ant_BikeLight_page70_data_layout_t *)p_page_buffer;

    if (Channel == 0)

    {

        if (p_incoming_data->Light_Index == 0 || p_incoming_data->Light_Index == m_ant_BikeLight.page_1.Light_Index) //Judge the light index

        {

            p_page_data->descriptor[0] = p_incoming_data->descriptor[0];

            p_page_data->descriptor[1] = p_incoming_data->descriptor[1];


            p_page_data->req_page_number = p_incoming_data->req_page_number;

            p_page_data->command_type = (ant_page70_command_t)p_incoming_data->command_type;


            if (p_page_data->command_type == 1) //Request data page

            {

                if (p_page_data->req_page_number == 1 || p_page_data->req_page_number == 2 ||

                    p_page_data->req_page_number == 80 || p_page_data->req_page_number == 81 || p_page_data->req_page_number == 19)

                {

                    switch (p_page_data->req_page_number)

                    {

                        case 1:

                            ANT_PAGE_NEW = 100;

                            break;

                        case 2:

                            ANT_PAGE_NEW = 0;

                            break;

                        case 80:

                            ANT_PAGE_NEW = 1;

                            break;

                        case 81:

                            ANT_PAGE_NEW = 2;

                            break;

                        case 19:

                            ANT_PAGE_NEW = 3;

                            break;

                        default:

                            break;

                    }

                }

                else

                {

                    ANT_PAGE_NEW = p_page_data->req_page_number; //Send the specified page

                }

            }

            m_ant_BikeLight.page_1.Last_Sequence_Number = 70;

            /*Prevent low power consumption during broadcasting*/

            LowPower_Tmr = 0;

            System_shutdown_count = 0;

        }

        else//It is not your own thing, forward it

        {

            if (p_incoming_data->Light_Index == 0xff)

            {

                LowPower_Tmr = 0;

                System_shutdown_count = 0;

            }

            if (p_incoming_data->Light_Index != 0xff && ANT_Relay_New_Share_Page != 32)

            {

                memcpy(ANT_message_payload_Shared_Wait, p_incoming_data, sizeof(ant_BikeLight_page70_data_layout_t)); //Copy non-self content to the shared channel buffer

                ANT_Relay_New_Share_Page = 70; //Send the specified page

                ANT_Shared_Channel_sens_message_encode(ANT_message_payload_Shared_Wait, ANT_Relay_New_Share_Page);//Reorganize the command

            }

        }

    }

    else if (Channel == BikeLight_Shared_CHANNEL_NUMBER) //The request sent from the shared channel needs to forward the specified content to the broadcast channel

    {

// SEGGER_RTT_printf(0, "[channel1_MY]---ID:%d %d req_page_number:%dnr",

// m_ant_BikeLight.page_1.Light_Index,p_incoming_data->Light_Index, p_page_data->req_page_number); //c test

        /*Prevent low power consumption during broadcasting*/

        LowPower_Tmr = 0;

        System_shutdown_count = 0;

        if (p_incoming_data->Light_Index == m_ant_BikeLight.page_1.Light_Index) //Judge the light index

        {

            p_page_data->descriptor[0] = p_incoming_data->descriptor[0];

            p_page_data->descriptor[1] = p_incoming_data->descriptor[1];


            p_page_data->req_page_number = p_incoming_data->req_page_number;

            p_page_data->command_type = (ant_page70_command_t)p_incoming_data->command_type;

            if (p_page_data->command_type == 1) //Request data page

            {

                if (p_page_data->req_page_number == 1 || p_page_data->req_page_number == 2 || p_page_data->req_page_number == 19) //

                {

                    if (ANT_Relay_New_Share_Page == 2 || ANT_Relay_New_Share_Page == 19)

                    {

                        return;

                    }

                    switch (p_page_data->req_page_number)

                    {

                        case 1:

                            memcpy(ANT_message_payload_Shared_Wait, &(m_ant_BikeLight.page_1), sizeof(ant_BikeLight_page1_data_t)); //Copy non-self content to the shared channel buffer

                            break;

                        case 2:

                            memcpy(ANT_message_payload_Shared_Wait, &(m_ant_BikeLight.page_2), sizeof(ant_BikeLight_page2_data_t)); //Copy non-self content to the shared channel buffer

                            break;

                        case 19:

                            memcpy(ANT_message_payload_Shared_Wait, &(m_ant_BikeLight.page_19), sizeof(ant_BikeLight_page19_data_t)); //Copy non-self content to the shared channel buffer

                            break;

                        default:

                            break;

                    }

                    ANT_Relay_New_Share_Page = p_page_data->req_page_number; //Send the specified page

                    ANT_Shared_Channel_sens_message_encode(ANT_message_payload_Shared_Wait, ANT_Relay_New_Share_Page);//Reorganize the command

                    //err_code = sd_ant_broadcast_message_tx(BikeLight_Shared_CHANNEL_NUMBER, 8, ANT_message_payload_Shared); //Send sharing command

// if (p_page_data->req_page_number == 2)

// {

// SEGGER_RTT_printf(0, "[channel1_MY]---TX page_%02d: %02X %02X %02X %02X %02X %02X %02X %02Xnr",

// ANT_Relay_New_Share_Page, Replace_Buff(ANT_message_payload_Shared_Wait)); //Print and send sharing command

// }

                }

            }

        }

    }

[1] [2]
Keywords:nrf51422 Reference address:[ANT+][nrf51422][s210] Bicycle Light General Page 70 (0x46): Request Data Page

Previous article:[ANT+][nrf51422][s210] Bicycle Light General Page 81 (0x51) – Product Information
Next article:[ANT+][nrf51422][s210] Minimum data page requirements for bicycle lights

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号