i have GSM modem (ZTE MF112) connected via USB port. I can send and receive SMS with this modem through serial port but i want to monitor the modem continuously for received SMS. if an SMS received, i want to connect the database, search the required information and send it back to the sender.
i need the whole process auto-method without any human interference.
like:
A function which will monitor the Serial port
if an SMS is received, it will call another function and pass the queried information to it and that function will connect the database. if information is found that information will be return otherwise some message will be return to the first function.
Note: The code is needed in VB.Net
some body help me plz.
One way is you make a loop which check for for any unread messages after certain time period like 5 sec or 10 sec if there is any unread message it gets it from modem parse it and display it
I have figured it out. I have added a timer to my application and set its delay to 5000 ms (5 s). Inside the timer_tick event I wrote the code to check and list up unread SMS from the modem.
Related
Looking to understand whether there is a a bulletproof event from the namagedObject side of c8y where we know the device has just connected.
I have a microservice that listens for events in real time and I want to trigger a process once we know a device has connected to send its payload.
We have used:
"c8y_Connection": {"status":"CONNECTED"}
We have had the microservice log to Slack all events from managedObjects where we saw for three days the "status":"CONNECTED" value in the payload of our demo devices at reporting times.
But after three days, we see no more this "CONNECTED" state (all payloads showing "DISCONNECTED").
What I am trying to achieve from the inventoryObject event is to understand when a device had connected and sent payload to know when data had arrived. I then go get the data and process it externally. This is post registration and as part of the daily data send cycle for my type of device.
What would be the best way to understand when a device has sent payload in a microservice? I want to notify an external application with either “data is arriving for id 35213” or even better, “data has arrived for device 35213, and here’s the $payload”.
Just as a general information ahead:
The c8y_Connection fragment showing connected shows an active MQTT connection or an active long polling connection and it is only evaluated once every minute.
So if the client is just sending data and immediately disconnecting afterwards this might not picked up.
If you want to see the device having send something to Cumulocity maybe the c8y_Availability fragment is a better as it holds the timestamp when the device last send something.
{ "lastMessage": "2022-10-11T14:49:50.201+09:00", "status": "UNAVAILABLE"}
Also here the evaluation (or better the update to database) only happens every minute.
Both c8y_Availability and c8y_Connection however are only generated if the availability monitoring has been activated for the device (by defining a required interval for the device).
So if you have activated the availability monitoring and you see a "lastMessage" you can reliably say that the device has already send something to Cumulocity.
i doing a simple application that able to integrate with GSM Modem to send and receive the SMS. i had completed the send SMS part, but i not able to receive the SMS. i get error message said that my SIM card memory is full when trying to send the SMS with other mobile device to my SIM card in the GSM Modem. i tried to use the AT command "AT+CMGL" to remove all the messages, but still same. May i know there are any method to store the message in my computer memory so that i able to receive the SMS with my GSM Modem. I using the sample code from here
http://www.codeproject.com/Articles/38705/Send-and-Read-SMS-through-a-GSM-Modem-using-AT-Com
The AT+CMGL command is for listing messages, not deleting them. Deleting messages is done with the AT+CMGD command. Do yourself a favour and download a copy of the 3GPP 27.005 standard, it defines all the standard sms AT commands (most other mobile phone AT commands are defined in 27.007), and by all means get a copy of the ITU standard V.250 which defines the basic command syntax, structure and behaviour for AT commands - an absolute must read for anyone that issues AT commands (read all of chapter 5 at least). These documents are more valuable than any random internet web site, including stackoverflow.
Speaking of random websites, the web page you linked as source seems to be of dubious value. It gives an example function DeleteMsg which issues AT+CMGF=1 but this command does in no way delete anything, it selects text or PDU mode for the various sms related commands.
It does have response handling that is better than the horrible send-sleep-read mistake that unfortunately is not as uncommon as it ought to be, but it is only half decent and not robust at all.
After sending an AT command to a modem you should continuously read and parse response lines from the modem (over and over again) until you receive a final result code (and not just once). See this answer for details.
All of the the message commands operate on the storage location set by AT+CPMS. And notice that you should always set <mem1> and <mem2> at the same time, e.g.
AT+CPMS="SM","SM"
It both makes little sense to only change one of mem1/mem2, and some phones do not like attempts to set only one of them.
In my project.i have below requirement.
we have to send some request to ATM.
so before sending response Atm will send some notifications.
As per requirement we have to listen the notifications and some how we need to send these content of this Notification tag to presenter.
for example
we are sending request to ATM---Rq1
then it sends some notifications like N1--it is a xml so for example value tag value is "some text".so this we need to send to presenter.if again we receive
N1 then needs to send the value tag value to presenter.so all these should send to presenter immediately.
once we receive response from ATM we can send the response data by using RPC.
The main motive is if we receive notification at 10:00 AM then we should send value tag value to the presenter.then next notification if we receive at 10:01 that value tag also we need to update to presenter.
So kindly advise us..if my question is not clear kindly let me know.
To my knowledge, an RPC call will only return once. And a server cannot directly communicate to a browser like the browser can to a server.
You might want to implement an asynchronous polling system. Essentially, your call your main RPC service, call it bigMethod(). After you call it, you immediately and asynchronously begin calling a polling method. just call it poll().
Every second or two, (or however long you think), it runs out to the ATM to check if there's a message. Once bigMethod() finishes you stop polling.
The downside is that this solution will require some tweaking of the back end code to handle it.
I need help to make Visual Basic not stop while sending emails.
I am using Smtp_Server.Send(e_mail) everytime it's sends an email the program stops for 5 seconds and then it's stop work for maybe 3 sec and then it sends the mail.
I want to be able to still use the program while it's sends the mail Help plz!
You can use some logging or careful observation in the debugger to confirm, but the conversation between your client and the SMTP server is probably taking 5 seconds (which is quite long, but plausible).
The solution is to use multiple threads to send email.
If you are sending batches of emails, try starting with 5-10 threads (with too many, the SMTP server on the other end might start rejecting some connection attempts).
If you are trying to send a single email at a time, but it is blocking your main application, you can use a single separate thread to perform the send.
i'm creating a windows form to send/receive data to/from serial port.
At first : i send the data as string to the serial port .
Second: i tried to read the string again for test the successfull transmission , but i recieved empty string
this is my code :
Try
Dim SerialPort1
As New SerialPort("Com1",9600, Parity.None, 8, StopBits.One)
SerialPort1.Open()
SerialPort1.DtrEnabled=True
SerialPort1.WriteLine("This is my test message ." )
' ================= Read from serial port
Label1.Text=SerialPort1.ReadExisting() ' this returns empty string
Catch ex As Exception
MessageBox.Show(
"Error writing to serial port:" & ex.Message)
Finally
SerialPort1.Close()
End Try
i need to ask another question:
is it required to connect device to serial port to send/recieve data successfully ????
please i need an urgent help
thanks
As Heinzi already mentioned, if you want to see data you need to have some coming in. There is no automatic echo of data you send out.
To answer your other question: Yes, you need to have another device connected to your serial port in order to send/receive data successfully. With no other device, what would be the point?
Fortunately for you, the "device" you connect can be as simple as a plug with some wires. Here is a set of instructions and diagrams for building a so-called loopback plug: http://www.airborn.com.au/serial/rs232.html
This will allow you to echo your output to your input using very simple hardware. If you're not into soldering up your own plug, you can use a so-called breakout box or board. Here's an example: http://www.breakoutboxes.com/D-Series-9-Position-Breakout-Board_p_31.html .
ReadExisting returns the data sent by the device you are communicating with, not the data sent by you.
You could try to use com0com for generating a virtual serial port pair, then you can rename one of these virtual ports to common name like "COM4". You should open other SW like hyperterminal for serial communication, then set to open the remaining port from the pair.
You may try to use com0com fist with two hyperterminals.
You will need a device through which your application will send and receive data.
For testing, you might consider creating a virtual serial port with software like this Virtual Serial Port Driver. It allows you to create serial ports that aren't actually connected to any physical device. You can then debug your program with another program or with something like HyperTerminal or PuTTY.
Assuming you have a loopback plug (simply connect pins 2 and 3 together) so that anything you send is immediately received.
However - you need to consider that the RS232 is slowly. ("S L O W L Y") and the transfer happens asynchronously so your program is hitting the readexisting long before the data has even been sent. So you're reading an empty buffer.
Just for the sake of your test you need to put some delay in there. so that you can wait a moment after sending before trying to receive.
In a real application though you'd use the receive event to read the serial port.