**** BEGIN LOGGING AT Thu Sep 27 02:59:59 2018 Sep 27 07:49:43 IroN900:~# cat /sys/devices/platform/musb_hdrc/charger Sep 27 07:49:44 1 Sep 27 07:50:10 he needs to differentiate between charger and charging via computer Sep 27 07:50:19 ^^^ Sep 27 07:53:46 /sys/devices/platform/musb_hdrc/charger == 1 : D+/- short Sep 27 07:54:25 when you connect a charger that doesn't short D+ and D-, your device won't charge. So... exactly what you asked for Sep 27 07:58:53 and reading the full backlog, this is actually _not_ what sunshavi is interested in. They want to know if device is connected to a PC USB data connection Sep 27 07:59:28 and I think the approach is pretty random Sep 27 08:05:31 sunshavi's question seems to be "can I send a signal from N900 to PC?" and to answer this we need to know which is the exact transport mechanism for the signal. USB networking with ssh? USB node polling? usb-tty? Sep 27 08:07:27 original question: >>[2018-09-26 16:01:53] Hi guys. is there a way of knowing if pc suite mode is active?<< Yes there is, but I don't know for sure right now how to check. Possibly lsmod Sep 27 08:07:58 ask pali Sep 27 08:11:29 Maybe by seeing if g_nokia appears in /proc/modules, as opposed to g_file_storage? Dunno if that's an accurate determiner though; I always use either g_file_storage or g_ether. Sep 27 08:12:44 * Maxdamantus managed to disable that "PC suite" dialogue because it would annoyingly unlock the screen when plugging a USB cord in. Sep 27 08:12:53 IroN900:~# cat /sys/devices/platform/musb_hdrc/mode Sep 27 08:12:54 b_peripheral Sep 27 08:12:56 PC-Suite Mode Sep 27 08:13:33 b_idle == unplugged Sep 27 08:13:50 HTH Sep 27 08:14:48 UNDEFINED == mass storage mode Sep 27 08:15:13 until mounted, then b_peripheral Sep 27 08:25:07 anyway note that [[ "b_peripheral" == `cat /sys/devices/platform/musb_hdrc/mode ` ]] still doesn't assert there's for example a working established network to run a ssh connection to the PC Sep 27 08:26:24 you know it failed when "ssh $PC mynotifycmd" returns with error Sep 27 08:27:19 >>... and to answer this we need to know which is the exact transport mechanism for the signal.<< Sep 27 08:30:41 KotCzarny: sunshavi: ^^^ Sep 27 08:31:50 >> Wizzup: I have the notification script done<< mind to share via pastebin? Sep 27 11:10:18 I've noticed that when I charge my n900 and wall charger flag is set absent it means that n900 thinks that it is connected to pc. Sep 27 11:22:24 DocScrutinizer05: afaik the /mode in musb_hdrc doesn't help distinguish between wall plug and pc Sep 27 11:22:37 DocScrutinizer05: it can also be idle when no gadget it loaded, for example Sep 27 11:23:09 mode is D+- short Sep 27 11:23:21 oops sorry nope Sep 27 11:23:39 mode is what the MUSB state machine is in Sep 27 11:23:55 which might be totally random sometimes Sep 27 11:23:59 yes Sep 27 11:24:28 don't tell the father of H.E.N ;-D Sep 27 11:24:50 * DocScrutinizer05 feels that headache again Sep 27 11:25:35 ~hen Sep 27 11:25:36 well, hen is hostmode-easy-now, or http://talk.maemo.org/showthread.php?t=65232, or see ~hostmode Sep 27 11:25:53 ~hostmode Sep 27 11:25:53 hmm... hostmode is http://talk.maemo.org/showthread.php?p=652330, or http://www.youtube.com/watch?v=fkCDyUO0sKQ, or see ~hostmode-powered Sep 27 11:28:40 DocScrutinizer05: good morning at least for me. the mechanism is this one Sep 27 11:30:41 when sms or phone call arrives a python scripts sends a file by bluetooth push notification to workstation. and workstation shown the notification (there a process reading when a new file arrives to a folder). that was in case phone is lost for not having and ssh-key on my workstation (just in case) Sep 27 11:31:47 Vajb: you mean you connect device to a charger without D+- short (cat /sys/devices/platform/musb_hdrc/charger ->0 )? Yes, that is the same situation like immediately after plugging device to a PC host, before ENUM Sep 27 11:32:38 afaik device will constantly try to communicate to host to run ENUM Sep 27 11:33:00 no charging will be done Sep 27 11:33:13 this is the script on n900 http://termbin.com/544z Sep 27 11:33:13 Sep 27 11:33:59 https://github.com/maemo-leste/hildon-status-bar-usb/blob/master/udev-helper.c#L152 Sep 27 11:34:02 sunshavi: mhm, so how is this related to USB? Sep 27 11:34:37 the problem happens when i disconnect|unplug the device from my workstation Sep 27 11:35:49 no usb host (workstation). then no no bluetooth host 4 receiving the file Sep 27 11:37:25 ??? Sep 27 11:39:05 if not host an errors happens within the python script and I would need to restart the process. so process should just do his work when connected to my workstation. All of the if on the python script is for avoiding the error Sep 27 11:39:40 brb. time for doing some duties here Sep 27 11:49:06 DocScrutinizer05: maybe. Bnf shows wall charger as absent. It will charge but keeps charge under 500mah. This happanes randomly when i plug charger in Sep 27 12:05:50 bnf? Sep 27 12:06:26 I seem to recall this is an app that dhows some system diagnostics, right? No idea what it does in detail Sep 27 12:08:04 sunshavi: >>if not host an errors happens within the python script and I would need to restart the process<< no, I think you should catch the error within the script and handle it Sep 27 12:09:16 it shows battery info and charging state, remaining time etc Sep 27 12:10:33 what it does is it pulls info from system battery related file (can't recall the name) and just shows them with info what they are Sep 27 12:11:02 DocScrutinizer05: there is an assert line there (watch the source code) Sep 27 12:11:52 the error happens on that line (assert pipe.returncode == 0 and not errout) Sep 27 12:12:42 because i am debugging the script. I am still tuning it. But it works. I just need to catch some corner cases Sep 27 12:12:53 as I said my device randomly pops out the dialog asking wether I want it to massmedia or usb state and if I don't reset the state with usb-host-mode it will charge only slow and wall charger absent flag stays on. Sep 27 12:13:08 other way to reset this is reboot obviously. Sep 27 12:17:28 Vajb: no idea what you're doing. Yes there is a race condition introducing randomness into charger detection, but I never seen a deadlock from that. Sep 27 12:19:39 sunshavi: I completely fail to understand the concept of what you're doing. USB has nothing to do with bluetooth. You don't need to test any arbitrary USB state to find out whether or not a BT transaction succeeds or not Sep 27 12:23:34 AIUI you want to avoid running the BT command under certain conditions (no PC in vicinity) since >>an errors happens within the python script and I would need to restart the process<< I think you need to catch the error so it does NOT abort the python script and rather tells you that no PC in vicinity Sep 27 12:26:15 docscrutinizer05: how should i know if device if plugged to my workstation, and ton to the usb-wall-charger? Sep 27 12:26:26 s/ton/not/ Sep 27 12:26:26 sunshavi meant: docscrutinizer05: how should i know if device if plugged to my workstation, and not to the usb-wall-charger? Sep 27 12:26:36 why do you want to know that? Sep 27 12:27:03 how is that even relevant? Sep 27 12:27:28 when dev is connected to different machine probably that machine that is not my workstation does not have a bluetooth device Sep 27 12:27:59 on n900 there is no l2ping utility. that could solve the issue too Sep 27 12:28:09 hm? Sep 27 12:28:42 l2ping is for checking with a device with an specific mac-address in on reach Sep 27 12:28:51 s/with/when/ Sep 27 12:28:52 sunshavi meant: l2ping is for checking when a device with an specific mac-address in on reach Sep 27 12:29:01 why do you need USB? Sep 27 12:30:32 for testing n900 is plugged on my workstation (1. check usb-connection; 2. see if my workstation-usb0 has the hardcoded ip needed) Sep 27 12:31:36 WHY??? Sep 27 12:31:36 when you send a file by bluetooth you need to give the device-bluetooth-address Sep 27 12:31:36 as a parameter Sep 27 12:31:36 how's that related to USB? Sep 27 12:32:02 the problem is: "how could be identified my machine from other machines?" Sep 27 12:32:18 err, doesn'tBT do that for you? Sep 27 12:32:41 i am using for that a mechanism that involves usb+ip Sep 27 12:32:47 I always thought that's what BT pairing is meant for Sep 27 12:33:27 whatever that "mechanism", I don't understand it and think it's nonsense Sep 27 12:34:17 n900 is paired with several other devices Sep 27 12:35:57 this is a classical yet very massive and wird instance of an XY problem Sep 27 12:36:03 weird* Sep 27 12:38:22 aiui you do a ping to USB-networked PC host. You as well could do a `ssh notifyuser@PC notify` Sep 27 12:39:04 or you forget about all USB and send your BT data to the right device and catch any "transmission failed" Sep 27 12:39:07 yes that could do the work too but a little insecure. bt is safer Sep 27 12:39:21 no Sep 27 12:39:32 this is NOT insecure at all Sep 27 12:40:43 anyway either BT or USB could do the whole task, you don't need both concurrently Sep 27 12:40:57 actually THIS is sort of insecure Sep 27 12:40:59 i am almost there with my approach. One of your first lines is going to be helpful with the issue. I am going to code that tonight Sep 27 12:41:49 good luck! I'm not going to help implement a flawed broken-by-design "solution" Sep 27 12:43:14 USB doesn't provide *any* info about what you can expect to find on BT Sep 27 12:48:29 why do you think BT is more secure than ssh? Sep 27 12:55:11 actually uploading arbitrary files to your PC via BT sounds damn dangerous, particularly compared to a ssh login that allows only one particular command to execute (add the allowed command to user "notifyuser"'s ~notifyuser/.ssh/authorized_keys line) and needs a proper keypair to do so Sep 27 12:59:42 both BT and ssh are virtually equally uncrackable, and when you lose the N900, then the ssh solution only enables the attacker to trigger a notification on your PC while the disclosed BT pairing key allows attacker to upload arbitrary files aiui - something you definitely want to avoid by all means since such arbitrary file might be a virus or whatever and take over your complete PC Sep 27 13:02:29 even worse, BT allows to do so wireless over the air while the already uncritical exploit of unsolicited SMS notification could only happen when the attacker has physical connection to your PC USB jack (or otherwise log in to your PC), to establish a network and open a ssh session Sep 27 13:08:28 s/ unsolicited / bogus forged / Sep 27 13:08:29 DocScrutinizer05 meant: even worse, BT allows to do so wireless over the air while the already uncritical exploit of bogus forged SMS notification could only happen when the attacker has physical connection to your PC USB jack (or otherwise log in to your PC), to establish a net... Sep 27 13:24:50 sunshavi: man sshd|less -j26 +'/command="uptime"' Sep 27 13:27:17 for your purposes a command="cat >/tmp/notificationtext && popup_notification" prolly will already do the whole trick Sep 27 13:31:58 or, for added safety (flood protection): instead of `cat >` use `dd bs=1 count=$INT_MAXCHARS of=` Sep 27 13:35:30 now, on N900, do `cat SMScontent.txt|ssh notifyuser@neo900` and up pops th notification on your PC. Absolutely no risk except a n900 thief could make offensive notifications pop up on your PC Sep 27 13:36:24 IF they had access to ssh-login to your PC (unlike BT where they need to be nearby, within RF range, only) Sep 27 13:40:31 I for one never use USB for networking, WLAN is so much more convenient Sep 27 14:04:54 actually you better bundle all the "dd bs=1 count=$INT_MAXCHARS of=/tmp/notificationtext && popup_notification" into a bash script mynotify.sh and only hava a command="mynotify.sh" in authorized_keys Sep 27 14:06:07 if you want to implement this, don't hesitate to ask about details Sep 27 14:08:09 actually not even a dedicated new user "notifyuser" is needed, you can run this under your default user account Sep 27 14:09:14 all you need is a dedicated pk-pair for this, with pubkey on N900 and privkey on your PC Sep 27 14:32:01 docscrutinizer05: on the contrary i almost never wlan on n900. Just usb and also bluetooth when needed. Also for consideration both of my n900 have a broken screen. so I access desktop by vnc over usb|bt Sep 27 14:33:54 and fyi my pc priv key is on n900 Sep 27 14:35:49 so from home i could access and modify the complete phone from any network connection. Sep 27 14:36:00 docscrutinizer05: thanks for your help Sep 27 14:57:54 >>and fyi my pc priv key is on n900<< irrelevant for this situation Sep 27 14:59:50 err wait. No. This is what already exactly you need. If you had not swapped the meaning of privkey and pubkey. The provjkey is on the originating side, the pubkey on the "server" you log in to Sep 27 15:00:20 when you log in to N900 from your PC then the privkey is on PC Sep 27 15:02:48 for the solution I sketched above, you need a dedicated key pair exclusively for this solution, you place the pubkey on PC so the N900 can log in to PC using the privkey on N900, and you modify the pubkey on PC so it only works for exactly one command: mynotify.sh Sep 27 15:03:05 my pc can read my phone or exec any ssh cmd on the phone. phone needs pwd when accesing pc Sep 27 15:03:17 ^^^ Sep 27 15:04:55 yes, you generally don't want password-less access from mobile devices to your PC, since you could lose the mobile device Sep 27 15:04:57 yes a dedicated key pair could be the answer Sep 27 15:05:27 in this case however the pubkey gets modified so it works for exactly ONE command only Sep 27 15:05:50 and doesn't need password for executing this one command Sep 27 15:06:21 for giving you the complete picture. i do the phone calls from my desktop-contacts app Sep 27 15:06:41 also i send sms's from my desktop-contacts app Sep 27 15:06:46 you can install this keypair on top of whatever is already there, since you can have multipkle authorized_keys lines Sep 27 20:11:24 Computrace.LoJack->LoJax :-o **** ENDING LOGGING AT Fri Sep 28 03:00:01 2018