Giter Club home page Giter Club logo

esp8266's People

Contributors

asolino avatar gerasdf avatar

Watchers

 avatar  avatar  avatar

Forkers

asolino

esp8266's Issues

Have a default WiFi network to connect to

If on first startup (or missconfiguration), the user opens a specific AP (ToI:Love) the device connects to it, and uses it for accessing internet.

This could be used for automatic configuration, see #29

Loop to get all updates in a loop cycle

Think about it:

Today each call to getUpdates() only retrieves 1 update (HANDLE_MESSAGES = 1).
This makes the bot have a longer response time, since it's only doing one getUpdates() pero loop iteration.

Using getPendingUpdatesCount()(gerasdf/Universal-Arduino-Telegram-Bot#7) it's possible to bring them all looping. This is preferred to just looping, specially when using long-polls

Only answer to commands if directed to the device

Commands must be directed to the particular device, otherwise they won't be answered

Some possibilities to identify messages:

  • Accept commands which are a reply_to_message to the last message sent by the device.
  • Accept commands which are a reply_to_message to a message starting with the device's name
  • Accept commands which are a callback_query.message.message_id from the last inline keyboard sent by the device (see #6 )

command: help

show all available commands and current status.
automatically call it on startup

Configuration interface

Commands to reconfigure the device?
/config token blah and /config name blah

or

/token blah and /name blah ?

Or maybe via a webpage?

add timeout and confirmation to /settoken cmd

If the token is wrong the user may completely lose control of the bot.

Implement a confirmation mechanism over the new bot token.

  • receive /settoken
  • ask for confirmation over the new bot token
  • if confirmation is received, keep new token and make it persistent
  • if no confirmation is received, keep the old token and discard the new

Support multiple devices

dupplicate of #7 (different approach?)

If all devices use a single Telegram bot to communicate, it's not clear how the user can talk to them independently.

It may be possible to filter the incoming messages by using the name of the devices in the messages, such as changing

polarity

for

caldera_1 polarity

and then even shortening the names.

But I'm not sure it's possible, as if one device pops the message from Telegram, the other devices won't see it. And if devices just peek the messages (is it even possible?) who will finally pop it and remove it from the list?

so maybe we need one different Telegram Bot per device? or is there anything like telegram-users-for-devices?

/settoken should clean updates

if /settoken doesn't clean updates, and the device is the only one in the bot, the /settoken command will persist and will be again effective on next reconnection to the same token.

Specially when coming back from a timeout. It's kind of needed or it otherwise enters in a bouncing loop going form one to the other.

Reboots after WiFi reconnections

sometimes the module reboots after reconnecting to WiFi

[321] numNewMessages: 0 last: 888666378 mem: 30960 - 31 - 20312
[321] .[322] .[323] .[324] .[325] .[326] .[327] .[328] .[329] .[330] .[331] .[332] .[333] .[334] .[335] .[336] .[337] .[338] .[339] .[340] .[341] .[342] .[343] .[344] .[345] .[346] .[347] .[348] .[349] .[350] .[351] .[352] .[353] .[354] .[355] .[356] .[357] .[358] .[359] .[360] .[361] .[362] .[363] .[364] .[365] .[366] .[367] .[368] .[369] .[370] .[371] .[372] .[373] .[374] .[375] .[376] .Connected!
[381] numNewMessages: 1 last: 888666380 mem: 11016 - 30 - 7400
[381] Received "allstatus" from 25235518
[381] *ex-Caldera2*: status: *Ok* relay: *Off* polarity: *+*

Exception (29):
epc1=0x4021cfd2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000008 depc=0x00000000

>>>stack>>>
3fffffa0:  feefeffe feefeffe feefeffe 40226c88  
<<<stack<<<
last failed alloc call: 4021E111(288)
ets Jan  8 2013,rst cause:2, boot mode:(3,7)
load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
   I'm ex-Caldera2

It seems to be an out of memory issue

/sysinfo and /allsysinfo commands

This info will answer information about the device itself, not the sensors

  • IP
  • WiFi network and information
  • Uptime (remove from /status) ?
  • Software version
  • RAM usage
  • Flash usage (if used)

Allow several devices on one single TelegramBot

A possible solution is to maintain a list of the last 20 messages in the servers. The offset in a getUpdates call retrieve messages starting at that update_id, and clears all preceding. Incrementing updates_id late by 20 updates will keep 20 in the server.

In this way all devices/instances will always see the last 20 (configurage), and the user can talk to any of them... I think.

Devices need to know if a message is for them or not, see issue #6 for an idea.

Additionally, a device could clean all consecutive message for it starting on the first of the 20. This minimize the number of message in the server. Also, if too many messages for one device are accumulated, other devices can detect a device is failing (or at least have a hint).

Polarity configuraiton

Make it possible to configure light sensor polarity

Telegram command

Report current polarity on status and startup

Support multiple users?

Decide what's better. To support a single user, who needs to be registered, or to simultaneously support multiple users, if at least to command the devices.

One user:

  • All messages are directed to s/he
  • Message only coming from s/he are accepted

Many users:

  • Who gets alerts?
  • Messages are answered to whoever sent them
  • Can anybody take over a device?

Answer keyboard queries

Answer something so the pending icon goes away.

See if better answers are switable
Maybe don't answer messages at all

First configuration mechanism

When the user first plugs in a device (or on missconfiguration or factory reset), there should be an easy setup procedure.

Internet access can be assumed (see #28 and as now implemented using AutoConnect portal)

/rename command

It should change the name of the device as it reports it in the messages.
It must be persistent across boots

/settoken command

This command sholuld let the user change the bot token. Is used to install new devices.
It has to be persistent. Mabe it can only come fom a hardcoded user id?

Only use portal temporarily

To save memory.

Try first to connect using regular wifi and saved credentials.
The, allocate, use and destroy portal on success

Implement a Keyboard interface

help message (automatically invoked on startup) should answer with an Keyboard (https://core.telegram.org/bots#keyboards) with all available commands. The user then clicks on the keyboard to talk to a specific instance. The help message message_id serves to identify to what instance the user is speaking.

https://api.telegram.org/bot648272766:AAEkW5FaFMeHqWwuNBsZJckFEOdhlSVisEc/sendMessage?chat_id=25235518&text=hola&&reply_markup={%22inline_keyboard%22:[[{%22text%22:%22hola%22,%22callback_data%22:%22hola%22},{%22text%22:%22chau%22,%22callback_data%22:%22chau%22}]]}

https://api.telegram.org/bot648272766:AAEkW5FaFMeHqWwuNBsZJckFEOdhlSVisEc/getUpdates?offset=0

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.