Swremote protocol documented ?

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
bcoggs
Member
Posts: 18
Joined: Mon Dec 07, 2009 12:23 pm

Swremote protocol documented ?

Post by bcoggs »

Is the protocol that swremote and housebot speak documented ?

I am looking at developing my own UI using chumbies for the displays.

I've been looking at the protocol using Ethereal. Before I start reverse-engineering it, I wanted to put the question out.
Timoh
Advanced Member
Posts: 260
Joined: Thu Feb 02, 2006 12:56 pm
Location: Montreal - Canada

Re: Swremote protocol documented ?

Post by Timoh »

The protocol is not documented. And it is binary. :(

If you wait a month or two or ???, my project may be able to help you out. In addition to full rendering in a browser, my web client plugin will also allow you to obtain the xml for theme that defines how the swremote is setup, and in addition will allow you to query/set properties & tasks via xml over http.

It is actually the piece I am working on right now, albeit somewhat slowly.

Tim
bcoggs
Member
Posts: 18
Joined: Mon Dec 07, 2009 12:23 pm

Swremote protocol partially decoded (for chumby project)

Post by bcoggs »

I spent a little bit of time analyzing the swremote<>housebot protocol. It is TCP port 5015.

I've written the following perl script which successfully connects with the housebot server and sends a button push.

My goal is to implement a swremote client on a Chumby.

If anyone cares to go further with this here's the script. It should be possible to fully decode the protocol. Or maybe CeBotics will see the value in publishing the definition.
..c

Code: Select all

#
# Speak to housebot server using swremote protocol
# works under activestate perl under windows xp
#
# 2011.05.18   
# Bob Coggeshall
# re_housebot (at) cogwheel.com


my $Host = "127.0.0.1"; # put ip address of your housebot host here if it is running on another machine

use IO::Socket; 
my $sock = new IO::Socket::INET ( 
  PeerAddr => $Host,
  PeerPort => '5015',
  Proto => 'tcp', 
); 
die "Could not create socket: $!\n" unless $sock; 


# The sequence '76 67 61 70 6f 72 74 32' is the ascii string 'vgaport2' 
# which is the name of my swremote definition. replace it with yours
my $hexdump = <<EOF;
e9 03 00 00 3e 00 00 00 01 00 
06 00 00 00 02 00 07 00 00 00 33 2e 33 30 2e 30 
32 02 00 08 00 00 00 
76 67 61 70 6f 72 74 32 
02
00 09 00 00 00 4f 43 4f 47 57 48 45 45 4c 02 00
00 00 00 00                                   
EOF


@B = split "\n", $hexdump; # get rid of newlines
$b = join '',@B; # make it all one var
$b=~s/ //g; # remove spaces
print "[$b]\n";

$data = pack('H*',$b); # make it a binary packet

$sock->send($data);

# This is a button push. I was able to see it getting acted upon in the housebot logs
# obviously there is a command opcode, and a button ID in here somewhere..
my $hexdump = <<EOF;
ee 03 00 00 0e 00 00 00 01 00
0b 00 00 00                 
EOF


@B = split "\n", $hexdump;
$b = join '',@B;
$b=~s/ //g;

print "[$b]\n";


$data = pack('H*',$b);

$sock->send($data);

close($sock)

roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Swremote protocol documented ?

Post by roussell »

Nice Work Bob! I've half-heartedly attempted this through the years but always gave up before I made any real progress. At some point it just became easier to use the external connector to do what I wanted. Now that all of my swremotes are HTML5/javascript/CSS3 (using mostly Sencha Touch) I haven't though about it in a while.

I know that several have asked Scott though the years to publish the protocol but thus far he hasn't - so to beat the dead horse some more:

How about it Scott? Care to publish the unpublished? Even if it's ugly it would beat reverse engineering right?

TIA,
Terry
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Swremote protocol documented ?

Post by ScottBot »

I don't think It's even documented in the code. Here's the message ID's and the class constructors for the messages. Maybe that might help a little, but you'll probably still have a lot of figuring out to do.

Code: Select all

	//
	// Loader message ID's start here
	midLoaderConnect,
	midLoaderDisconnect,

	//
	// Client message ID's start here
	midClientIDStart = 1000,			
	midClientLogin,
	midClientLogout,
	midClientSubscribeToProperty,
	midClientUnsubscribeFromProperty,
	midClientPropertyChangeRequest,
	midClientTaskExecuteRequest,
	midClientGetPropertyValueRequest,
	midClientGetValidPropertyValuesRequest,
	midClientFileUpdateCheckRequest,
	midClientChangeModeState,
	midClientGetModeStateRequest,
	midClientSleep,
	midClientDirectoryListingRequest,
	midClientAddValueToList,
	midClientChangeValueInList,
	midClientAcknowledgment,
	midClientInitialized,
	midClientGetFileRequest,
	midClientMouseAction,
	midClientBulkUnsubscribeFromProperties,
	midClientBulkSubscribeToProperties,
	
	//
	// Server message ID's start here
	midServerIDStart = 2000,
	midServerTerminating,
	midServerPropertyChangeNotification,
	midServerPropertyValueResponse,
	midServerValidPropertyValuesResponse,
	midServerLoginResponse,
	midServerFileUpdateCheckResponse,
	midServerModeChangeStateNotification,
	midServerModeStateResponse,
	midServerDirectoryListingResponse,
	midServerPingStatusRequest,
	midServerClientSleepResponse,
	midServerControlClientRequest,
	midServerGetFileResponse,

Code: Select all

	CClientLoginMessage( DWORD dwAPIVersion, LPCTSTR szClientVersion, CString& szClientName, CString& szComputerName, CString& szPassword );
	CClientSubscribeToPropertyMessage( DWORD dwDeviceID, DWORD dwPropertyID );
	CClientBulkSubscribeToPropertiesMessage( LPCTSTR szData );
	CClientUnsubscribeFromPropertyMessage( DWORD dwDeviceID, DWORD dwPropertyID );
	CClientBulkUnsubscribeFromPropertiesMessage( LPCTSTR szData );
	CClientPropertyChangeRequestMessage( DWORD dwDeviceID, DWORD dwPropertyID, LPCTSTR szNewValue );
	CClientTaskExecuteRequestMessage( DWORD dwTaskID );
	CClientGetPropertyValueMessage( DWORD dwControlID, DWORD dwDeviceID, DWORD dwPropertyID );
	CClientGetValidPropertyValuesMessage( DWORD dwControlID, DWORD dwDeviceID, DWORD dwPropertyID );
	CClientFileUpdateCheckRequestMessage( LPCTSTR szFileName, DWORD dwChecksum );
	CClientChangeModeStateMessage( DWORD dwModeID, BOOL bActive );
	CClientGetModeStateMessage( DWORD dwControlID, DWORD dwModeID );
	CClientSleepMessage( BOOL bSleep );
	CClientDirectoryListingRequest( DWORD dwControlID, LPCTSTR szDirectory );
	CClientAddValueToList( DWORD dwIndex, LPCTSTR szItemToAdd, DWORD dwDeviceID, DWORD dwPropertyID );
	CClientChangeValueInList( eFunction eAction, DWORD dwIndex, DWORD dwDeviceID, DWORD dwPropertyID );
	CClientAcknowledgement( DWORD dwStatus );
	CClientInitialized( BOOL bInitialized );
	CClientGetFileRequest( DWORD dwControlID, BOOL bCompareChecksums, DWORD dwCheckSums, LPCTSTR szFileName );
	CClientMouseActionRequest( int nAction, int nX, int nY );
	CServerPropertyChangeNotificationMessage( DWORD dwDeviceID, DWORD dwPropertyID, LPCTSTR szPropertyValue );
	CServerPropertyValueMessage( DWORD dwControlID, DWORD dwDeviceID, DWORD dwPropertyID, LPCTSTR szPropertyValue );
	CServerValidPropertyValuesMessage( DWORD dwControlID, DWORD dwDeviceID, DWORD dwPropertyID, LPCTSTR szPropertyValues );
	CServerLoginResponseMessage( BOOL bLoginAccepted, LPCTSTR szDefaultTheme );
	CServerFileUpdateResponseMessage( BOOL bFilesMatch, LPCTSTR szFileName, LPVOID pUpdatedFileData, DWORD dwFileSize );
	CServerModeChangeStateNotificationMessage( DWORD dwModeID, BOOL bActive );
	CServerModeStateResponseMessage( DWORD dwControlID, DWORD dwModeID, BOOL bActive );
	CServerDirectoryListingResponse( DWORD dwControlID, LPCTSTR szListing );
	CServerPingStatusRequest( DWORD dwType );
	CServerClientSleepResponse();
	CServerControlClientRequest( DWORD dwAction, LPCTSTR szValue1, LPCTSTR szValue2 );	// Value 1 and 2 depend on the value set in dwAction
	CServerGetFileResponseMessage( DWORD dwControlID, BOOL bFilesMatch, LPCTSTR szFileName, DWORD dwServerChecksum, DWORD dwFileSize, LPVOID pFileData );
Scott
Post Reply