Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    cobi.js 0.44.0 is buggy and I cant get it working

    cobi.js 0.44.0 is buggy and I cant get it working

    Rob-Black
    Member

     

    I  took the speedometer sample as a starting point and stripped it down to the very basics. I´ve tested both in DevKit simulator using Chrome under Windows 10 and in My Module on my Android 11 Smartphone.

    Problem: While the current speed is reported flawlessly, my own subscriptions to other channels like motor, battery and some others do not work, although I did everything like documented (https://cobi-bike.github.io/COBI.js). On the other hand, other channels do work fine.

    First, I´ve spent hours searching for my mistake - found none. Then I discovered a true bug, or at least a discrepancy between documentation and code:
    The static property "serialNumber" of channel motor does not exist at all. In the simulator, the console states "Uncaught TypeError: Cannot read property 'subscribe' of undefined" - and checking cobi.js file reveals that "serialNumber" truly does not exist.

    Now my question is: is this the only bug or is there something else wrong with version 0.44 that keeps my code from running? Or is it me being to stupid? Does is work for you guys? Is there a more recent version?

    Have a look at my stripped-down-to-the-bone code to demonstrate the issues:

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<title>COBI.js 0.44.0 - showcase</title>
    		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
    		<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    		<script src="https://cdn.cobi.bike/cobi.js/0.44.0/cobi.js"></script>
    	</head>
    
    	<body>
    		<div id="speed">Go riding...</div>
    		<br />
    		<div id="dbg1">Debug1: waiting for data</div>
    		<br />
    		<div id="dbg2">Debug2: waiting for data</div>
    
    		<!-- COBI.JS -->
    		<script>
    			// Authenticate your module
    			COBI.init('token');
    
    			// Subscribe to current speed - works!
    			COBI.rideService.speed.subscribe(function(speed) {
    				$('#speed').html(`Speed: ${speed.toFixed(2)} m/s`);
    			});
    
    			// Subscribe to total travelled distance - no data arrives
    			COBI.motor.distance.subscribe(function(value) {
    				$('#dbg1').html(`Value: ${value.toString()}`);
    			});
    			
    			// Subscribe to serialNumber - object is undefined
    			COBI.motor.serialNumber.subscribe(function(value) {
    				$('#dbg2').html(`Value: ${value.toString()}`);
    			});
    		</script>
    	</body>
    </html>

     

    1 REPLY 1

    Rob-Black
    Member

    Found it myself.

    There are multiple issues and reasons why it did not work. First, querying battery and motor is not supported by the simulator. Second, it does work in MyModule (in the app when truly connected with the bike) - but I overlooked that communication was blocked by my VPN-based AdBlocker (Blokada). Once I created an exception for the Cobi app, data was sent to my module.

    But the biggest fault was - and I stumbled over it just be accident - the documentation (https://cobi-bike.github.io/COBI.js/), although stating it is for cobi-js 0.44.0, is for a more recent version! By trial and error, I have found version 0.59.0 but cannot be sure this really is the latest one. I have not found any hint anywhere on something newer than 0.44.0 but in fact...

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist