roberttidey / IRBlasterWeb

Infra Red Remote Blaster using esp8266 including bit bang libraries
9 stars 2 forks source link

Missing components #1

Open fenyvesi opened 6 years ago

fenyvesi commented 6 years ago

It is a good program and detailed decription.

When I compile it I get the error messages:

  1. IRBlasterWeb:866: error: 'base64_encode' was not declared in this scope base64_encode(unameenc, uname, strlen(uname));
  2. 'class HardwareSerial' has no member named 'printf_P' Serial.printf_P(PSTR("Waiting %d mSec\r\n"), cmdWait);

I use Arduino 1.8.5 , ESP8286 2.3.0

My questions:

  1. Which base64 you use?
  2. Some #define or library seems to be missing related to printf_P.
  3. What is the difference between the 2 IRBlasterWeb.ino-s? (One of them in a separated folder, without temperature.)

Thank you.

George

roberttidey commented 6 years ago

Yes. I recently updated to include optional temperature monitoring (which use the base64) and the git upload got a bit messed up.

Should be OK now.

Old ino deleted New ino moved into its correct folder base64 files included. (I just keep them with the ino)

Not sure about comment 2 at the moment

fenyvesi commented 6 years ago

Thank you. I check. I found a syntax error in line 210: Serial.print(F(("."))); one ) was missing.

Comment 2 has been solved, upgraded to Arduino ESP8266 2.4.0

roberttidey commented 6 years ago

Thanks. Yes two more errors in transcribing for git. ( I have to keep my dev version separate as it has passwords etc in)

Mispell of TEMPERATURE define Extra bracket in line 210. That one didn't cause a compile error for me strangely. I think the F macro must do something.

fenyvesi commented 6 years ago

Thanks. I don't use temp, so it is commented out.

fenyvesi commented 6 years ago

I uploaded all the devices files you created but can't delete a part of them on ip/edit page. I can see only upload and create buttons. How to do it?

roberttidey commented 6 years ago

You can delete a file on edit by right clicking on file name link. It allows a download or delete.

If you left click then you can edit it (if its text)

fenyvesi commented 6 years ago

May be I am doing it in a wrong way but ip/edit produces a page with 2 columns: Left: file names; right: the content. Nothing happens right clicking on file names.

fenyvesi commented 6 years ago

I try the Alexa integration. Not the IFTTT but the classic Alexa integration. I am afraid I am a bit confused. I thought that the process is:

  1. Define Thing
  2. Define Lambda function.
  3. define Skill
  4. Upload Lambda function (you already prepared).

How can I define a Thing as ESP missing all the software that is available either for Linux or Windows ? OR: Not to define a thing and start with the Skill. I am trying this way.

roberttidey commented 6 years ago

On edit, are you seeing the list of filenames as links (with an underline)? edit If you left click does it change right hand content? Is your browser blocking anything? Maybe clear cache?

For Alexa; yes you define a skill and use the Amazon Lambda service to accept commands from ALexa and forward them on as web requests to the ESP.

Edit: Note right hand side only displays text type files.

fenyvesi commented 6 years ago
  1. If I left click on any file, I can see tho content.

  2. If I move the cursor on the file name in the left list, then it is underlined. If I right click , then nothing happens. I can't decide from your screen shot that the extra menu is whether a pop-up window. I checked and enabled pop-ups, in vain. Firefox 58.02

  3. I managed to start the Skill/Lambda, the ESP got the message. I only find out how to set up the Interaction Model in Skills to get the proper message..

image

fenyvesi commented 6 years ago

I checked in Chrome. It works.

fenyvesi commented 6 years ago

After getting a message from Amazon, the Wifi can't connect. again (The Amazon message is incorrect, the program doesn't find the macro because of incorrect Skill setup.)

I am on manual Wifi because of a fix, forwarded IP.

The debug screen: Set up manual IRBlaster Web Connecting to AP. WiFi connected ip 192.168.0.40:80 mac 18:FE:34:D6:81:19 18FE34D68119 Set up Web update service Set up Web command handlers Set up IR sender Set up filing system SPIFFS file list / - 0 /buttonnames.txt - 772 /dev_lgtv.txt - 723 /favicon.ico - 1150 /index.htm - 783 /dev_yamahaAV.txt - 1096 /dev_philipsDVD.txt - 520 /graphs.js - 3852 /edit.htm - 7887 Buttons:118 Devices:3 Codes: 150 Length:904 Set up complete Get args command received Macro on not found

Wifi connection timed out. Try to relink Set up manual IRBlaster Web Connecting to AP....................

Wifi connection timed out. Try to relink Set up manual IRBlaster Web Connecting to AP.................... .....

roberttidey commented 6 years ago

Sounds like you are close.

Failing to process a command or macro not found should not be having any effect on the wifi connection. Can you confirm you only start getting the wifi issues after processing a command. If so, is it just a failed command that triggers this?

