plewin / tp-link-modem-router

Goodies for TP-Link modem routers
GNU General Public License v3.0
82 stars 17 forks source link

Any chance to add Delete SMS? #14

Closed algorni closed 2 years ago

algorni commented 2 years ago

Excellent being able to list sms and send SMS but what about DELETE SMS?

plewin commented 2 years ago

Hey @algorni,

Are you asking about the inbox or the outbox ?

Can your use case be solved with the api bridge ? There are some operations supported for managing the inbox in the api bridge: https://github.com/plewin/tp-link-modem-router/blob/master/src/controllers/sms.mjs Namely listing, marking a sms read, and deleting from the last 8 sms in the inbox.

Best regards,

Salvialf commented 2 years ago

Hello @plewin,

A big thank you for this library that allows me to interface the SMS function of the router with my smart home software (Jeedom). I wrote a plugin around it and it works perfectly even with polls each second.

I join this issue to ask if it would be possible to implement the SMS deletion function for the outbox?

Thanks again for all the work you have done here, that's exactly what i was looking for.

plewin commented 2 years ago

Hey Salvialf,

Happy it was useful to you, don't hesitate to share what you wrote, in your repository or a gist. It might be useful for someone who search jeedom + the router.

It might be possible. I actually broke my router (a sim reader pin broke) and decided not rebuying it. I will see if I can still use it to develop this feature. I don't recall exactly but if I haven't implemented this already it might be because I had trouble making it reliable.

Best regards,

On Thu, Sep 23, 2021, 15:20 Salvialf @.***> wrote:

Hello @plewin https://github.com/plewin,

A big thank you for this library that allows me to interface the SMS function of the router with my smart home software (Jeedom). I wrote a plugin around it and it works perfectly even with polls each second.

I join this issue to ask if it would be possible to implement the SMS deletion function for the outbox?

Thanks again for all the work you have done here.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/plewin/tp-link-modem-router/issues/14#issuecomment-925810786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFMVLI5GSNJZAZGVI5CJW3UDMSTFANCNFSM5DLTDTIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Salvialf commented 2 years ago

Thanks for the quick response. This Jeedom plugin will be shared on github and accessible to all very soon, it was already planned. This function will be very useful because the plugin is provided with a management interface for inbox and sending box but this is limited to the inbox for now.

I suspect that it is not necessarily easy so thank you for taking the time to consider this request. I tried to adapt the function "router.delete" by replacing "inbox" with "outbox" and "LTE_SMS_RECVMSGENTRY" with "LTE_SMS_SENDMSGENTRY" without success (of course).

Too bad you don't use this router anymore, there aren't many available libraries that allow to interact with it. For my part, I will continue to study your lib that I only discovered a few days ago.

plewin commented 2 years ago

@Salvialf So my router is still usable for development, so I will see what I can do for the outbox. I will keep you updated.

Your work looks quite nice, you don't mind me adding a link in this project readme as project of interest ?

Yes, this repository is AFAIK the current best reference for interacting with these routers. The encryption used by this router is odd and its protocol undocumented.

Salvialf commented 2 years ago

Hi @plewin,

Glad to read you and learn that you are still able to use your router for development.

Thank you for your positive feedback on my little Jeedom plugin. Of course you can refer to it with great pleasure.

I'm in a hurry to know if you were able to successfully delete sent messages through the API.

RudySixOw commented 2 years ago

Hi, @Salvialf, Can you share your jeedom plugin ?

Salvialf commented 2 years ago

Hi, @Salvialf, Can you share your jeedom plugin ?

Hi @RudySixOw,

You can found it here : https://github.com/jeedom/plugin-tplinksms

I want to rework the daemon before officialy share it.

RudySixOw commented 2 years ago

Thanks @Salvialf.

Do you find the solution to delete all inbox and outbox messages ?

plewin commented 2 years ago

@Salvialf Unfortunately I have to forget about implementing this because I have no data on my broken router to develop or test.

If anyone is interested in getting this implemented, please investigate / capture the traffic between the browser and the router.

Here is how to implement a cheap traffic capture : Log in in the router UI at 192.168.1.1 Open developer console with F12. Allow pasting if necessary. Paste and execute

$.Iencryptor.AESDecrypt_backup = $.Iencryptor.AESDecrypt;
$.Iencryptor.AESEncrypt_backup = $.Iencryptor.AESEncrypt;

$.Iencryptor.AESDecrypt = function(data) {
    let decrypted = $.Iencryptor.AESDecrypt_backup(data);
    console.log("RECV:\n" + decrypted);
    return decrypted;
}

$.Iencryptor.AESEncrypt = function(data) {
    console.log("SEND:\n" + data);
    return $.Iencryptor.AESEncrypt_backup(data);
}

All traffic will be logged in the console in plain text.

By browsing to the outbox ui, moving to some pages and delete one or two messages, it should be enough to implement something in the bridge api.

Salvialf commented 2 years ago

Hi @plewin,

Thank you for this elements that confirm my first idea was not so bad :

I tried to adapt the function "router.delete" by replacing "inbox" with "outbox" and "LTE_SMS_RECVMSGENTRY" with "LTE_SMS_SENDMSGENTRY" without success

So i tried again with this code that I kept commented and it turns out that it works perfectly ! Sent messages are well deleted. I don't know if I forgot to restart the daemon or to reload the page when I tried earlier.

Anyway, i made a pull request in order to add sent sms deletion : #19

Thanks again for your availability and your precious help

plewin commented 2 years ago

Hey @Salvialf thanks a lot for your help ! It's merged now.

I am marking this issue as closed.