This thing is ticking in the back of my head since long time ago, i searched a lot and couldn't find answer,
when push noticition server like onesignal sends a push notification, how does it know the right device to deliver the notification, how does it know it's IP address?
thank you.
Related
At the moment I'm working with the Arduino and SIM900, well, I could say I'm intermediate with the SIM, I could accomplish sending data to my website and receiving data from another phone. But now I would need that when I press a toggle button on my website it will send a message to the SIM900, for example, If I check the button it will send 1 if uncheck it, it will send 0. The problem is, I don't know how to start, I already searched up how to send data to the SIM900, But what I always get is the SIM making a request to the server, I would need the server to send the message whenever it is pressed, without the need of the SIM to keep making requests. Will I need an API for this? Please Help
Your phone (client) is behind a NAT. To reach it, you should read about NAT Traversal tactics, which will enable you to push a message to a client.
You can achieve that with Socket.IO or MQTT.
Your server will have a piece of code that the client should connect to when it's up, and the server will maintain the connection alive so that the server can push messages over this connection.
How do I let two ESP8266's in my home network listen to the same Telegram bot (the same chat_id) at the same time? I am using bot.getUpdates on both ESP's to check for new messages now, but then only the ESP which happens to perform a getUpdates before the other ESP does, receives the new messages. The second ESP receives none. So I think I need to use something besides, or in stead of, getUpdates but I don't know what.
What I would like to achieve is that one ESP (device 1) must only receive and respond to messages which are addressed to him, based on the message text: "1" on the first position of the message text means it's meant for device 1. Messages which don't start with "1" (they'll start with "2") are not meant for him must stay available on the Telegram server for the other ESP (device 2).
More details about the project:
I have a simple ESP8266 project running fine. When the frontdoor of my house opens, a reedcontact opens and a message is sent from the ESP in my home network to my Telegram bot and then I receive a notification in the Telegram app on my phone saying that door 1 has opened. The other way around, when I type "1" in the app, the bot returns the current state of the door. But when I add a second ESP8266 to control the backdoor (door 2), the problem starts: there is one random ESP which receives the messages. which may not be the ESP/door I am asking for.
I am using:
Arduino IDE
clone nodemcu ESP8266 (ESP-12E)
clone wemos d1 r1
Use the offset parameter of getUpdates method. As the documentation states:
By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
You need to pass the last update_id through your ESP8266s, but this is kind of tricky.
I advise you to build a central system (or a master-slave system) that reads and processes the updates from Telegram and sends to the two ESP8266s the relative commands (like "open the door 1", etc...). In my opinion this is the easiest way to do what you want to do.
Would it be easier to have one bot for the frontdoor and one for the backdoor?
They can both send messages and you can send a command to the respective bot to get the state of the door.
I am working on Android BLE as a peripheral connected to a custom device that runs Nordic NRF51 as a central. The project requires Android peripheral to connect to two NRF51 central devices.
Android is advertising two different Advertisement UUIDs one for left and other for right Nordic NRF51 devices. Ideally, I would like to have both Nordic Centrals to connect to the Android at the same time.
I have two main issues.
First issue. Android can get both connections fine. The problem occurs when Android sending notification or Android sending reply back as result of Write Request from the central. When both Centrals are connected, often notification nor the send reply works. I confirmed that the Nordic central does not receive the notification nor the reply. Does anyone have experiences in Android as a Peripheral supporting multiple connections at the same time? I have tried two BluetoothGattServer instances (one for each device) as well as one instance of BluetoothGattServer and based on the connected device, I can tell which Central the event if for and handle it correctly. It is sending notification or send reply to Write Request that at times it does not get sent from Android. I am using synchronized methods on the GattServerCallback event handlers.
Second Issue. Due to the first issue, I am now only advertising one UUID at a time. The idea is to switch between two advertising UUIDs, thus have only one connection at time. The problem now is switch advertising. About 1 out 3 times, when I start advertising with first UUID with its name (LFDroid), it appears that it is actually advertising second UUID with its name (RTDroid) briefly (1 or 2 seonds) and then advertises what was requested. Note that second UUID advertising was stopped on previous switching. It almost looks like when I ask to advertise, it starts to advertise with the last advertised UUID and name and then quickly advertises what is requested. This now causes problem because both Nordic Centrals sees the advertisement and connects.
Any suggestions would be appreciated.
How do I implement notification in BLE?
I have a smartphone, and every hour it will send notification to all nearby BLE devices (smartwatch, RFduino, etc) for time synchronization purpose.
Other devices are server now (since it provides data), and smartphone is the client that collect the data.
Could I piggyback into the advertisement packages? For example, the smartphone always broadcast an advertisement packet to annoucement its presence (that's how other devices can find it). Can I modify that packet to be a time sync?
In order to send notifications or advertisements, your smartphone has to act as a server, which also means that in order to be able to receive notifications or scan for advertisements, your peripheral devices must act as clients.
This can be a bit tricky, because if two devices act as client and server, they may not simultaneously fulfil the other role. You need to switch roles whenever needed, which is an open field for all kinds of problems.
Also, I am not convinced that it is really the optimal choice to let the smartphone regularly notify all devices in the vicinity. Each of the devices that wants to receive the notification has to be connected with the device in order to receive the notification, and this connection has to be already active when the notification is sent in order to really get the correct time. So all these devices need to connect in advance to the expected notification time, and hold up the connection until the notification has come.
It might be better to just advertise the current time, but remember that you can't connect to the smartphone as a server while it is advertising, because the link layer may not be in scanning and advertising mode at the same time, and you may also not be connected when advertising for a similar reason.
If you want to do it that way, you can include the time information in the advertising data. See the Supplement to the Bluetooth Core Specification v6, Part A for further information on the structure of the advertising data. You could put it in the manufacturer specific data.
However, another option would be to write the time directly to the device using a write request. You can define your own service and characteristics. You can include a "time synch necessary" information in the advertisement data of the servers, and when the smartphone evaluates the advertisement, it can connect to the corresponding device and send the time directly.
The advantage of this procedure is that time is only updated if you really need it on the device, and that you do not have to switch client/server roles, because the device in server role may advertise as normal, and the smartphone can always stay in client role.
I've got a problem that we are hoping there is a simple solution for.
We have a need to allow a push notification to appear on a device when it enters into a certain space. The space is only going to be about 1500 sq ft. So my thought is to set up a wifi network in this area... I'm curious if anyone is aware if it is possible to notify anyone with our app installed on their device when they enter into this wifi space if they want to take a certain action... for instance to open the app?
Create an Android service that is launched when the intent WIFI connected is triggered.
The service will check if the bssid of the wifi connection is the same of the wifi area you want to monitor and then it could either launch the app/show popup/show notification.