yashsingh1/xdaforums huggingface dataset:
[FYT Android Head Units] surfer63:
I don't see it yet. What would be useful to start from my Jet apk? Can you explain?

Please also note that when I started the JET apk I knew absolutely nothing about java (and didn't want to know anything about java) and started in appinventor/thunkable, as that was easy enough. But it is a big mess of all kind of shell scripts called from my app using the "rootexec" plugin, because that was the only way to make it work.

If I would start again I would rewrite it immediately in java.

So perhaps your own app would be a much better basis than my JET apk.

Please don't think I'm against it, but I do not understand (yet?) why that would be useful.
[FYT Android Head Units] bambapin:
Don't know, i thought of your JET because i see it as a great collection of tools dedicated to Joying head units.

Given that on android 8 the intents ACC_ON and ACC_OFF are not usable, it could be an additional tool that allows you to schedule actions to be performed on wakeup without without the need to set Tasker as an NAVI app and without Xposed, since it still doesn't work on SC9853i.

BTW about Xposed i am also afraid, but i really hope i'm wrong, that with the code obfuscation of the firmwware, the maintenance of the Xposed modules will become increasingly difficult.

However, i will make a mini app with a list of apps to launch at ACC_ON (in my case the Accessibility Service, Poweramp and the NAVI), the code will be available if you change your mind :).
[FYT Android Head Units] surfer63:
Based on your work on USB, I also started to work on that idea again and built a "UsbReceiver" in my FytHWOneKey. It works great on my old sofia (6.0.1), but the usb event (""android.hardware.usb.action.USB_DEVICE_ATTACHED"") is never triggered on my 8.0.0 PX5. It doesn't work there.

Does this USB still work for you on 8.1.0?

Xposed will no longer be feasible indeed when you look at the code obfuscation.

Your list of apps to be started: An internal list or external list (ascii config/ini file?), or preferences list?
[FYT Android Head Units] bambapin:
Yes, it's the intent i'm still using to re-activate the accessibility service. It seems strange to me that it is not triggered at all, do you have any other app installed that could "steal" it? Torque for example?

EDIT: did you fetch the last version from github? i added a .xml with the filtered devices, it could be required (it depends on the firmware implementation)

Internal, stored in the shared preferences.
[FYT Android Head Units] surfer63:
No other apps, only my own FytHWOneKey.

I did see the xml, but did not understand it and wanted to ask later. Those vendor id's / product id's: Are those from your usb devices or are they from (internal) Joying devices?

I can only find one vendor-id in the USB device database.
[FYT Android Head Units] bambapin:
Since i'm a lazy guy i found that file on the net :)

Actually the one that triggers the intent on my car is the arduino <usb-device vendor-id="9025"/> (0x2341)
[FYT Android Head Units] surfer63:
I just did some tests I should have done earlier. When I turn ignition on, nothing happens. However, I do ha a DAB tuner and a dashcam connect. With the unit on, nothing loaded, nothing used, and disconnect/connect the dashcam or the DAB-tuner, the USB intent is triggered and my app reacts.

So why does it react when "actively" disconnecting/connecting USB devices, but not when coming from deep-sleep?

I don't get it (yet).
[FYT Android Head Units] bambapin:
Is it possibile that the devices are not disconnected on deep-sleep? A no-kill mod or something like that prevents the disconnection?
[FYT Android Head Units] surfer63:
I'm not using my own nokill mod :)

And the nokill mod has nothing to do with deep-sleep and disconnecting/connecting usb devices. The number of apps being killed before going into deep-sleep is reduced by using de nokill mod.
[FYT Android Head Units] surfer63:
This "com.cpsdna.mirror" and a bunch of others (see further below) are only available in the PX5 and 9853i main server apks, not in the Sofia ones. Maybe some software that some of their resellers use on the Chinese market and not for Europe/US. So probably not old software like I first expected.

==

with regard to the ino (and sorry for being so ignorant and so slow-witted):

Yesterday evening I received my Arduino pro micros. To first read the resistances, I outcommented the "#include "HID-Project.h"" and all "Consumer.write" statements. The latter I substituted with "Serial.print("<specific key code>");

I had to add "#include <Keyboard.h>". (Does it compile correctly without for you?)

Now when I connect ACC and GND to the unit, and key1/2 to A2 and A3, connect the micro pro via USB to my laptop and open the serial monitor in arduino, I get a really overwhelming and continuous amount of random *KEY* printouts.

