Categories
Uncategorized

Facebook IP Ranges

(as at 2020.08.03)

Sometimes you just need a list of addresses to block to stop this plague getting in to your networks.

The address ranges can be found using the following command:

whois -h whois.radb.net -- '-i origin AS32934' | grep ^route

route:      69.63.176.0/20
route:      66.220.144.0/20
route:      66.220.144.0/21
route:      69.63.184.0/21
route:      69.63.176.0/21
route:      74.119.76.0/22
route:      69.171.255.0/24
route:      173.252.64.0/18
route:      69.171.224.0/19
route:      69.171.224.0/20
route:      103.4.96.0/22
route:      69.63.176.0/24
route:      173.252.64.0/19
route:      173.252.70.0/24
route:      31.13.64.0/18
route:      31.13.24.0/21
route:      66.220.152.0/21
route:      66.220.159.0/24
route:      69.171.239.0/24
route:      69.171.240.0/20
route:      31.13.64.0/19
route:      31.13.64.0/24
route:      31.13.65.0/24
route:      31.13.67.0/24
route:      31.13.68.0/24
route:      31.13.69.0/24
route:      31.13.70.0/24
route:      31.13.71.0/24
route:      31.13.72.0/24
route:      31.13.73.0/24
route:      31.13.74.0/24
route:      31.13.75.0/24
route:      31.13.76.0/24
route:      31.13.77.0/24
route:      31.13.96.0/19
route:      31.13.66.0/24
route:      173.252.96.0/19
route:      69.63.178.0/24
route:      31.13.78.0/24
route:      31.13.79.0/24
route:      31.13.80.0/24
route:      31.13.82.0/24
route:      31.13.83.0/24
route:      31.13.84.0/24
route:      31.13.85.0/24
route:      31.13.86.0/24
route:      31.13.87.0/24
route:      31.13.88.0/24
route:      31.13.89.0/24
route:      31.13.90.0/24
route:      31.13.91.0/24
route:      31.13.92.0/24
route:      31.13.93.0/24
route:      31.13.94.0/24
route:      31.13.95.0/24
route:      69.171.253.0/24
route:      69.63.186.0/24
route:      31.13.81.0/24
route:      179.60.192.0/22
route:      179.60.192.0/24
route:      179.60.193.0/24
route:      179.60.194.0/24
route:      179.60.195.0/24
route:      185.60.216.0/22
route:      45.64.40.0/22
route:      185.60.216.0/24
route:      185.60.217.0/24
route:      185.60.218.0/24
route:      185.60.219.0/24
route:      129.134.0.0/16
route:      157.240.0.0/16
route:      157.240.8.0/24
route:      157.240.0.0/24
route:      157.240.1.0/24
route:      157.240.2.0/24
route:      157.240.3.0/24
route:      157.240.4.0/24
route:      157.240.5.0/24
route:      157.240.6.0/24
route:      157.240.7.0/24
route:      157.240.9.0/24
route:      157.240.10.0/24
route:      157.240.16.0/24
route:      157.240.19.0/24
route:      157.240.11.0/24
route:      157.240.12.0/24
route:      157.240.13.0/24
route:      157.240.14.0/24
route:      157.240.15.0/24
route:      157.240.17.0/24
route:      157.240.18.0/24
route:      157.240.20.0/24
route:      157.240.21.0/24
route:      157.240.22.0/24
route:      157.240.23.0/24
route:      157.240.0.0/17
route:      69.171.250.0/24
route:      157.240.24.0/24
route:      157.240.25.0/24
route:      199.201.64.0/24
route:      199.201.65.0/24
route:      199.201.64.0/22
route:      204.15.20.0/22
route:      157.240.192.0/24
route:      157.240.198.0/24
route:      129.134.0.0/17
route:      102.132.96.0/20
route:      102.132.96.0/24
route:      102.132.97.0/24
route:      157.240.26.0/24
route:      157.240.27.0/24
route:      157.240.28.0/24
route:      157.240.29.0/24
route:      157.240.30.0/24
route:      129.134.28.0/24
route:      129.134.29.0/24
route:      157.240.208.0/24
route:      157.240.193.0/24
route:      157.240.194.0/24
route:      157.240.195.0/24
route:      157.240.197.0/24
route:      157.240.196.0/24
route:      157.240.200.0/24
route:      157.240.201.0/24
route:      157.240.203.0/24
route:      157.240.204.0/24
route:      157.240.205.0/24
route:      157.240.206.0/24
route:      157.240.207.0/24
route:      157.240.209.0/24
route:      157.240.210.0/24
route:      157.240.211.0/24
route:      157.240.212.0/24
route:      157.240.213.0/24
route:      157.240.214.0/24
route:      157.240.215.0/24
route:      157.240.216.0/24
route:      157.240.222.0/24
route:      129.134.30.0/24
route:      129.134.31.0/24
route:      129.134.30.0/23
route:      129.134.25.0/24
route:      129.134.26.0/24
route:      129.134.27.0/24
route:      102.132.98.0/24
route:      102.132.99.0/24
route:      102.132.100.0/24
route:      102.132.101.0/24
route:      102.132.102.0/24
route:      102.132.103.0/24
route:      102.132.104.0/24
route:      102.132.105.0/24
route:      102.132.106.0/24
route:      102.132.107.0/24
route:      102.132.108.0/24
route:      102.132.109.0/24
route:      102.132.110.0/24
route:      102.132.111.0/24
route:      129.134.64.0/24
route:      129.134.65.0/24
route:      129.134.66.0/24
route:      129.134.67.0/24
route:      157.240.219.0/24
route:      157.240.202.0/24
route:      157.240.217.0/24
route:      157.240.218.0/24
route:      157.240.199.0/24
route:      129.134.127.0/24
route:      157.240.223.0/24
route:      157.240.192.0/18
route:      157.240.221.0/24
route:      157.240.220.0/24
route:      173.252.88.0/21
route:          185.89.219.0/24
route:          185.89.218.0/24
route:          185.89.218.0/23
route:          185.89.216.0/22
route:          147.75.208.0/20
route:      204.15.20.0/22
route:      69.63.176.0/20
route:      69.63.176.0/21
route:      69.63.184.0/21
route:      66.220.144.0/20
route:          69.63.176.0/20
route6:     2620:0:1c00::/40
route6:     2a03:2880::/32
route6:     2a03:2880:fffe::/48
route6:     2a03:2880:ffff::/48
route6:     2620:0:1cff::/48
route6:     2a03:2880:f000::/48
route6:     2a03:2880:f001::/48
route6:     2a03:2880:f002::/48
route6:     2a03:2880:f003::/48
route6:     2a03:2880:f004::/48
route6:     2a03:2880:f005::/48
route6:     2a03:2880:f006::/48
route6:     2a03:2880:f007::/48
route6:     2a03:2880:f008::/48
route6:     2a03:2880:f009::/48
route6:     2a03:2880:f00a::/48
route6:     2a03:2880:f00b::/48
route6:     2a03:2880:f00c::/48
route6:     2a03:2880:f00d::/48
route6:     2a03:2880:f00e::/48
route6:     2a03:2880:f00f::/48
route6:     2a03:2880:f010::/48
route6:     2a03:2880:f011::/48
route6:     2a03:2880:f012::/48
route6:     2a03:2880:f013::/48
route6:     2a03:2880:f014::/48
route6:     2a03:2880:f015::/48
route6:     2a03:2880:f016::/48
route6:     2a03:2880:f017::/48
route6:     2a03:2880:f018::/48
route6:     2a03:2880:f019::/48
route6:     2a03:2880:f01a::/48
route6:     2a03:2880:f01b::/48
route6:     2a03:2880:f01c::/48
route6:     2a03:2880:f01d::/48
route6:     2a03:2880:f01e::/48
route6:     2a03:2880:f01f::/48
route6:     2a03:2880:1000::/36
route6:     2a03:2880:2000::/36
route6:     2a03:2880:3000::/36
route6:     2a03:2880:4000::/36
route6:     2a03:2880:5000::/36
route6:     2a03:2880:6000::/36
route6:     2a03:2880:7000::/36
route6:     2a03:2880:f020::/48
route6:     2a03:2880:f021::/48
route6:     2a03:2880:f022::/48
route6:     2a03:2880:f023::/48
route6:     2a03:2880:f024::/48
route6:     2a03:2880:f025::/48
route6:     2a03:2880:f026::/48
route6:     2a03:2880:f027::/48
route6:     2a03:2880:f028::/48
route6:     2a03:2880:f029::/48
route6:     2a03:2880:f02b::/48
route6:     2a03:2880:f02c::/48
route6:     2a03:2880:f02d::/48
route6:     2a03:2880:f02e::/48
route6:     2a03:2880:f02f::/48
route6:     2a03:2880:f030::/48
route6:     2a03:2880:f031::/48
route6:     2a03:2880:f032::/48
route6:     2a03:2880:f033::/48
route6:     2a03:2880:f034::/48
route6:     2a03:2880:f035::/48
route6:     2a03:2880:f036::/48
route6:     2a03:2880:f037::/48
route6:     2a03:2880:f038::/48
route6:     2a03:2880:f039::/48
route6:     2a03:2880:f03a::/48
route6:     2a03:2880:f03b::/48
route6:     2a03:2880:f03c::/48
route6:     2a03:2880:f03d::/48
route6:     2a03:2880:f03e::/48
route6:     2a03:2880:f03f::/48
route6:     2401:db00::/32
route6:     2a03:2880::/36
route6:     2803:6080::/32
route6:     2a03:2880:f100::/48
route6:     2a03:2880:f200::/48
route6:     2a03:2880:f101::/48
route6:     2a03:2880:f201::/48
route6:     2a03:2880:f102::/48
route6:     2a03:2880:f202::/48
route6:     2a03:2880:f103::/48
route6:     2a03:2880:f203::/48
route6:     2a03:2880:f104::/48
route6:     2a03:2880:f204::/48
route6:     2a03:2880:f107::/48
route6:     2a03:2880:f207::/48
route6:     2a03:2880:f108::/48
route6:     2a03:2880:f208::/48
route6:     2a03:2880:f109::/48
route6:     2a03:2880:f209::/48
route6:     2a03:2880:f10a::/48
route6:     2a03:2880:f20a::/48
route6:     2a03:2880:f10b::/48
route6:     2a03:2880:f20b::/48
route6:     2a03:2880:f10d::/48
route6:     2a03:2880:f20d::/48
route6:     2a03:2880:f10e::/48
route6:     2a03:2880:f20e::/48
route6:     2a03:2880:f10f::/48
route6:     2a03:2880:f20f::/48
route6:     2a03:2880:f110::/48
route6:     2a03:2880:f210::/48
route6:     2a03:2880:f111::/48
route6:     2a03:2880:f211::/48
route6:     2a03:2880:f112::/48
route6:     2a03:2880:f212::/48
route6:     2a03:2880:f114::/48
route6:     2a03:2880:f214::/48
route6:     2a03:2880:f115::/48
route6:     2a03:2880:f215::/48
route6:     2a03:2880:f116::/48
route6:     2a03:2880:f216::/48
route6:     2a03:2880:f117::/48
route6:     2a03:2880:f217::/48
route6:     2a03:2880:f118::/48
route6:     2a03:2880:f218::/48
route6:     2a03:2880:f119::/48
route6:     2a03:2880:f219::/48
route6:     2a03:2880:f11a::/48
route6:     2a03:2880:f21a::/48
route6:     2a03:2880:f11f::/48
route6:     2a03:2880:f21f::/48
route6:     2a03:2880:f121::/48
route6:     2a03:2880:f221::/48
route6:     2a03:2880:f122::/48
route6:     2a03:2880:f222::/48
route6:     2a03:2880:f123::/48
route6:     2a03:2880:f223::/48
route6:     2a03:2880:f10c::/48
route6:     2a03:2880:f20c::/48
route6:     2a03:2880:f126::/48
route6:     2a03:2880:f226::/48
route6:     2a03:2880:f105::/48
route6:     2a03:2880:f205::/48
route6:     2a03:2880:f125::/48
route6:     2a03:2880:f225::/48
route6:     2a03:2880:f106::/48
route6:     2a03:2880:f206::/48
route6:     2a03:2880:f11b::/48
route6:     2a03:2880:f21b::/48
route6:     2a03:2880:f113::/48
route6:     2a03:2880:f213::/48
route6:     2a03:2880:f11c::/48
route6:     2a03:2880:f21c::/48
route6:     2a03:2880:f128::/48
route6:     2a03:2880:f228::/48
route6:     2a03:2880:f02a::/48
route6:     2a03:2880:f12a::/48
route6:     2a03:2880:f22a::/48
route6:     2a03:2880:f12f::/48
route6:     2a03:2880:f22f::/48
route6:     2a03:2880:f11d::/48
route6:     2a03:2880:f11e::/48
route6:     2a03:2880:f120::/48
route6:     2a03:2880:f124::/48
route6:     2a03:2880:f127::/48
route6:     2a03:2880:f129::/48
route6:     2a03:2880:f12b::/48
route6:     2a03:2880:f12c::/48
route6:     2a03:2880:f12d::/48
route6:     2a03:2880:f12e::/48
route6:     2a03:2880:f130::/48
route6:     2a03:2880:f131::/48
route6:     2a03:2880:f132::/48
route6:     2a03:2880:f133::/48
route6:     2a03:2880:f134::/48
route6:     2a03:2880:f135::/48
route6:     2a03:2880:f136::/48
route6:     2a03:2880:f137::/48
route6:     2a03:2880:f138::/48
route6:     2a03:2880:f139::/48
route6:     2a03:2880:f13a::/48
route6:     2a03:2880:f13b::/48
route6:     2a03:2880:f13c::/48
route6:     2a03:2880:f13d::/48
route6:     2a03:2880:f13e::/48
route6:     2a03:2880:f13f::/48
route6:     2a03:2880:f21d::/48
route6:     2a03:2880:f21e::/48
route6:     2a03:2880:f220::/48
route6:     2a03:2880:f224::/48
route6:     2a03:2880:f227::/48
route6:     2a03:2880:f229::/48
route6:     2a03:2880:f22b::/48
route6:     2a03:2880:f22c::/48
route6:     2a03:2880:f22d::/48
route6:     2a03:2880:f22e::/48
route6:     2a03:2880:f230::/48
route6:     2a03:2880:f231::/48
route6:     2a03:2880:f232::/48
route6:     2a03:2880:f233::/48
route6:     2a03:2880:f234::/48
route6:     2a03:2880:f235::/48
route6:     2a03:2880:f236::/48
route6:     2a03:2880:f237::/48
route6:     2a03:2880:f238::/48
route6:     2a03:2880:f239::/48
route6:     2a03:2880:f23a::/48
route6:     2a03:2880:f23b::/48
route6:     2a03:2880:f23c::/48
route6:     2a03:2880:f23d::/48
route6:     2a03:2880:f23e::/48
route6:     2a03:2880:f23f::/48
route6:     2a03:2880:f0ff::/48
route6:     2a03:2880:f1ff::/48
route6:     2a03:2880:f2ff::/48
route6:     2a03:2887:ff34::/48
route6:     2a03:2880:f044::/48
route6:     2a03:2880:f144::/48
route6:     2a03:2880:f244::/48
route6:     2a03:2880:f042::/48
route6:     2a03:2880:f043::/48
route6:     2a03:2880:f045::/48
route6:     2a03:2880:f046::/48
route6:     2a03:2880:f047::/48
route6:     2a03:2880:f048::/48
route6:     2a03:2880:f049::/48
route6:     2a03:2880:f04a::/48
route6:     2a03:2880:f04c::/48
route6:     2a03:2880:f04b::/48
route6:     2a03:2880:f04d::/48
route6:     2a03:2880:f259::/48
route6:     2a03:2880:f258::/48
route6:     2a03:2880:f257::/48
route6:     2a03:2880:f256::/48
route6:     2a03:2880:f255::/48
route6:     2a03:2880:f254::/48
route6:     2a03:2880:f253::/48
route6:     2a03:2880:f252::/48
route6:     2a03:2880:f251::/48
route6:     2a03:2880:f250::/48
route6:     2a03:2880:f24f::/48
route6:     2a03:2880:f24d::/48
route6:     2a03:2880:f24e::/48
route6:     2a03:2880:f24c::/48
route6:     2a03:2880:f24b::/48
route6:     2a03:2880:f24a::/48
route6:     2a03:2880:f249::/48
route6:     2a03:2880:f248::/48
route6:     2a03:2880:f247::/48
route6:     2a03:2880:f246::/48
route6:     2a03:2880:f245::/48
route6:     2a03:2880:f243::/48
route6:     2a03:2880:f242::/48
route6:     2a03:2880:f241::/48
route6:     2a03:2880:f240::/48
route6:     2a03:2880:f159::/48
route6:     2a03:2880:f158::/48
route6:     2a03:2880:f157::/48
route6:     2a03:2880:f156::/48
route6:     2a03:2880:f155::/48
route6:     2a03:2880:f154::/48
route6:     2a03:2880:f153::/48
route6:     2a03:2880:f152::/48
route6:     2a03:2880:f151::/48
route6:     2a03:2880:f150::/48
route6:     2a03:2880:f14f::/48
route6:     2a03:2880:f14e::/48
route6:     2a03:2880:f14d::/48
route6:     2a03:2880:f14c::/48
route6:     2a03:2880:f14b::/48
route6:     2a03:2880:f14a::/48
route6:     2a03:2880:f149::/48
route6:     2a03:2880:f148::/48
route6:     2a03:2880:f147::/48
route6:     2a03:2880:f146::/48
route6:     2a03:2880:f145::/48
route6:     2a03:2880:f143::/48
route6:     2a03:2880:f142::/48
route6:     2a03:2880:f141::/48
route6:     2a03:2880:f140::/48
route6:     2a03:2880:f059::/48
route6:     2a03:2880:f058::/48
route6:     2a03:2880:f057::/48
route6:     2a03:2880:f056::/48
route6:     2a03:2880:f055::/48
route6:     2a03:2880:f054::/48
route6:     2a03:2880:f053::/48
route6:     2a03:2880:f052::/48
route6:     2a03:2880:f051::/48
route6:     2a03:2880:f050::/48
route6:     2a03:2880:f04f::/48
route6:     2a03:2880:f04e::/48
route6:     2a03:2880:ff0b::/48
route6:     2a03:2880:ff0c::/48
route6:     2a03:2880:f040::/48
route6:     2a03:2880:f041::/48
route6:     2a03:2880:f0fc::/48
route6:     2a03:2880:f0fd::/48
route6:     2a03:2880:f0fc::/47
route6:     2a03:2880:f1fc::/48
route6:     2a03:2880:f1fd::/48
route6:     2a03:2880:f1fc::/47
route6:     2a03:2880:ff08::/48
route6:     2a03:2880:ff09::/48
route6:     2a03:2880:ff0a::/48
route6:     2a03:2880:f05b:0000:0000:0000:0000:0000/56
route6:     2a03:2880:f15b:0000:0000:0000:0000:0000/56
route6:     2a03:2880:f25b:0000:0000:0000:0000:0000/56
route6:     2a03:2880:f05d::/56
route6:     2a03:2880:f15d::/56
route6:     2a03:2880:f25d::/56
route6:     2a03:2880:f05f:0000:0000:0000:0000:0000/56
route6:     2a03:2880:f15f:0000:0000:0000:0000:0000/56
route6:     2a03:2880:f25f:0000:0000:0000:0000:0000/56
route6:     2a03:2880:f05e::/48
route6:     2a03:2880:f15e::/48
route6:     2a03:2880:f25e::/48
route6:     2a03:2880:f060::/56
route6:     2a03:2880:f160::/56
route6:     2a03:2880:f260::/56
route6:     2620:0:1cfa::/48
route6:     2a03:2880:f05b::/48
route6:     2a03:2880:f05a::/48
route6:     2a03:2880:f25a::/48
route6:     2a03:2880:f15c::/48
route6:     2a03:2880:f000::/36
route6:     2a03:2880:f05d::/48
route6:     2a03:2880:f25c::/48
route6:     2a03:2880:f05c::/48
route6:     2a03:2880:f260::/48
route6:     2a03:2880:f060::/48
route6:     2a03:2880:f160::/48
route6:     2a03:2880:f05f::/48
route6:     2a03:2880:f15d::/48
route6:     2a03:2880:f25b::/48
route6:     2a03:2880:f25d::/48
route6:     2a03:2880:f25f::/48
route6:     2a03:2880:f15b::/48
route6:     2a03:2880:f15a::/48
route6:     2a03:2880:f161::/48
route6:     2a03:2880:f15f::/48
route6:     2a03:2880:f061::/48
route6:     2a03:2880:f261::/48
route6:     2a03:2881::/32
route6:     2a03:2881::/48
route6:     2a03:2881:1::/48
route6:     2a03:2881:2::/48
route6:     2a03:2881:3::/48
route6:     2a03:2880:f162::/48
route6:     2a03:2880:f062::/48
route6:     2a03:2880:f262::/48
route6:         2a03:83e0::/32
Categories
Uncategorized