The foreground loop does a routine check every 30 seconds to see if wifi is OK and if not then it tries to set up the wifi connection again.

The log shows that happening but failing to connect again.

Each . is a retry within the wifi set up routine. By default there is 10, but there seems to be more in your log. Have you changed something there? Also after the retries there should be a success failure message but I don't see that.

I normally use the WifiManager method rather than manual which works very well and makes it easier to manage if AP changes. Have you tried that method?

Note that it can be easier to test command processing first without Alexa by using the form when you just browse to the esp IP. You can test macros by putting macro for the device and the macro name as the parameter.

fenyvesi commented 6 years ago

Thank you for taking care my errors.

1. WifiManager/Manual Wifi If you use Wifi Man, how do you forward your port with DHCP given IP? Do you set it in router with MAC address? I'd prefer this method also.

2. The number of Wifi errors is unlimited. I only commented out WM_NAME for manual Wifi.

3. Testing with macros:

The line in the lambda_function.py: link="http://fenyvesi.dyndns.org:20000/ir?auth=0000&device=macro&parameter=" + macro
Shall I try locally with url: local.ip/ir?auth=0000&device=macro&parameter=test1 ?

startall.txt: { "auth":"0000", "macro":"test1", "commands": [ { "device":"yamahaAV", "parameter":"hdmi4", "wait":"5000", "bits":"0", "repeat":"1" }, { "device":"yamahaAV", "parameter":"hdmi1", "wait":"100", "bits":"0", "repeat":"1" } ] }

4. Alexa Skill Yesterday evening I stopped trying the skill setup, I was tired to read the whole documentation. Could you give an example for Intent Schema and Utterances for more devices and commands?

fenyvesi commented 6 years ago

I misunderstood the macro syntax. I realized that the macros are in separated files one by one, the name of the macro doesn't matter, only the file name. So the syntax is: local.ip/ir?auth=0000&device=macro&parameter=startall.txt

fenyvesi commented 6 years ago

The Wifi problem didn't occur again, it can reconnect after a time out.

roberttidey commented 6 years ago

Sounds good. Yes macro is per file with same name. You can leave out the extension.txt in the parameter if you want. The software will try appending .tx itself. If that doesn't work then it just uses the name. So in your case it would try to find startall.txt.txt, and then try startall.txt One can nest macros within macros if required, but it is not normally necessary.

For WifiManager usage and router set up I do

1) On first use or network change, WifiManager brings up its own AP. Connect to this (e.g. on Phone). Browse to 192.168.4.1, select network, and enter password. This will be rembered for future use.

2) Set up Router to assign a fixed IP address to Mac address of IRBlaster.

3) Set up Router to port forward the assigned port number (AP_PORT) to that IP address

I use a dynamic dns service to associate the Router WAN IP to a domain and then use that domain in Alexa / IFTTT references. That way if the WAN IP changes then I only need update the dynamic DNS. My router does that automatically, although it very rarely changes.

fenyvesi commented 6 years ago

Thank you. I use dydns also. I don’t like giving Ip on base of MAC, but this seems to be the only solution.

George

Küldte a Windows 10 Posta