When I press a button (any button) on my remote I only get values between 634 and 649 (the tolerance I assume), but really the same for ALL buttons.

Can you please explain what I'm doing wrong (and I will write it down and deliver it as a READ.me pull-request for your repo :) )

=================

The still readable code in my PX5 main server:

public static void startHaoGuObd() {
if (isInstalled(App.getInstance().getApplicationContext(), "com.cpsdna.mirror")) {
startApplicationByPkg("com.cpsdna.mirror");
}
}

public static void startrunspeech() {
if (isInstalled(App.getInstance().getApplicationContext(), "ava.com.avaaccessibility")) {
startApplicationByPkg("\tava.com.avaaccessibility");
}
}

public static void startCheXunWang() {
if (isInstalled(App.getInstance().getApplicationContext(), "com.yh.devicehelper")) {
startApplicationByPkg("com.yh.devicehelper");
}
}

public static void startyouzi() {
if (isInstalled(App.getInstance().getApplicationContext(), "com.youzi.customer.service")) {
startApplicationByPkg("com.youzi.customer.service");
}
}

public static void starthiworld() {
if (isInstalled(App.getInstance().getApplicationContext(), "com.ex.hiworld.server")) {
startApplicationByPkg("com.ex.hiworld.server");
}
}
[FYT Android Head Units] bambapin:
You have to remove the #include <Keyboard.h> and comment out also the Keyboard.write(...) (when i suggested to comment the Consumer.write i hadn't used them in the code yet).

The reason is that if you include Keyboard.h or HID-Project.h (which includes Keyboard.h) and you upload the sketch, the arduino will switch to USB keyaboard mode.

First you have to reset the arduino to normal mode, then upload the sketch with all the references to the Keyboard commented to read the resistance.

To reset to "normal" mode you have to upload an empty sketch

void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

EDIT: maybe instead of comment the #include and the code it is possibile to use an #ifdef but i programmed in C a long time ago and now i remember little
[FYT Android Head Units] surfer63:
I'm very rusty myself, but your above remark brought some brain cells back to life.

So now in the top of the code:

// define whether we are in read resistance mode or in HID keyboard mode
// For HID_keyboard mode uncomment the #define HID_keyboard
//#define HID_keyboard

#ifdef HID_keyboard
#include "HID-Project.h"
#endif

And in the case statement:

