Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Cannot turn off sensor streaming #100

Open
@avidj

Description

Hi, as mentioned in this issue (#37) I have the problem of "command sync response was lost" when I use sprk+ on Mac OS as intended (issueing move commands while streaming all sensor data). Now, if I leave sensor data turned off then the sphero runs smoothly at a moderate but probably sufficient frequency of issuing roll commands.
Unfortunately, doing entirely without sensor data is not an option. So I am now trying to reduce the sensor data frequency or turn it on and off periodically, up to now without success.
What I've tried is
`function setUpSensorPolling(sfero, uuid) {
const sensorPollingDelay = 4000;
const sensorPollingInterval = 4000;
const sensorPollingPeriod = 2000;

sfero.on(VELOCITY, (data) => publishSensorData(VELOCITY, uuid, data));
// sfero.streamData = STREAM_DATA; // adapted to call 'once' instead of 'on'

const listener = function() {
console.log("+++ enable sensor stream")
sfero.streamVelocity(0.2, false);
// setTimeout(() => {
// sfero.removeListener("dataStreaming", listener);
// console.log("--- disable sensor stream")
// sfero.streamVelocity(1, true)
// }, sensorPollingPeriod);
};

setTimeout(() => {
setInterval(listener, sensorPollingInterval);
}, sensorPollingDelay)
}`
thus, reducing the frequency of sensor packets to 1 every 5 seconds
and still the connection is lost after some time
I also tried

  • the above reduced frequency
  • disabling the streaming with commented out streamVelocity(1, true). This doesn't work at all, and it adds another listener.
  • replacing 'on(..)' by 'once(..)' when adding the listener. This at least removes the listener after receiving a packet.

It all doesn't help. The connection is lost after some time.

Is there anyone who tried this?

Best,
David

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions