Преглед на файлове

split up getendpointsrequest in scm, rsp and gependpointsspecific
information to utilize gather buffer and prepare for further services.

Leon Urbas преди 10 години
родител
ревизия
7e708b4b01
променени са 1 файла, в които са добавени 38 реда и са изтрити 29 реда
  1. 38 29
      examples/src/opcuaServerMini.c

+ 38 - 29
examples/src/opcuaServerMini.c

@@ -35,45 +35,52 @@ int main(void) {
 
 #ifdef LINUX
 
-UA_Byte ack_msg_buf[] = { 					0x41, 0x43, /* ..m...AC */
+UA_Byte ack_msg_buf[] = { 					0x41, 0x43, /*       AC */
 		0x4b, 0x46, 0x1c, 0x00, 0x00, 0x00, 0xff, 0xff, /* KF...... */
 		0xff, 0xff, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, /* ... ...  */
 		0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, /* ...@.... */
-		0x00, 0x00                                      /* .. */
+		0x00, 0x00                                      /* ..       */
 };
 UA_ByteString ack_msg = { sizeof(ack_msg_buf), ack_msg_buf };
 UA_ByteString* ack_msg_gb[] = { &ack_msg };
 
 
-UA_Byte opn_msg_buf[] = {                   0x4f, 0x50, /* ......OP */
-		0x4e, 0x46, 0x88, 0x00, 0x00, 0x00, 0x19, 0x00, /* NF...... */
-		0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x68, 0x74, /* ../...ht */
-		0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x70, 0x63, /* tp://opc */
-		0x66, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, /* foundati */
-		0x6f, 0x6e, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x55, /* on.org/U */
-		0x41, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, /* A/Securi */
-		0x74, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, /* tyPolicy */
-		0x23, 0x4e, 0x6f, 0x6e, 0x65, 0xff, 0xff, 0xff, /* #None... */
-		0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x00, 0x00, /* .....3.. */
-		0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xc1, /* ........ */
-		0x01, 0x10, 0x56, 0x73, 0x9e, 0xdf, 0x63, 0xcf, /* ..Vs..c. */
-		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
-		0x00, 0xff, 0xff, 0xff, 0xff, 0x19, 0x00, 0x00, /* ........ */
-		0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
-		0x00, 0x01, 0x00, 0x00, 0x00, 0x48              /* .....H */ };
+UA_Byte opn_msg_buf[] = {           0x4f, 0x50, /*       OP */
+0x4e, 0x46, 0x88, 0x00, 0x00, 0x00, 0x19, 0x00, /* NF...... */
+0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x68, 0x74, /* ../...ht */
+0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x70, 0x63, /* tp://opc */
+0x66, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74, 0x69, /* foundati */
+0x6f, 0x6e, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x55, /* on.org/U */
+0x41, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, /* A/Securi */
+0x74, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, /* tyPolicy */
+0x23, 0x4e, 0x6f, 0x6e, 0x65, 0xff, 0xff, 0xff, /* #None... */
+0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x00, 0x00, /* .....3.. */
+0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xc1, /* ........ */
+0x01, 0x10, 0x56, 0x73, 0x9e, 0xdf, 0x63, 0xcf, /* ..Vs..c. */
+0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
+0x00, 0xff, 0xff, 0xff, 0xff, 0x19, 0x00, 0x00, /* ........ */
+0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
+0x00, 0x01, 0x00, 0x00, 0x00, 0x48              /* .....H   */
+};
+
 UA_ByteString opn_msg = { sizeof(opn_msg_buf), opn_msg_buf };
 UA_ByteString* opn_msg_gb[] = { &opn_msg };
 
-UA_Byte gep_msg_buf[] = {           0x4d, 0x53, /* ......MS */
-0x47, 0x46, 0x8b, 0x01, 0x00, 0x00, 0x19, 0x00, /* GF...... */
+UA_Byte scm_msg_buf[] = {           0x4d, 0x53, /*       MS */
+0x47, 0x46, 0x8b, 0x01, 0x00, 0x00, 0x19, 0x00, /* GF<XX>.. */ // <XX> = msglen. TODO: should be set or checked by writer?
 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x34, 0x00, /* ......4. */
-0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, /* ........ */
-0xaf, 0x01, 0x2c, 0xc1, 0x73, 0x9e, 0xdf, 0x63, /* ..,.s..c */
+0x00, 0x00, 0x02, 0x00, 0x00, 0x00              /* ......   */
+};
+UA_Byte rsp_msg_buf[] = {           0x01, 0x00, /* ........ */
+0xaf, 0x01, 0x2c, 0xc1, 0x73, 0x9e, 0xdf, 0x63, /* <>,.s..c */ // <> = response nS0-ID
 0xcf, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
-0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1b, 0x00, /* ........ */
+0x00, 0x00};
+
+UA_Byte gep_msg_buf[] = {
+		    0x01, 0x00, 0x00, 0x00, 0x1b, 0x00, /*   ...... */
 0x00, 0x00, 0x6f, 0x70, 0x63, 0x2e, 0x74, 0x63, /* ..opc.tc */
 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x30, 0x2e, 0x30, /* p://10.0 */
 0x2e, 0x35, 0x33, 0x2e, 0x31, 0x39, 0x38, 0x3a, /* .53.198: */
@@ -118,8 +125,10 @@ UA_Byte gep_msg_buf[] = {           0x4d, 0x53, /* ......MS */
 0x75, 0x61, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, /* uabinary */
 0x00                                            /* . */
 };
+UA_ByteString scm_msg = { sizeof(scm_msg_buf), scm_msg_buf };
+UA_ByteString rsp_msg = { sizeof(rsp_msg_buf), rsp_msg_buf };
 UA_ByteString gep_msg = { sizeof(gep_msg_buf), gep_msg_buf };
-UA_ByteString* gep_msg_gb[] = { &gep_msg };
+UA_ByteString* gep_msg_gb[] = { &scm_msg, &rsp_msg, &gep_msg };
 
 UA_Int32 myProcess(TL_Connection* connection, const UA_ByteString* msg) {
 	switch (*((UA_Int32*) &(msg->data[0]))) { // compare first four bytes
@@ -136,11 +145,11 @@ UA_Int32 myProcess(TL_Connection* connection, const UA_ByteString* msg) {
 			switch (*((UA_Int16*) &(msg->data[26]))) {
 				case (UA_Int16) 0xAC01: // 428 - GetEndpointsRequest
 					printf("server_run - GetEndpointsRequest\n");
-					connection->writerCallback(connection, (const UA_ByteString**) &gep_msg_gb, 1);
+					connection->writerCallback(connection, (const UA_ByteString**) &gep_msg_gb, 3);
 				break;
 				default:
-					//FIXME: send a real error message
-					connection->writerCallback(connection, (const UA_ByteString**) &gep_msg_gb, 1);
+					//FIXME: construct and send a real error message
+					connection->writerCallback(connection, (const UA_ByteString**) &gep_msg_gb, 3);
 				break;
 			}
 		break;