switch(key) {
case 0:
#ifdef HID_keyboard
Keyboard.write((singlePress ? KEY_F1 : KEY_F5)); // KEYCODE_F1
#endif
break;
case 1:
#ifdef HID_keyboard
Keyboard.write((singlePress ? KEY_F2 : KEY_F6)); //
#endif
break;
case 2:
#ifdef HID_keyboard
Keyboard.write((singlePress ? KEY_F3 : KEY_F7)); //
#endif
break;
case 3:
#ifdef HID_keyboard
Keyboard.write((singlePress ? KEY_F4 : KEY_F8));//
#endif
break;
case 4:
#ifdef HID_keyboard
Consumer.write((singlePress ? MEDIA_PLAY_PAUSE : KEY_F9));
#endif
break;
case 5:
#ifdef HID_keyboard
Consumer.write((singlePress ? MEDIA_VOL_UP : KEY_F10));
#endif
break;
case 6:
#ifdef HID_keyboard
Consumer.write((singlePress ? MEDIA_VOL_DOWN : KEY_F11));
#endif
break;
case 7:
#ifdef HID_keyboard
Consumer.write((singlePress ? MEDIA_VOL_MUTE : KEY_F12));
#endif
break;
case 8:
#ifdef HID_keyboard
if(singlePress)
Consumer.write(MEDIA_NEXT);
else
Keyboard.write(KEY_RIGHT_SHIFT);//
#endif
break;
case 9:
#ifdef HID_keyboard
if(singlePress)
Consumer.write(MEDIA_PREV);
else
Keyboard.write(KEY_LEFT_SHIFT);//
#endif
break;

Actually the statement

if(abs(delta) < tolerance) {
manageKey(i, nLoop);
break;
}

would be better as:

if(abs(delta) < tolerance) {
#ifdef HID_keyboard
manageKey(i, nLoop);
#endif
break;
}

(Same for loop2)
[FYT Android Head Units] bambapin:
[MENTION=2550900]surfer63[/MENTION] how's it going with the arduino?

I almost finished the mini starter app, could you check if it works on your PX5?
[FYT Android Head Units] surfer63:
The arduino is driving me completely mad. I'm currently using it against to 12V power supplies. On one supply I get a continuous flow of signals with or without pressing a button. On the other 12V supply I do not get any signal at all. :mad:

I already checked with several analog ports (and changed them accordingly in the ino).

I'll test your app tonight or tomorrow morning.
[FYT Android Head Units] bambapin:
If you test the output of the SWC receiver with a multimeter do you get different readings when you press the buttons?
[FYT Android Head Units] surfer63:
Yes, I do. I had already tested that. That's why the Arduino micro is making me crazy. Maybe it is somehow damaged. I will try with one of my nanos or minis to see what I read on the Serial monitor.
[FYT Android Head Units] bambapin:
Maybe i ask a stupid question, but re-reading what you wrote I have a doubt. How are you using the 12V power supply? The SWC receiver must be powered at 12V, the arduino at 5V (via USB) and the key1 and key2 output voltage from the receiver must ideally vary between 0 and 5V.
[FYT Android Head Units] surfer63:
The SWC is powered by 12 Volt.

The usb connection is of course 5 Volt.

I can set the output of my key1/key2 wires to 5V or to 3.3V by means of a little switch.

When I press one of the buttons, a white led illuminates in the controller box, so signal is received by the controller box.

Scenario 1:

12V connected to SWC. Measuring resistance over key1 and GND, or key2 and GND. => that works. Both in 3.3V as in 5V switch setting.

Scenario 2: 3A 12V power supply to power the old Sofia head unit. Wires split for 12V and GND. Key1/key2 to arduino A1/A2 => continuous flow of values.

Scenario 3: 1.2A 12V power supply to ACC/GND. key1/key2 to arduino A1/A2 => no values at all. (This power supply can also do 14.4V like a "real" car battery)

In scenario 2 and 3, the white led lights up when a button is pressed.

=====

Your FYT-starter app works fine. I tested it now 4 times (with 15 minutes intervals) using several apps, and it does work really well.

Those Accessibilty servers: Are they here for Tasker to be able to call your other app, or does this app also uses them?
[FYT Android Head Units] bambapin:
Wait a second, the continuos flow is correct, you are reading the analog pin, it is a voltage sampled at the frequence of the arduino + the delay set at the end of the sketch.

When no buttons are pressed you read the base voltage +- noise (my BASE=650 constant)

What should happen when you press a button is that the voltage should change, try to use the serial plotter instead of the the serial console, keep pressed one button and check if the graph changes.

Maybe you have to tune the BASE value, and also the 1000 related to the localMin variable (if the voltage is too high it could skip the reading because of the condition

if(localMin < 1000)

===

About the accessibility services: they are not in the app, they are a list of accessibility services installed in the headunit.

If you install JY-HU-Remote you will find in the list also the ToggleService which is responsibile to read the hardware key press sent by the arduino.
[FYT Android Head Units] surfer63:
I'm lost right now. I will first print the code and completely read through the code.

With your base value 650, I do get continuous values around 633-639.

All my button presses (key1 and key2) are between 452-455.

I'm also beginning to think the "button thing" is not correct. Maybe the "button thing" itself, maybe the "controller".
[FYT Android Head Units] surfer63:
I ordered a second pro micro. It behaves exactly the same (just like the nano did). So continues signal ~635 and all button signals around ~450.

I'm more and more thinking that my "button thing" is broken.

Another question: did your use resistors (4K7 or 10K or so) between input ports?

It suddenly came to mind that my "button thing" might simply blow the ports by providing too much current. Will check tonight.
[FYT Android Head Units] bambapin:
No resistors at all.

Later i'll bring the headunit and the buttons receiver home, i'll check with a multimeter my exact readings and i'll tell you.

The too much current idea could be correct even if your ~635 signal is very close to mine, i chose 650 as BASE because my signal was ~700.

If i'm not wrong you said that your receiver was able to switch between 3.3v and 5v output, did you try to change it?
[FYT Android Head Units] bambapin:
Ok i did the measures (only 1 button group but it should be enough).

Multimeter set to measure Voltage 0-6v, multimeter - to common negative, multimeter + to key1 output of the receiver.

Thos are the readings

NO button -> 3.49v

B1 -> 1.29v

B2 -> 1.04v

B3 -> 1.57v

B4 -> 0.51v

B5 -> 0.79v

Pay attention, i noticed that if you measure KEY2 (instead of KEY1) while you are pressing the buttons group that belongs to KEY1, you will read a voltage value lower than the base which changes very very little (something similar to what you experienced).
[FYT Android Head Units] surfer63:
I think my receiver is damaged somehow. I also connected it to the multimeter exactly the same you did.

No matter whether I set it to 5V or 3.3V, the base voltage is 2.02V (very stable) with Key2 connected.

Pressing any button drops the Voltage to 0.03V or 0.02V, both for Key1 as well as Key2 button presses. In this case I think the 0.01V inaccurracy has to do with my multimeter. I have to set it to 20V as on 2000mV it overshoots due to the 2.02V.

When connecting Key1 the voltage is 2.14V. With any button press the Voltage goes to 0.04V. Again here: I have to set it to 20V as on 2000mV it overshoots.

I guess I will order a new SWC controller (but that will take quite some time)

Edit: Something has also changed. In post #31 it did work correctly with the multimeter but not with the pro micro. Now it doesn't work at all.
[FYT Android Head Units] surfer63:
I ordered a new one. The one from Joying.

It comes with only one key wire and it is faster delivered than the "aliexpress" like websites.

I will adapt the ino for the one wire Joying. In that case we have a "2-wire" version and a "1-wire" version.
[FYT Android Head Units] bambapin:
Yep, it should be enough to skip the second loop.

I was thinking... have you ever tried to connect key1 and key2 together on the old receiver?
[FYT Android Head Units] surfer63:
What do you mean? Put both wires on one analog input, like A0 for example?

If so: No I did not try that (yet).
[FYT Android Head Units] bambapin:
Yes, both wires on one analog input, and also remeasure with the multimeter with the 2 cables connected together.
[FYT Android Head Units] surfer63:
It doesn't make a difference at all. So, I'm waiting for the new SWC controller.
[FYT Android Head Units] surfer63:
I'm getting so tired of this. Murphy is hitting me hard.

So I got my new controller and wanted to start again.

However, in the past weekend I upgraded my (firmware modified chromebook running linux) Ubuntu based GalliumOS from 2.1 (Ubuntu 16.04LTS) to 3.0 (Ubuntu 18.04LTS).

And now that I connect my micro's again, they are not recognized anymore. (And of course I didn't test. Why shouldn't it work?)

Connecting it to an old Windows laptop gives the same issue: my micro's are not recognized.

So did I blow my micro's as well (although they still worked on my 16.04 setup), or is it just a simple drawback?
[FYT Android Head Units] bambapin:
Did you already try to reset the arduino by shorting the pins reset and gnd?
[FYT Android Head Units] surfer63:
Shortly after I typed above message.

They also behave differently: one micro has just the green led. The other micro has the green led and the TX/RX led burning continuously, until I reset it. Then the TX/RX led go out. But when removing the RST/GND connection they immediately switch on again: constantly, not reacting or real TX/RX data. I can't find anything on that on the web.
[FYT Android Head Units] bambapin:
I think it is stuck on HID keyboard mode, the reset doesn't clear the eprom.

You have to find a way upload an empty sketch, when you reset the arduino you have a small time window, 10 seconds or close to this, to reset the eprom by uploading an empty sketch, you have to be very fast.
[FYT Android Head Units] surfer63:
I already tried that, but in the 8~10 seconds window I do not get a usb connection, so I still can't upload.

I should have an fsdi somewhere, so I will see if I can use that. Or I will use one of my other Arduinos (nano) to flash my micro's.

It also confuses me that it is (maybe) stuck in hid mode as I still use the "read resistance" version on both micros.

It is just that I don't want all this fuss, so I need to motivate myself :rolleyes: (and "restore" a lot of knowledge I already forgot).

===

Edit: I have a very busy week ahead with not much time for the car. I ordered a new micro that should arrive somewhere 2nd half of the week. That's currently my best (and most lazy) option.
[FYT Android Head Units] surfer63:
Got my new micro.

Uploaded the sketch. Disabled loop2, set base value to 350. Disabled the managekey, as I'm only reading. And added the following after loop1.

// calculate the average:
average = total / numReadings;
Serial.println(average);

12V on the receiver. Only one wire to Analog input A2, but also tried some others.

Did not push any button and got attached graph in the serial plotter.

Pushing a button doesn't make a difference.

When using the serial monitor I actually get the same graph. A number of readings on 0, climbing to 1023, staying on 1023, going down to 0 again, and this in loop: the same graph in ascii.

When measuring the key wire directly with a multimeter (- on GND, + key wire) I get 115 mVolt constant.

By now I feel so dumm. I don't understand at all.

If you have any clues, please let me know.
[FYT Android Head Units] bambapin:
This is with the new SWC from Joying? The multimeter measure changes when you keep a button pressed?
[FYT Android Head Units] surfer63:
Yes, it is. This is the default output without any button pressed.

But like mentioned: also with buttons pressed it doesn't change, or not noticeably.

I do see some change, but exactly the same as I saw with the previous one. Always seeming a very minor peak with the same value, completely disappearing in the noise. So is it a value or not, or again some disturbance in the signal?

Maybe with a completely stabilized power-supply from, or in combination with, an oscilloscope I could say more, but not at the moment.

Like in our head units itself, the USB might also generate all kind of noise over other signals.

Some completely other question: I hooked up a real USB keyboard to my unit as I needed to type a lot (some other test/project), but that also resulted in the fact that I could not use my soft keyboard at all anymore.

That also meant I could not type in destinations in my navigation app other than from the usb keyboard.

How does this work with the micro pro in keyboard mode. Does it disable the soft keyboard?
[FYT Android Head Units] bambapin:
When an hw keyboard is plugged in, there is an option (in the Android hw keyboard settings) to always show the soft keyboard.

About the voltage readings there should be something that we are overlooking, it cannot be so different from my receiver...

Inviato dal mio SM-G965F utilizzando Tapatalk
[FYT Android Head Units] bambapin:
I got an idea, it doesn't explain the reading on the multimeter but it could explain the very floating values on the arduino.

The problem could be caused by something strange in the connection of the GND, as if the negative of the arduino taken from the USB was a circuit completely separate from the negative of the receiver (are you using a battery-powered laptop?).

Try this sketch and add a connection between the GND of the receiver and the GND of the arduino (the one near the reset pin, on the same side of the A2).

const int numReadings = 40;

int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average

int localMin = 1000;

int inputPin = A2;

void setup() {
// initialize serial communication with computer:
Serial.begin(9600);
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}

void loop() {
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = analogRead(inputPin);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;

// if we're at the end of the array...
if (readIndex >= numReadings) {
// ...wrap around to the beginning:
readIndex = 0;
}

// calculate the average:
average = total / numReadings;
Serial.println(average);

delay(25); // delay in between reads for stability
}

Let's check with the serial plotter if the signal is more stable
[FYT Android Head Units] surfer63:
I did indeed use my laptop on battery power, but I tried now on net power and battery power.

See attached graph. The graph is the same for GND connected or not. When connecting or deconnecting GND, I do get "spikes with noise" which fade away within a second and then it is exactly the same.

This graph is for battery power (graph range ~450 - ~550)

If I switch to net power I get the exact same graph but then from ~500 - ~600, so apparently it puts slightly more power on the usb.

Note that your graph is for 9600 baud. My earlier graph was for 2400 baud as I wanted to see if slower speeds would change the signal.

So I also changed the ino to 38400 baud and back to 2400 baud, but that didn't make a difference.

This also means that it is again completely different from the graph of Yesterday evening. That was of course a different ino, but also used the

// calculate the average:
average = total / numReadings;
Serial.println(average);

It's getting stranger and stranger. :confused:

Maybe I have some alien machine below my house or some overlapping dimensions in my house that mess with the laws of nature. :rolleyes:

Tomorrow busy, Saturday moving my daughter to another appartment. Sunday I have time enough.

Maybe I will get the unit from my car but that means I have to open my complete dashboard as I have USB cables running to left and right. So that is the last thing I want to do.
[FYT Android Head Units] bambapin:
I will be away from home for almost 3 weeks, otherwise i swear i would have bought the Joying controller myself to do the tests :)

EDIT: the overlapped dimension theory is still the most probable but another thing to check is the quality of the electrical contact on the arduino analog pin, i remember that after welding the key1 and key2 wires, the noise had dropped a lot compared to the dupont.
[FYT Android Head Units] surfer63:
I'm guessing now but: have a nice holiday. :)