Giter Club home page Giter Club logo

Comments (5)

shurillu avatar shurillu commented on August 25, 2024

Hola Javier,
this is not a CTBot library issue, anyway I'll try to help you.
I guess you don't update the ESP8266 core for some compatibility issue versus old code, but I strongly suggest you to update.
BTW the core of the CTBot library is the sendCommand() method: it is "self contained". In other word that method:

  • establish a connection to the Telegram Server
  • send the defined command
  • get the response
    There are a lot of other stuff inside (for example, exit when the JSON packet is complete without waiting the connection timeout) so my advice is: try to use the code in the sendCommand() method stripping out all the fancy code.
    As far as I remember, the fingerprint is mandatory only from 2.5.0 ESP8266 core library version and above, so I guess is not a fingerprint problem...
    Finally, try to use this code to create the WiFiClientSecure object:
	BearSSL::WiFiClientSecure telegramServer;

and in your setup, set the fingerprint:

	telegramServer.setFingerprint(m_fingerprint);

My last advice is, when you can't figure out what is going wrong, put some console log (Serial.print()) printing out the returned codes of the functions/methods called as you can monitor if errors occurred.
Let me know if you found a solution.
Mucha suerte hombre y que te vaya bien!

Stefano

from ctbot.

javierferwolf avatar javierferwolf commented on August 25, 2024

Hola Stefano!! gracias por tu respuesta! CTbot es una biblioteca estupenda! =)

Yes is true it is not a library error! sorry! but I was so interested to know how the library CTbot works so that it still works in version 2.4.2. For reasons of library compatibility, I cannot update the version of core 2.4.2.

if I understood correctly, at the beginning of the sketch I have to write: const uint8_t fingerprint[20] = { 0xBB, 0xDC, 0x45, 0x2A, 0x07, 0xE3, 0x4A, 0x71, 0x33, 0x40, 0x32, 0xDA, 0xBE, 0x81, 0xF7, 0x72, 0x6F, 0x4A, 0x2B, 0x6B }; and BearSSL::WiFiClientSecure telegramServer;
then in the setup block: telegramServer.setFingerprint(m_fingerprint); but i have a question where does this variable "m_fingerprint" come from?

grazie per il tuo aiuto!!=)

from ctbot.

shurillu avatar shurillu commented on August 25, 2024

ehm... copy/paste error :-D
As you said:

  • In the beginning of the sketch (global variables)
      const uint8_t fingerprint[20] = { 0xBB, 0xDC, 0x45, 0x2A, 0x07, 0xE3, 0x4A, 0x71, 0x33, 0x40, 0x32, 0xDA, 0xBE, 0x81, 0xF7, 0x72, 0x6F, 0x4A, 0x2B, 0x6B };
      BearSSL::WiFiClientSecure telegramServer;
  • In the setup block:
      telegramServer.setFingerprint(fingerprint);

Try and let me know ;-)

Stefano

from ctbot.

javierferwolf avatar javierferwolf commented on August 25, 2024

Stefano, now it works but in the first cycle, that is, the first connection to the api.telegram.org server works and can send the first message! but then when performing the same action again "Connection 149.154.167.198:443... Connection to the server failed!" what would be the problem?

from ctbot.

shurillu avatar shurillu commented on August 25, 2024

Javier, I see in your first posted code a lot of client.connect() but you don't close any connections.
The error that pop out is likely a connection issue due an already established connection.
My advice is to build up a procedure that do:

  • connect to the telegram server
  • send the command passed as paraeter when call the procedure
  • read the telegram response
  • close the connection

Let the CTBot library sendCommand() method inspire you ;-)

Stefano

from ctbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.