Smart Bike Lights (Data Field) / Bike Lights Control (Widget)

I've made two open source CIQ applications to control ANT+ lights:

- Smart Bike Lights (data field): https://apps.garmin.com/en-US/apps/0d9fd828-c932-4470-9c37-fd2828881888 

      Configurator: https://maca88.github.io/SmartBikeLights/ 

- Bike Lights Control (widget): https://apps.garmin.com/en-US/apps/fa3c2332-76e3-4ba1-8528-32a0fd617ab1 

     Configurator: https://maca88.github.io/BikeLightsControl/ 

Smart Bike Lights features:
- Automatic light control (Smart mode) based on the configured filters (sunset, sunlight, speed, ...)
- Manual light control (only for Edge devices with a touch screen or devices with CIQ 3.2 and more than 32KB memory)
- Records lights modes that are displayed in Garmin Connect

Bike Lights Control features:
- Manual light control (available to all devices)

Both applications can be installed on the same device, which can be useful for low end devices (e.g. Edge 520) where "Bike Lights Control" can be used to change light modes manually and "Smart Bike Lights" for automatic light control.

Currently registered ANT+ lights:
- Bontrager Ion Pro RT
- Bontrager Ion 200 RT
- Bontrager Flare RT
- Garmin Varia RTL500
- Garmin Varia RTL510
- Garmin Varia RTL515
- Garmin Varia HL500
- Garmin Varia UT800

in case your ANT+ light is not on the list you can help by doing the following:

1. Install Bike Lights Control
2. Pair your bike light with your Garmin device
3. Open the widget:
- Edge with a touch screen: post which numbers are displayed on the buttons and what mode each button represents when pressed
- Other devices: Select the "Light modes" menu and post which numbers are displayed in the menu and what mode each menu item represents when selected

Example for Bontrager Ion Pro RT:


1 -> High steady beam
2 -> Medium steady beam
5 -> Low steady beam
63 -> Day flash
62 -> Night flash

There are some features that could be possible to add in the future, but would require Garmin to add them to the CIQ api. In case you are interested in any of the below features, consider upvoting their feature request thread:

