aabmets / SIM800

A comprehensive SIM800 Series library for simplified and in-depth chip access.
GNU Affero General Public License v3.0
38 stars 27 forks source link

Call Doubt #2

Closed jemos closed 7 years ago

jemos commented 7 years ago

Hi,

I found this library and I've a simple doubt to be able to use it. From what I know when the module is receiving a call it sends a specific message. How this is handled by the library, is there a callback function that is called whenever a call is received by the module? I couldn't figure it out from the code.

Thank you. Jean Mousinho

aabmets commented 7 years ago

When you call any AT method on the SIM object, which sends an AT command to the SIM module, it will after transmission immediately enter a read loop and wait for a return message from the SIM module. To prevent infinite read loop, there is a timeout global variable, which can be modified by SIM helper methods. The read loop reads the message from the SIM module into the general buffer, which can be modified from the SIM800 header file. This buffer is linear, such that when the message is longer than the buffer size, the rest of the message is discarded. To overcome this limitation, there is a helper method which can be used to scan a message piece by piece to process it fully. This requires multiple identical consecutive AT method calls to the SIM module and must be executed manually by the user in their source code.

On 18 March 2017 at 00:44, Jean-François Mousinho notifications@github.com wrote:

Hi,

I found this library and I've a simple doubt to be able to use it. From what I know when the module is receiving a call it sends a specific message. How this is handled by the library, is there a callback function that is called whenever a call is received by the module? I couldn't figure it out from the code.

Thank you. Jean Mousinho

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aspenforest/SIM800/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/AGoExP0y78Fw75hRyt09tcZQBjnkSZ7Eks5rmwzGgaJpZM4MhLaT .

jemos commented 7 years ago

Understood. But I think you misunderstood my question. That is related to when is the client the initiator of the message exchange (as you said, the AT command is send to the SIM module and will then have a read loop to get the reply from the module). But I was asking about the other way, when the SIM800 actually sends some message that is not a reply from AT command. For example when a call is received:

...
RING <- sent by SIM800 when a call is received
RING
ATA <- to answer the call we need to send this to the SIM800

Thanks for your help!

aabmets commented 7 years ago

Ah, okay. What you are talking about are the URC-s, or Unsolicited Response Codes.

There is no way with this library to automatically enter a read loop upon a comm request initiated by the SIM800 module. You need to manually use the SIM.available() helper method which internally calls SoftwareSerial and returns true, if there are characters in the SoftwareSerial buffer.

I think there should be a pin on the SIM800 module (was it called DTR?) which should output high when the module wants to send an URC. I'm not entirely sure, but the functionality of the DTR(?) pin can probably be enabled by sending an appropriate AT command to the SIM800 module. Also, you should check if the module provides a lead-out of the pin from the chip itself. If that's the case, then all you need to do is to wire that pin to an arduino digital pin and if it reads high, then jump to appropriate response processing logic.

On 18 March 2017 at 21:02, Jean-François Mousinho notifications@github.com wrote:

Understood. But I think you misunderstood my question. That is related to when is the client the initiator of the message exchange (as you said, the AT command is send to the SIM module and will then have a read loop to get the reply from the module). But I was asking about the other way, when the SIM800 actually sends some message that is not a reply from AT command. For example when a call is received:

... RING <- sent by SIM800 when a call is received RING ATA <- to answer the call we need to send this to the SIM800

Thanks for your help!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/aspenforest/SIM800/issues/2#issuecomment-287567260, or mute the thread https://github.com/notifications/unsubscribe-auth/AGoExPGRqlpneA4Y8dmgaa2ajldJcoIIks5rnCoogaJpZM4MhLaT .

jemos commented 7 years ago

Thanks very much, that clarifies my doubt : )