Behringer BCF2000 Power Cycling

My Behringer BCF2000 control surface developed some faults recently. In particular, it appeared to be resetting constantly (as if I was turning power on and off).

With some trepidation, I opened the chassis and discovered that two 1000uF 16V electrolytic capacitors in the power supply had fallen victim to the capacitor plague. I replaced these with a couple of 1500uF 16V electrolytics that I had on hand, and everything was well again.

Just remember, the plague can affect the power supply of any electronic device!

(originally published 2013.11.23)

Categories
Uncategorized

Vietnamese Language Lessons

The Voice of Vietnam radio service provides 38 lessons for English speakers to learn Vietnamese. These used to be available for download in RealAudio format, but the website has recently [note: this was circa 2006 :-)] been updated to a format that cannot be accessed on any of my systems … I had some of the files, but I could no longer find the downloadable versions online. I eventually discovered the files I was missing through some detective work in Google’s cache and the Wayback Machine. Also, RealAudio files won’t play on my iPod. So, here are the lessons in their original RealAudio files, here are the lessons as MP3 files (there is also an archive of all the lessons). Please don’t link to these files without informing me. This site can’t handle the bandwidth. Also, I don’t own the copyright in these files, that clearly belongs to VOV.

(originally published 2007.02.15)

Categories
Projects