1. Control lights based on the ambient light sensor available on some devices:
https://forums.garmin.com/developer/connect-iq/i/bug-reports/ambient-light-sensor-api-access 

  • Thanks for taking your time to try it out and post the results. Based on the log I have good and bad news. The good news is that I found out why the widget is crashing, it seems like that Cyclq lights have 6 custom modes but only 5 are supported by the LightNetwork, for the sixth one NULL is set which is the reason for the crash and can be easily fixed.
    Now the bad news:

    In the log there is no "UPD:" lines and the light mode was always off (LM=0). Have the lights been always off when you tried the test widget? Did you try to switch modes while the test widget was open?

    Every time you tried to pair both lights (T_L: 2), the lights were not correctly detected by the LightNetwork. The light modes were both null (CM=null) and the light type was "Other" (TY=7) for both of them, instead of "Headlight" (TY=0) and "TailLight" (TY=2). This to me indicates that the implementation for the ANT+ Lights is not fully implemented by Cycliq. My See Sense ICON2 suffers a similar issue, I am able to control it by using the Garmin menu, but I am not able to control it by using the LightNetwork API. Due to the partial implementation, the ICON2 light is sometimes detected as "Other" (TY=7) instead of "TailLight" (TY=2) when paired with a headlight, which is similar to what I see in your log. This unfortunately means that it won't work with the Smart Bike Lights or Bike Lights Control widget when both lights are paired. If you see in the Garmin Sensor menu that for the paired lights it shows "Other" instead of "Headlight" or "Taillight", that is a bad sign.

    the only peculiar thing, is once started they only momentarily report to widget and after that it goes network not found

    So do you mean that the widget at the beginning shows "Network formed" and afterwards the text is changed to "No Network" and does not go to "Network formed" again?
    From the logs I don't see that the light network was disconnected after its formation. "Net ST=2" means that the network is formed and "Net ST=0" that network is not formed.

    I released a new Bike Lights Control version (0.6.1) that fixes the crash, so you can try it out to see whether you can control at least one light. If you get "Error 1", this means that the light was paired as "Other" instead of "Headlight" or "Taillight". There is a chance that even when the light will be correctly recognized that you won't be able to set the mode by using the widget due to the partial implementation of the ANT Light protocol from Cycliq. Please let me know your results with the updated widget.

  • It works great :) Thank you ...

  • The widget does work now and shows numbers ,it allows me to chose network or manual but it seems to work for very short time . It seems fenix sort of losing connection to light ( rear or headlight separately , it doesnt matter which )

    it will reconnect once i go to sensors menu and then widget will work again for short time. 

    the lights are not detected as other , but i get error 1 after few seconds until i go sensors menu again.

    i was wondering , if i could use the numbers for data field to work correctly ?

  • Unfortunately the numbers won't help for Error 1, for some reason after a few seconds the light are recognized as "Other" light type and such lights are not usable with the LightNewtork API. Based on the fact that the LightNewtork API works for Garmin and Bontrager lights, I suspect that the Cycliq only partially implemented the ANT+ Light protocol, similar to what See Sense did for ICON2. The only thing that we can do at this point is to contact Cycliq and tell them about the issue with the ANT+ connectivity and hopefully they will resolve it in a future firmware update.

  • thank you for trying...

  • Hi Maca,

    when I read the words about NULL in the list of supported modes I had to laugh a bit... it is the same and absolutely unexpected thing I struggled with for maybe two hours last week. Really stupid! Without any debugging tool it was quite hard to find such a bloody thing.

    I have combination Flare RT + Cycliq FLY12. I managed to create a datafield that controls the lights as I want - taillight always blinking while timer is running, headlight off by default, but can be switched to steady or blink mode from the datafield. Just simple code, nothing configurable etc. 

    Everything seemed to work perfectly, but ... after a certain time (sometimes 10min, sometimes even 2hrs) the light network is gone and forming again for no reason. This is bad as the lights go off unexpectedly. I added some code into my DF to handle this event and put the lights back into desired mode when the light network is formed again. However, even this is not any (although very dirty..) solution, as in 50% of "reforming light network" it is not successful and the only way how to put it back to life is to disable/enable the whole network in Garmin sensors menu.

    I did logs of ANT traffic, converted the FIT file into Excel and tried to understand the contents (with help of some ANT documents I found in different forums etc.). What I can see there (if I understand well) is that:

    1/ Both lights are identified correctly as headlight or taillight (according to their data page 1)

    2/ Surprisingly the main light in the network is always the Flare RT in the rear, while Cycliq is always the secondary one. Cycliq should have significantly better RSSI as it is 5cm from the Edge 1030.. so probably Garmin does not keep his own recommendation to select the light with highest RSSI as the main one ;-)

    3/ Everything looks good, i.e. data pages 1, 2 from both lights, 80, 81 from main one and 16, 17 from secondary one are there. What is strange is that I can sometimes (and repeatedly) see a message that should be interpreted as EVENT_RX_FAIL, which I understand as a kind of timeout.. but have no idea what is triggering this situation. I do not see any gap in the broadcast messages.

    mesg_id 64 mesg_data 2|1|2|0|0|0|0|0|0

    5/ But, in a certain moment, the data pages with light index 2 disappear..  and after a while datapages 1,2  with light index 0 appear there. It is the Cycliq, which goes to unconnected state and it also sends incorrect sequence number in that message (but this is probably not important as it is sending index 0 i.e. unconnected light)

    During today I will try disabling taillight and make log again only with headlight connected. Just because I am curious if these timeouts will be there as well or not.

    I will come back if I find any interesting piece of info.

    Jan.

    P.S. I can send you the logs if you are interested...

  • Hi Jan,

    Surprisingly the main light in the network is always the Flare RT in the rear

    This happens to me also, Flare RT is always promoted as the main light even if the Ion RT Pro headlight is right below Edge.

    see a message that should be interpreted as EVENT_RX_FAIL

    This happens also to me and it should not be a problem if the channel remains open.

    In the meantime I managed to implement a custom light network that connects to each light separately and I am happy to report that it works on my Edge 1000. I am now able to connect and control Bontrager Ion Pro RT and See Sense ICON2 lights, which was not possible with the default LightNetwork. You can test the code to see whether it works also for your Cycliq light. In order to test the code you need to:
    1. Clone https://github.com/maca88/SmartBikeLights repository
    2. Switch to branch "feature/individual-network"
    3. Change the light device numbers in IndividualLightNetwork.mc file (you can obtain them by using Edge)
    4. Build the project and copy the prg file inside /Garmin/Apps folder on your Edge
    5. Set the datafield on a single field data screen

    EDIT: You can also run the project in the simulator and test there. 

  • Perfect!!! Will do and let you know.

    J.

  • Hi Maca, 

    I compiled your code with my light numbers and side-loaded it, bud I did not manage to get it fully working. Actually, in the very first moment when I added the datafield into a new screen it appeared correctly, i.e. it connected to the lights and correctly listed all available light modes of both. Even first tap worked and switched the light into proper mode. However, after that the DF started to show "No network" forever.

    I saw you decided to go a clever way and implemented the class "individualLightNetwork" which could be used instead of the Garmin's original LightNetwork class absolutely seamlessly. Good work! So, I decided to try compiling my very simple DF using your class (without your consent, sorry, but I hope you will not be angry of me ;-). And everything seems to work absolutely fine!!! I will go for a ride today evening so I will see if is is stable for a long time. 

    Thus, I think the "IndividualLightNetwork" class is ok, there is just some (maybe only minor... ) bug in your DF. 

    Jan

    P.S. I owe you a beer ;-)

  • I decided to try compiling my very simple DF using your class (without your consent, sorry, but I hope you will not be angry of me

    You don't need any consent, you can do whatever you want with the code :)

    Thus, I think the "IndividualLightNetwork" class is ok, there is just some (maybe only minor... ) bug in your DF. 

    You are correct, there was an issue with the DF that is now fixed in the latest commit. Also I did some modifications to IndividualLightNetwork, mostly related with establishing the light connection, so you can use the updated version if you want. As now the configuration was moved to Lights Configurator, in case you want to try the new version you need to do the following:
    1. Pull the latest changes from branch "feature/individual-network"
    2.a In case you would like to test it in the simulator, you can run the project and set the app setting "Light Configurator" to

    #######1:111:222#B2713#99#99#0#0

    but you will need to change 111 to your headlight device number and 222 to your taillight device number. You can also modify the device numbers by using Lights Configurator

    2.b In case you want to test on the real device you will need to this line to:

    var configuration = parseConfiguration("#######1:111:222#B2713#99#99#0#0");

    and replacing 111 and 222 as described in point 2.a

    As I don't have a Cycliq light, can you please describe each light mode that is available on the light, so that I can add the mappings in the Lights Configurator.