[ANT+][nrf51422][s210] Bicycle Light Data Page 33 – Connect Command (0x21)

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

Data Page 33 is the command page sent from an ANT+ controller to an ANT+ bike light to initiate a connection with a new ANT+ bike light. The command includes the light index and settings that should be used in the connected state, as well as the channel ID variables (i.e. device number and transmission type) to search for (if applicable). This command should be sent as a confirmation message from the ANT+ controller.

All fields in this message shall be set as described in Table 7-34.


insert image description here

insert image description here

insert image description here

/*********************************************

Function name: ant_BikeLight_SHARED_MASTER_Init

Function: Shared channel initialization

Form parameter: ch--> 0--main light shared channel (can send and receive) 1--secondary light shared channel (only receive)

return value:

Remark:

Author: Xue Jianqiang

Time: 2020/02/27

use:

**********************************************/

void ant_BikeLight_SHARED_MASTER_Init(void)

{

    uint32_t err_code = 0;

    /*Shared channel*/

    if (SystemInit_Type.ANT_SHARED_MASTER == 0)

    {

        err_code = sd_ant_channel_unassign(BikeLight_Shared_CHANNEL_NUMBER);

        SEGGER_RTT_printf(0, "ANT BikeLight Shared channel_unassign %u close %dnr", BikeLight_Shared_CHANNEL_NUMBER, err_code);

        if ( m_ant_BikeLight . page_33 . Light_Index_Set == 1 ) / / ID = 1 , one

        {

            ant_channel_Shared.channel_type   = BikeLight_SENS_CHANNEL_TYPE_Shared;

            ant_channel_Shared.device_number = BikeLight_DEVICE_NUMBER; //Set the ANT device number to the MAC address

            //ant_channel_Shared.device_number = NRF_FICR->DEVICEADDR[0]; //Set the ANT device number to the MAC address

        }

        else if (m_ant_BikeLight.page_33.Light_Index_Set > 1)//ID>1,副灯

        {

            ant_channel_Shared.channel_type   = BikeLight_DISP_CHANNEL_TYPE_Shared;

            ant_channel_Shared.device_number = BikeLight_DEVICE_NUMBER; //Set the ANT device number to the MAC address

            //ant_channel_Shared.device_number = NRF_FICR->DEVICEADDR[0]; //Set the ANT device number to the MAC address

        }

        else

        {

            SEGGER_RTT_printf(0, "Shared_open_fail,not Light_Index!!! %drn", m_ant_BikeLight.page_33.Light_Index_Set);

            return;

        }

//        m_ant_BikeLight_Shared.channel_number = BikeLight_Shared_CHANNEL_NUMBER; //通道号


        ant_channel_Shared.channel_number = BikeLight_Shared_CHANNEL_NUMBER;//通道号


        ant_channel_Shared.ext_assign = BikeLight_EXT_ASSIGN; //ANT external assignment.

        ant_channel_Shared.rf_freq = BikeLight_ANTPLUS_RF_FREQ; //frequency

        ant_channel_Shared.transmission_type = m_ant_BikeLight.page_33.Transmission_Type; //Transmission type of the main light

        ant_channel_Shared.device_type = BikeLight_DEVICE_TYPE_Shared; //Device type


        ant_channel_Shared.device_number  = m_ant_BikeLight.page_33.DeviceNumber_MSB << 8 | m_ant_BikeLight.page_33.DeviceNumber_LSB;

        ant_channel_Shared.channel_period = BikeLight_MSG_PERIOD_8Hz; //Message period

        ant_channel_Shared.network_number = 0;

        err_code = ant_channel_init(&ant_channel_Shared);

        APP_ERROR_CHECK(err_code);

        err_code = ant_BikeLight_Shared_open(&ant_channel_Shared);

        SEGGER_RTT_printf(0, "Shared_open,err_code=%02X  device_number:%d  transmission_type:%drn", err_code, ant_channel_Shared.device_number, ant_channel_Shared.transmission_type);

        APP_ERROR_CHECK(err_code);

    }

}


7.17.1 Setting the Light Index

The Light Index Settings fields should be interpreted as follows for unconnected lights (i.e. lights that currently have a light index of 0):

ANT+ bike lights should have their light index set to the value specified in the Light Index Settings field.


• If the Light Index is set to 1, the ANT+ bike light is designated as the Master light for the network and should turn on the shared Master channel as detailed in section 6.5.

• Alternatively, if the light index is set to 2 – 63, the ANT+ bike light is assigned as an auxiliary light and the shared slave channel should be turned on as described in section 6.4.


Note that ANT+ controllers should assign light indices in order, starting with the first fill light having its light index set to 2. For any fill light in the shared network, the light index setting field must not be more than one greater than the "Fll Light" field in the connect command sent to the master light.


Light index 255 (0xFF) should only be used when controlling unconnected lights, such as setting the light type or light state settings, without changing the light index or affecting the channel the light turns on.


The light index settings fields should be interpreted as follows for connected rays (i.e. lights with current light index > 0):

• ANT+ bike lights must not change their light index.

• If the light index is set to 1, the connect command only applies to the main light.

• If the light index is set to 2 – 63, the connect command will apply to the fill light with the specified light index. If the main light receives this command, it should forward it to the specified fill light.

