This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'multi_json' | |
require 'uri' | |
require 'base64' | |
require 'openssl' | |
require 'cgi' | |
require 'net/http' | |
require 'time' | |
module AzureNotificationHub | |
ENDPOINT = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commands = [ | |
'HUANTENG_BULB_ON'.freeze, 'HUANTENG_BULB_OFF'.freeze, 'HUANTENG_BULB_SWITCH'.freeze, | |
'HUANTENG_BULB_TUNE'.freeze, 'HUANTENG_BULB_BRIGHTNESS'.freeze, 'HUANTENG_BULB_HUE'.freeze, | |
'HUANTENG_BULB_SLOWLYOFF'.freeze, 'HUANTENG_BULB_SLOWLYON'.freeze, 'HUANTENG_WALLSWITCH_ON'.freeze, | |
'HUANTENG_WALLSWITCH_OFF'.freeze, 'HUANTENG_CURTAIN_OPEN'.freeze, 'HUANTENG_CURTAIN_CLOSE'.freeze, | |
'HUANTENG_CURTAIN_STATUS'.freeze, 'HUANTENG_CURTAIN_STOP'.freeze, 'BROADLINK_SPMINI_ON'.freeze, | |
'BROADLINK_SPMINI_OFF'.freeze, 'BROADLINK_RM2_SEND'.freeze, 'BROADLINK_SP2_ON'.freeze, 'BROADLINK_SP2_OFF'.freeze, | |
'MAGI4U_NOTIFICATION_SEND'.freeze, 'ANFANG_NOTIFICATION_SEND'.freeze, 'MAGI4U_SCENE_SWITCH'.freeze, | |
'HAIER_REFRIGERATOR_OPERATION'.freeze, 'HAIER_AIRCONDITIONER_OPERATION'.freeze, 'HAIER_WATERHEATER_OPERATION'.freeze, | |
'HONGYAN_10A_ON'.freeze, 'HONGYAN_10A_OFF'.freeze, 'HONGYAN_16A_ON'.freeze, 'HONGYAN_16A_OFF'.freeze, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen_redis_proto(*cmd) | |
proto = "" | |
proto << "*"+cmd.length.to_s+"\r\n" | |
cmd.each{|arg| | |
proto << "$"+arg.to_s.bytesize.to_s+"\r\n" | |
proto << arg.to_s+"\r\n" | |
} | |
proto | |
end |