Controlling a Monoprice 4×4 True Matrix HDMI switch using IR, ESP8266 and OSC

I used a Lolin D1 Mini and their IR shield.

D1 Mini

Details: https://www.wemos.cc/en/latest/d1/d1_mini.html

To buy: https://www.aliexpress.com/item/32529101036.html

D1 Mini IR Controller Shield

Details: https://www.wemos.cc/en/latest/d1_mini_shiled/ir.html

To buy: https://www.aliexpress.com/item/32891173618.html

You’ll need the ESP8266 specific version of the IRRemote library:

https://github.com/crankyoldgit/IRremoteESP8266

And I use the CNMAT OSC library:

https://github.com/CNMAT/OSC

/*------------------------------------------------------

	OSC to IR interface for 
	Monoprice Blackbird 4K Pro 4X4 True Matrix HDMI Powered Switch with EDID and RS232 Control

	/matrix   first integer variable is input channel, second is output channel
	/led  sets onboard LED (0 = off, 1 = on)
	
----------------------------------------------------- */

#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <OSCBundle.h>
#include <OSCData.h>

#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>

const uint16_t kIrLed = 0;  // ESP8266 GPIO pin to use. Recommended: 4 (D2).

IRsend irsend(kIrLed);  // Set the GPIO to be used to sending the message.

