Hello. I asked a question yesterday, and it seems I was able to identify the cause of my problem. The problem lies in the Communications.transmit() method (line 46 of the code).
import Toybox.Lang;
import Toybox.Time;
import Toybox.Sensor;
import Toybox.WatchUi;
import Toybox.Communications;
import Toybox.Application.Storage;
class AccelAppDelegate extends WatchUi.BehaviorDelegate {
private var countOfAccelDataInArray;
private var mySampleRate;
private var myPeriod;
private var listener;
function initialize() {
BehaviorDelegate.initialize();
myPeriod = 1;
mySampleRate = 25;
countOfAccelDataInArray = mySampleRate * myPeriod;
listener = new Communications.ConnectionListener();
var options = { :period => myPeriod,
:sampleRate => mySampleRate,
:enableAccelerometer => true
};
Sensor.registerSensorDataListener(method(:onSensor), options);
}
function onSensor(sensorData) {
var accelDataToPhone = "";
for (var i = 0; i < countOfAccelDataInArray; i++) {
var floatX = sensorData.accelerometerData.x[i].toFloat() / 1000;
var floatY = sensorData.accelerometerData.y[i].toFloat() / 1000;
var floatZ = sensorData.accelerometerData.z[i].toFloat() / 1000;
accelDataToPhone = accelDataToPhone + "\n"+Time.now().value() + ", " + floatX + ", " + floatY + ", " + floatZ;
}
sendMessage(accelDataToPhone);
}
function sendMessage(accelDataToPhone) {
Communications.transmit(accelDataToPhone, null, listener);
}
function onSelect() {
return true;
}
function onMenu() as Boolean {
WatchUi.pushView(new Rez.Menus.MainMenu(), new AccelAppMenuDelegate(), WatchUi.SLIDE_UP);
return true;
}
}
When I pass to this method the string that is formed in line 39 of the code, then after a few minutes the iq! icon appears on the clock, and the data transfer stops. But if I pass the string "1" to the Communications.transmit() method, then the data transfer takes a very long time, and it seems to be stable. I see this error in the logs:
---
Error: Out Of Memory Error
Details: 'Failed invoking <symbol>'
Time: 2024-01-30T10:13:42Z
Part-Number: 006-B3869-00
Firmware-Version: '9.03'
Language-Code: eng
ConnectIQ-Version: 4.2.4
Store-Id: 2c61dcda-01b6-476f-b527-0fa5edc8134a
Store-Version: 7
Filename: E1UA0959
Appname: AccelApp
Stack:
- pc: 0x100001f3
0x100001f3 is a 268435955
I see this in the file debug.xml
<entry filename="/Users/artemgrigoran/OtherProjects/AccelApp/source/AccelAppDelegate.mc" id="5" lineNum="39" parent="globals/AccelAppDelegate" pc="268435922" symbol="onSensor"/> <entry filename="/Users/artemgrigoran/OtherProjects/AccelApp/source/AccelAppDelegate.mc" id="5" lineNum="42" parent="globals/AccelAppDelegate" pc="268435997" symbol="onSensor"/>
The example of data from the accelerometer in Xcode looks like this:

Question: how can I successfully transfer big data (my accelDataToPhone string) to a phone using the Communications.transmit() method, and without the problem that causes the "Out Of Memory Error" error? I use Forerunner 55.