BLE_ERROR when using makeJsonRequest on the device, but not on the simulator

Former Member
Former Member
Getting BLE_ERROR (-1) when making a Json request on a Vivoactive device. The request works fine in the simulator. The watch is connected to a Nexus 7 and I can see the connection working well (notifications, calendar).
Thanks for any suggestions.
  • Are you checking "phoneConnected" before calling makeJsonRequest? (to make sure the va and nexus are talking)

    Does it happen all the time, or just once in a while?
  • Former Member
    Former Member over 10 years ago
    Yes, I check if the phone is connected and it is.
    It happens all the time, same error "-1" (BLE_ERROR).
    Again, in the simulator I do get back the json reply with no problem.
  • What version of the SDK, and what version of FW on the device? What does the request look like?
  • Former Member
    Former Member over 10 years ago
    2048

    I am using the latest version of the SDK, 1.1.3.
    The firmware is 3.00 (from Settings -> System -> About)
    The Connect IQ version on the device is 1.1.2. I just compiled the app with that version of the SDK and I get the same error.

    The request is for the HERE APis:

    Comm.makeJsonRequest("route.cit.api.here.com/.../calculateroute.json",
    {"app_id"=>app_id,
    "app_code"=>app_code,
    "mode"=>"fastest;publicTransportTimeTable",
    "departure" => "now",
    "waypoint0"=>waypoint0,
    "waypoint1"=>waypoint1}, {}, method(:onReceiveRoute));

    Here is an example of the Json response in the simulator:

    {response=>{route=>[{leg=>[{start=>{shapeIndex=>0, type=>stopOver, sideOfStreet=>neither, mappedPosition=>{latitude=>41.904655, longitude=>-87.631485}, linkId=>-1575363128660723696, spot=>0.398058, mappedRoadName=>N Clark St, originalPosition=>{latitude=>41.904655, longitude=>-87.631500}, label=>N Clark St}, length=>3389, end=>{shapeIndex=>23, type=>stopOver, sideOfStreet=>left, mappedPosition=>{latitude=>41.884487, longitude=>-87.638931}, linkId=>-1575292759899767285, spot=>0.250000, mappedRoadName=>W Randolph St, originalPosition=>{latitude=>41.884178, longitude=>-87.638931}, label=>W Randolph St}, maneuver=>[{instruction=>Head <span class="heading">south</span> on <span class="street">N Clark St</span>. <span class="distance-description">Go for <span class="length">82 m</span>.</span>, id=>M1, position=>{latitude=>41.904655, longitude=>-87.631485}, travelTime=>92, length=>82, _type=>PrivateTransportManeuverType}, {instruction=>Turn <span class="direction">left</span> onto <span class="next-street">W Division St</span>. <span class="distance-description">Go for <span class="length">5 m</span>.</span>, id=>M2, position=>{latitude=>41.903915, longitude=>-87.631470}, travelTime=>5, length=>5, _type=>PrivateTransportManeuverType}, {instruction=>Go to the <span class="company">Train</span> station <span class="station">Clark/Division</span> and take the <span class="transit">rail</span> <span class="line">Red Line</span> toward <span class="destination">95th</span>. <span class="distance-description">Follow for <span class="stops">3 stations</span>.</span>, stopName=>Clark/Division, id=>M3, position=>{latitude=>41.903919, longitude=>-87.631409}, travelTime=>360, length=>2347, _type=>PublicTransportManeuverType}, {stopName=>Lake, nextRoadName=>N State St, id=>M4, position=>{latitude=>41.884804, longitude=>-87.627922}, instruction=>Get off at <span class="station">Lake</span>., travelTime=>0, length=>0, _type=>PublicTransportManeuverType}, {instruction=>Head <span class="heading">south</span> on <span class="street">N State St</span>. <span class="distance-description">Go for <span class="length">40 m</span>.</span>, id=>M5, position=>{latitude=>41.884804, longitude=>-87.627922}, travelTime=>50, length=>40, _type=>PrivateTransportManeuverType}, {instruction=>Turn <span class="direction">right</span> onto <span class="next-street">W Randolph St</span>. <span class="distance-description">Go for <span class="length">915 m</span>.</span>, id=>M6, position=>{latitude=>41.884441, longitude=>-87.627907}, travelTime=>915, length=>915, _type=>PrivateTransportManeuverType}, {instruction=>Arrive at <span class="street">W Randolph St</span>. Your destination is on the left., id=>M7, position=>{latitude=>41.884487, longitude=>-87.638931}, travelTime=>0, length=>0, _type=>PrivateTransportManeuverType}], travelTime=>1422}], publicTransportLine=>[{lineName=>Red Line, lineBackground=>#C60C30, type=>railMetro, companyName=>Chicago Transit Authority, lineForeground=>#C60C30, id=>L1, destination=>95th}], mode=>{trafficMode=>disabled, type=>fastest, feature=>[], transportModes=>[publicTransportTimeTable]}, summary=>{distance=>3389, _type=>PublicTransportRouteSummaryType, text=>The trip takes <span class="length">3.4 km</span> and <span class="time">24 mins</span>., baseTime=>1422, travelTime=>1422, departure=>2015-07-01T09:24:23-05:00}, waypoint=>[{shapeIndex=>0, type=>stopOver, sideOfStreet=>neither, mappedPosition=>{latitude=>41.904655, longitude=>-87.631485}, linkId=>-1575363128660723696, spot=>0.398058, mappedRoadName=>N Clark St, originalPosition=>{latitude=>41.904655, longitude=>-87.631500}, label=>N Clark St}, {shapeIndex=>23, type=>stopOver, sideOfStreet=>left, mappedPosition=>{latitude=>41.884487, longitude=>-87.638931}, linkId=>-1575292759899767285, spot=>0.250000, mappedRoadName=>W Randolph St, originalPosition=>{latitude=>41.884178, longitude=>-87.638931}, label=>W Randolph St}]}], language=>en-us, metaInfo=>{mapVersion=>8.30.58.159, moduleVersion=>7.2.58.0-1179, timestamp=>2015-07-01T14:25:26Z, interfaceVersion=>2.6.13}}}
  • Could it be you hit some kind of limit on the size of the response? (it may not be there in the simulator, but is there on the real device.)

    That is a good sized chunk of data coming back. Anyway to get a smaller response with different options to see if that works?
  • Former Member
    Former Member over 10 years ago
    I get the same error message with the json request from the Weather sample app:

    Comm.makeJsonRequest("api.openweathermap.org/.../weather",
    {"lat"=>latLon[0].toFloat(), "lon"=>latLon[1].toFloat()}, {}, method(:onReceiveRoute));

    The response (as seen in the simulator) is much shorter:
    {clouds=>{all=>75}, main=>{temp=>290.709991, humidity=>63, temp_min=>288.149994, temp_max=>296.149994, pressure=>1015}, weather=>[{main=>Clouds, id=>803, description=>broken clouds, icon=>04d}], coord=>{lat=>41.849998, lon=>-87.650002}, cod=>200, dt=>1435785787, sys=>{sunset=>1435800561, message=>0.011400, type=>1, sunrise=>1435745981, id=>961, country=>US}, base=>cmc stations, wind=>{deg=>90, speed=>5.700000}, id=>4887398, name=>Chicago}


    Matei
  • Former Member
    Former Member over 10 years ago
    It does seem to be a limitation of the json message size. I tested my app with a json request I found here (in the forum), a very short reply (http://echo.jsontest.com/date/143233...direction/Flat) and I no longer get the error -1.
    If this is true, than this is a pretty serious limitation, it would be good to document it (with the specific limit for the json message size).
  • Former Member
    Former Member over 10 years ago
    There isn't a hard limitation that I know of, but there are practical limitations related to the speed of the BLE link, and the amount of memory available on the device. The response you have posted above is about 4KB, which I would expect to work as long as your app has enough memory remaining to receive it. It could take 4-8 seconds for that response to transfer to the device, which might affect behavior.