Feladó: roberttidey Elküldve: 2018. február 21., szerda 9:52 Címzett: roberttidey/IRBlasterWeb Másolatot kap: George Fenyvesi; Author Tárgy: Re: [roberttidey/IRBlasterWeb] Missing components (#1)

Sounds good. Yes macro is per file with same name. You can leave out the extension.txt in the parameter if you want. The software will try appending .tx itself. If that doesn't work then it just uses the name. So in your case it would try to find startall.txt.txt, and then try startall.txt One can nest macros within macros if required, but it is not normally necessary. For WifiManager usage and router set up I do

  1. On first use or network change, WifiManager brings up its own AP. Connect to this (e.g. on Phone). Browse to 192.168.4.1, select network, and enter password. This will be rembered for future use.
  2. Set up Router to assign a fixed IP address to Mac address of IRBlaster.
  3. Set up Router to port forward the assigned port number (AP_PORT) to that IP address I use a dynamic dns service to associate the Router WAN IP to a domain and then use that domain in Alexa / IFTTT references. That way if the WAN IP changes then I only need update the dynamic DNS. My router does that automatically, although it very rarely changes. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
roberttidey commented 6 years ago

On Alexa side. There is the Intent file in the git. This is pretty simple and all it does is associate this skill with the lambda via the BLASTER_EFFECT type. YOu should be able to use that unchanged if the lambda is kept the same.

I have added example slot content file to the git. This is just a simple list of utterances to be recognised, So when Alexa hears an utterance after the magic skill word, she looks in this list to see if it is recognised. If so then it is passed to the lamda function. The lamda function strips out any spaces to make a macro name and then calls the IRBlaster with this name as a macro. So "media on" invokes the mediaon macro.

Couple of things. Alexa use numbers. So it must be BBC 1 in the list not BBC ONE. Most words are OK but sometimes one needs to be a bit more phonetic, so Alexa thinks ITV is eye tv

Having said all that I tend to use the IFTTT service most of the time as it works well. It is a bit more painful to set up as one has to set up a separate IFTTT action for each command, but it does mean that simple commands can be called in the IFTTT action rather than using macros for everything.

roberttidey commented 6 years ago

One can hard wire a specific IP into the code of the blaster to avoid the Mac assign in the router but you need to be sure it is outside of the normal dhcp allocation in the router. Currently the code only uses this for the non WifiManager case.

roberttidey commented 6 years ago

I have added code so the static IP should work for the WifiManager case as well.

fenyvesi commented 6 years ago

Thank you for detailed answer. I will check the Github for the examples.

Related to IFTTT. I try to use minimal number of software services because if one of them misses (for example stopped Google and Amazon services I already experienced) you are in a trouble and can start from scratch again. First I tried the whole process with local software imitated WeMo switches, but Amazon switched off this possibility for the new Echoes, they work only with skills. That's why I have to define the skills....

Static address: I have already separated the DHCP interval to 200-255, so I can give a fix IP below this range.

Thank you once more.

fenyvesi commented 6 years ago

The new static IP works. Thanks.

fenyvesi commented 6 years ago

Do you think that I can capture SonyAV Receiver codes with your python program? They seem to use a different coding (SIRC) ?

roberttidey commented 6 years ago

This looks like quite a good description of SIRC protocol https://www.sbprojects.net/knowledge/ir/sirc.php

Although the python program won't handle that, it should be pretty easy to add support for that alongside the nec,rc5, and rc6 variants. I can check that out later.

fenyvesi commented 6 years ago

OK. I will doing it.

roberttidey commented 6 years ago

OK. I won't have a chance to look at it until later this evening.

If you want to have a go that's great. One needs to put an extra test in get_ir like elif codetype == 'sirc': return get_sirc(check=chk)

and then add a routine get_sirc which can be largely based on the get_nec one as the protocol is similar,

fenyvesi commented 6 years ago

I already done. I extended the program with a new get_sirc() routine. I haven’t tried it yet because the sony is 40kHz and I don’t have this receiver at home.

I prepared a working skill also, I will send it tomorrow.

Küldte a Windows 10 Posta

Feladó: roberttidey Elküldve: 2018. február 22., csütörtök 11:40 Címzett: roberttidey/IRBlasterWeb Másolatot kap: George Fenyvesi; Author Tárgy: Re: [roberttidey/IRBlasterWeb] Missing components (#1)

OK. I won't have a chance to look at it until later this evening. If you want to have a go that's great. One needs to put an extra test in get_ir like elif codetype == 'sirc': return get_sirc(check=chk) and then add a routine get_sirc which can be largely based on the get_nec one as the protocol is similar, — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

fenyvesi commented 6 years ago

The program wasn't sent. This is really a rar file, but can't be uploaded. rxir.zip

roberttidey commented 6 years ago

Great stuff. I'll update repository with that.

I use the TSOP type receivers. They are not super selective on the modulation frequency so any one will work OK particularly if the remote is closer than normal.

fenyvesi commented 6 years ago

I defined the skill, this is a working but preliminary version.

skill. xml: The skill has to Slots: device and mode. The possible values of devices (Device_effect) are the same as the device names (1st line) in dev_xxx.txt device definition files in the ESP. If I want to use a macro, then the device="scene". The mode defines what to do with the device. In simplest form it is equal to the name of the button in the dev_xxx.txt definition file. In case of macro (device=="scene"), the mode is the name of the macro file in ESP. Invocation: "remote" The only task is to redefine the button names in device files.

lambda function: It remained almost the same you made, only extended with the device, mode and scene parameters.

alexa_skill.zip

roberttidey commented 6 years ago

Interesting. I will check out the extended skill.

On the capture tool I corrected syntax error on line 105 if check and not ( len(code) == 12 or len(code) == 15 or len(code) == 20) :

and replaced git version existing functions will stillwork. It can be updated if it needs any changes once sirc is tested.

fenyvesi commented 6 years ago

This is my Python knowledge....

fenyvesi commented 6 years ago

One more question:

How OTA works? I can't see.

roberttidey commented 6 years ago

In the Arduino IDE Export compiled binary. This will produce a bin file of the compiled sketch.

Browse to IP/firmware of the IRBlaster. This will prompt for user / password of OTA as set up in the sketch (update_username, update_password). This will then bring up a browse for binary, select the exported binary and press update button. The file will update in a few seconds, flash the new firmware and reboot.

Note it is good to check the new sketch at least functions going round the loop and therefore OTA will still function after updating. If the loop has some fatal run time error then the OTA won't work and you then have to revert to serial upload to get it working again.

fenyvesi commented 6 years ago

Thank you.