char ssid[] = "**network**";          			// your network SSID (name)
char pass[] = "**password**";     					// your network password

// A UDP instance to let us send and receive packets over UDP
WiFiUDP Udp;
const IPAddress outIp(10,40,10,105);        // remote IP (not needed for receive)
const unsigned int outPort = 9999;          // remote port (not needed for receive)
const unsigned int localPort = 8888;        // local port to listen for UDP packets (here's where we send the packets)


OSCErrorCode error;
unsigned int ledState = LOW;              	// LOW means led is *on*
unsigned int inChannel = 0;
unsigned int outChannel = 0;

#ifndef BUILTIN_LED
#ifdef LED_BUILTIN
#define BUILTIN_LED LED_BUILTIN
#else
#define BUILTIN_LED 13
#endif
#endif

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);
  digitalWrite(BUILTIN_LED, ledState);    // turn *on* led

  irsend.begin();

  Serial.begin(115200);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, pass);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");

  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  Serial.println("Starting UDP");
  Udp.begin(localPort);
  Serial.print("Local port: ");
#ifdef ESP32
  Serial.println(localPort);
#else
  Serial.println(Udp.localPort());
#endif

}


void led(OSCMessage &msg) {
  ledState = msg.getInt(0);
  digitalWrite(BUILTIN_LED, ledState);
  Serial.print("/led: ");
  Serial.println(ledState);
}