Note that connected lights should ignore connect commands with a light index of 255 (0xFF).


7.17.2 # Secondary Light

This field indicates the number of fill lights that will be connected to the shared channel so that the master light knows which light index to poll. For example, if the number of fill lights is 5, the master light should poll light indexes 2-6.


7.17.3 Controller ID

The Controller ID field should be filled by the ANT+ controller with the LSB of its serial number. ANT+ controllers without a serial number should assign a fixed value to this field.


7.17.4 Sub-lamp index

The Sublight Index field indicates the sublight to which the Light State and Light Type settings should be applied. If the Sublight Index is set to 0, the commanded light settings should only be applied to the main ANT+ bike light and not any sublights.

This field should not be set to the values ​​5, 6, or 7.

7.17.5 Lighting status settings

ANT+ controllers can use the Light State settings field to command ANT+ bike lights to turn off, flash, or turn on the beam (steady). ANT+ bike lights should respond to commands immediately.

insert image description here

Note that the Light State Setup field provides an ANT+ controller with limited control over the state of an ANT+ bike light. This feature can be used during network configuration to allow basic control of an ANT+ bike light without requiring the ANT+ controller to get full mode information from the bike light.

An ANT+ bike light that receives a "blink" command should set itself to whatever mode the light is blinking in.

An ANT+ bike light that receives a "steady on" command should set itself to any mode with a steady light brightness.


7.17.6 Lighting type settings

ANT+ controllers should use this field to configure their ANT+ bike lights as needed. ANT+ controllers should not attempt to set an ANT+ bike light's light type to an unsupported type. ANT+ bike lights should configure their light type as requested. ANT+ bike lights should ignore any request to set their light type to something unsupported. .


7.17.7 Device Number and Transfer Type Fields

The Device Number and Transmission Type fields contain the Channel ID parameters for the master light. These values ​​should be included as valid values ​​whenever the light metrics are set to a value between 2 and 63. ANT+ bicycle lights should use the parameters specified in Table 7-37 and Table 7-38.

Note that when the light index is set to 0, the Device Number and Transfer Type fields should be set to invalid.

insert image description here

/* 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_33.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 connection command (0x21) Page 33 data layout structure. */

typedef struct

{

    uint8_t Light_Index_Set; //Light index setting [1-63]

    uint8_t Secondary_Lights; //Auxiliary lights [1-62] Invalid: 255 (0xFF)

    uint8_t Controller_ID; //Controller ID [0-255]


    uint8_t SubLight_Index : 3; //Sublight index [0-2] 5-7: Reserved, do not use

    uint8_t Light_State_Setting : 2; //Light state setting [3-4] 0: Invalid 1: Turn off 2: Flashing 3: Always on

    uint8_t Light_Type_Setting : 3; //Light type setting [5-7] 0: Headlight 2: Taillight 3: Signal light 4: Signal light - left 5: Signal light - right


    uint8_t DeviceNumber_LSB; //The device number LSB of the main light

    uint8_t DeviceNumber_MSB; //MSB of the device number of the main light

    uint8_t Transmission_Type; //Transmission type of the main light [1-255]

} ant_BikeLight_page33_data_layout_t;



static void page33_data_log(ant_BikeLight_page33_data_t const *p_page_data)

{

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

}



void ant_BikeLight_page_33_encode(uint8_t                     *p_page_buffer,

                                  ant_BikeLight_page33_data_t const *p_page_data)

{

//    ant_BikeLight_page33_data_layout_t *p_outcoming_data = (ant_BikeLight_page33_data_layout_t *)p_page_buffer;


//    p_outcoming_data->Light_Index_Set        = p_page_data->Light_Index_Set;

//    p_outcoming_data->Secondary_Lights       = p_page_data->Secondary_Lights;

//    p_outcoming_data->Controller_ID          = p_page_data->Controller_ID;

//    p_outcoming_data->SubLight_Index         = p_page_data->SubLight_Index;

//    p_outcoming_data->Light_State_Setting    = p_page_data->Light_State_Setting;

//    p_outcoming_data->Light_Type_Setting     = p_page_data->Light_Type_Setting;

//    p_outcoming_data->DeviceNumber_LSB       = p_page_data->DeviceNumber_LSB;

[1] [2]
Keywords:nrf51422 Reference address:[ANT+][nrf51422][s210] Bicycle Light Data Page 33 – Connect Command (0x21)

Previous article:[ANT+][nrf51422][s210] Bicycle Light Data Page 35 - Channel Cycle Extraction
Next article:[ANT+][nrf51422][s210] Bicycle Lights Generic Page 80 (0x50) – Manufacturer Identification

Recommended ReadingLatest update time:2024-11-23 01:43

[ANT+][nrf51422][s210] Bicycle Light Data Page 17 – Product Information for Connected Lights (0x11)
Data Page 17 is one of the data pages broadcasted from an ANT+ bike light when in a connected state. All master lights shall send this page upon request from the controller. This page may optionally be included as one of the primary data pages broadcasted from an ANT+ bike light as part of the data page round-robin. A
[Microcontroller]
[ANT+][nrf51422][s210] Bicycle Light Data Page 17 – Product Information for Connected Lights (0x11)
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号