×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    40

    ISensor.Cancel() returns error with "correct" TransactionID

    Has anybody else had problems when trying to cancel sensor notifications (for rotation channel) with Platform Services 1.0?

    My sensor code is roughly following:

    Code:
    var sensorTransactionID;
    
    function start() {
      // ...
      var so = device.getServiceObject("Service.Sensor","ISensor");
      var criteria = { /* proper values for Rotation channel */ };
      var registration = so.ISensor.RegisterForNotification(criteria, callback);
      sensorTransactionID = registration.TransactionID;
    }
    
    function stop() {
      // ...
      var so = device.getServiceObject("Service.Sensor","ISensor");
      var criteria = { TransactionID: sensorTransactionID };
      cancel = so.ISensor.Cancel(criteria);
    }
    
    function callback() { /*...*/ }
    Sensors are started without problem and i get data to my callback as expected. However, calling ISensor.Cancel() returns ErrorCode "1000" and ErrorMessage "Sensors:Cancel:Transaction id is incorrect".

    I have checked and rechecked that the TransactionID I give to Cancel() is the same that I receive from RegisterForNotification(). How come?

    The code above is in its own file sensor.js that I include to my Main.html. The start() and stop() functions are called from another js-file that is also included and used in Main.html.

    Too bad if I can't cancel the sensor notifications until the application is closed

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    40

    Re: ISensor.Cancel() returns error with "correct" TransactionID

    Should the ISensor.Cancel() just work out of the box or did I miss something important in my code above?

  3. #3
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: ISensor.Cancel() returns error with "correct" TransactionID

    Hello

    You are instantiating the service object twice. Basically you will end up sending the cancel to another instance, which is not sending notifications to you.

    So to fix this instantiate only one service object and use it across your widget. You can do it either in widget startup or when discovering sensor channels.
    Code:
    var so= null;
    function discoverChannels(){
    	writelog("discovering channels");
    	try{
    		so = device.getServiceObject("Service.Sensor", "ISensor");		
    	}catch(e){
    		alert(e);
    	}....
    Br,
    Ilkka

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    40

    Re: ISensor.Cancel() returns error with "correct" TransactionID

    Thanks Ilkka,

    I was just going to reply that today I noticed this duplicate instantiation and tried moving the instantiation to the beginning of my sensor.js file. Now cancellations are successful

    /matti

Similar Threads

  1. ExampleClientEngine ...
    By GeKI in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-12-16, 07:12
  2. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×