void switchmatrix(OSCMessage &msg) {
  inChannel = msg.getInt(0);
  outChannel = msg.getInt(1);
  
  // this bit is just for debugging
  // it prints the command neatly to the serial monitor
  
  Serial.print("/matrix/");
  Serial.print(inChannel);
  Serial.print("/");
  Serial.println(outChannel);
  
  switch (inChannel) {
  case 1:
    switch (outChannel) {
      case 1:
        irsend.sendNEC(0xFF906F);
        break;
      case 2:
        irsend.sendNEC(0xFFB847);
        break;
      case 3:
        irsend.sendNEC(0xFFF807);
        break;
      case 4:
        irsend.sendNEC(0xFFB04F);
        break;
      default:
        break;
      }
    break;
  case 2:
    switch (outChannel) {
      case 1:
        irsend.sendNEC(0xFFE817);
        break;
      case 2:
        irsend.sendNEC(0xFF48B7);
        break;
      case 3:
        irsend.sendNEC(0xFF9A65);
        break;
      case 4:
        irsend.sendNEC(0xFF10EF);
        break;
      default:
        break;
      }
    break;
  case 3:
    switch (outChannel) {
      case 1:
        irsend.sendNEC(0xFFE817);
        break;
      case 2:
        irsend.sendNEC(0xFFB847);
        break;
      case 3:
        irsend.sendNEC(0xFFF807);
        break;
      case 4:
        irsend.sendNEC(0xFFB04F);
        break;
      default:
        break;
      }
    break;
  case 4:
    switch (outChannel) {
      case 1:
        irsend.sendNEC(0xFFE817);
        break;
      case 2:
        irsend.sendNEC(0xFFB847);
        break;
      case 3:
        irsend.sendNEC(0xFFF807);
        break;
      case 4:
        irsend.sendNEC(0xFFB04F);
        break;
      default:
        break;
      }
    break;
  default:
    break;
  }
}

void loop() {
  // Serial.println("loop");
  OSCMessage msg;
  int size = Udp.parsePacket();

  if (size > 0) {
    while (size--) {
      msg.fill(Udp.read());
    }
    if (!msg.hasError()) {
      //Serial.println("msg received");
      msg.dispatch("/led", led);
      msg.dispatch("/matrix", switchmatrix);

    } else {
      error = msg.getError();
      Serial.print("error: ");
      Serial.println(error);
    }
  }
}