<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>iLived小站</title>
	<atom:link href="http://www.ilived.cn/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ilived.cn/wordpress</link>
	<description>写写我的程序，写写我的生活...</description>
	<pubDate>Wed, 02 Dec 2009 09:17:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>GSM0408RR部分阅读的选取笔记</title>
		<link>http://www.ilived.cn/wordpress/2009/12/gsm0408rr%e9%83%a8%e5%88%86%e9%98%85%e8%af%bb%e7%9a%84%e9%80%89%e5%8f%96%e7%ac%94%e8%ae%b0/</link>
		<comments>http://www.ilived.cn/wordpress/2009/12/gsm0408rr%e9%83%a8%e5%88%86%e9%98%85%e8%af%bb%e7%9a%84%e9%80%89%e5%8f%96%e7%ac%94%e8%ae%b0/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 09:16:55 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[GSM协议栈]]></category>

		<category><![CDATA[TI]]></category>

		<category><![CDATA[技术资料]]></category>

		<category><![CDATA[RR]]></category>

		<category><![CDATA[协议栈]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=580</guid>
		<description><![CDATA[国庆，旅游等等杂事让我荒废了接近3个月，现在还是要重新开始努力了，不管结局如何。
GSM0408RR部分阅读的选取部分
Two service access points are defined on signalling layer 2 which are discriminated by their Service
Access Point Identifiers (SAPI) (see GSM 04.06):
i) SAPI 0: supports the transfer of signalling information including user-user information;
ii) SAPI 3: supports the transfer of user short messages.
The general purpose of Radio Resource procedures is to establish, maintain and release RR [...]]]></description>
			<content:encoded><![CDATA[<p>国庆，旅游等等杂事让我荒废了接近3个月，现在还是要重新开始努力了，不管结局如何。</p>
<p>GSM0408RR部分阅读的选取部分<br />
Two service access points are defined on signalling layer 2 which are discriminated by their Service<br />
Access Point Identifiers (SAPI) (see GSM 04.06):<br />
i) SAPI 0: supports the transfer of signalling information including user-user information;<br />
ii) SAPI 3: supports the transfer of user short messages.</p>
<p>The general purpose of Radio Resource procedures is to establish, maintain and release RR connections<br />
that allow a point-to-point dialogue between the network and a mobile station. This includes the cell<br />
selection/reselection and the handover procedures. Moreover, Radio Resource management procedures<br />
include the reception of the uni-directional BCCH and CCCH when no RR connection is established. This<br />
permits automatic cell selection/reselection.<br />
A RR connection is a physical connection used by the two peer entities to support the upper layers’<br />
exchange of information flows.</p>
<p>In idle mode no RR connection exists.<br />
In Idle mode, upper layers can require the establishment of an RR connection</p>
<p>In dedicated mode, the RR connection is a physical point-to-point bi-directional connection, and includes a<br />
SAPI 0 data link connection operating in multiframe mode on the main DCCH. If dedicated mode is<br />
established, RR procedures provide the following services:<br />
- establishment/release of multiframe mode on data link layer connections other than SAPI 0, on the<br />
main DCCH or on the SACCH associated with the channel carrying the main signalling link;<br />
- transfer of messages on any data link layer connection;<br />
- indication of temporary unavailability of transmission (suspension, resuming);<br />
- indication of loss of RR connection;<br />
- automatic cell reselection and handover to maintain the RR connection;<br />
Page 34<br />
Draft prETS 300 940 (GSM 04.08 Part A version 5.7.0): October 1997<br />
- setting/change of the transmission mode on the physical channels, including change of type of<br />
channel, change of the coding/decoding/transcoding mode and setting of ciphering;<br />
- allocation/release of an additional channel (for the TCH/H + TCH/H configuration);<br />
- allocation/release of additional channels for multislot operation;<br />
- release of an RR connection.</p>
<p>In case a change of dedicated channels is required using a dedicated assignment and handover<br />
procedure, respectively, the RR sublayer will request the data link layer to suspend multiple frame<br />
operation before the mobile station leaves the old channel. When the channel change has been<br />
completed, layer 3 will request the data link layer to resume multiple frame operation again.</p>
<p>For SAPIs other than 0, the data link procedures described in GSM 04.06 do not provide any guarantee<br />
against message loss or duplication.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/12/gsm0408rr%e9%83%a8%e5%88%86%e9%98%85%e8%af%bb%e7%9a%84%e9%80%89%e5%8f%96%e7%ac%94%e8%ae%b0/feed/</wfw:commentRss>
		</item>
		<item>
		<title>directdraw error信息汇总</title>
		<link>http://www.ilived.cn/wordpress/2009/09/directdraw-error%e4%bf%a1%e6%81%af%e6%b1%87%e6%80%bb/</link>
		<comments>http://www.ilived.cn/wordpress/2009/09/directdraw-error%e4%bf%a1%e6%81%af%e6%b1%87%e6%80%bb/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 11:34:31 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[技术资料]]></category>

		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=559</guid>
		<description><![CDATA[具体请看附件..
errornumber
类似
(0, &#8220;S_OK&#8221;, &#8220;The function completed successfully&#8221;)
(0&#215;1, &#8220;S_FALSE&#8221;, &#8220;Call successful, but returned FALSE&#8221;)
(0&#215;2, &#8220;DXERROR_FILE_NOT_FOUND&#8221;, &#8220;The system cannot find the file specified.&#8221;)
(0&#215;3, &#8220;DXERROR_PATH_NOT_FOUND&#8221;, &#8220;The system cannot find the path specified.&#8221;)
(0&#215;4, &#8220;DXERROR_TOO_MANY_OPEN_FILES&#8221;, &#8220;The system cannot open the file.&#8221;)
(0&#215;5, &#8220;DXERROR_ACCESS_DENIED&#8221;, &#8220;Access is denied.&#8221;)
(0&#215;6, &#8220;DXERROR_INVALID_HANDLE&#8221;, &#8220;The handle is invalid.&#8221;)
(0&#215;8, &#8220;DXERROR_NOT_ENOUGH_MEMORY&#8221;, &#8220;Not enough storage is available to process this command.&#8221;)
(0&#215;9, &#8220;DXERROR_INVALID_BLOCK&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p>具体请看附件..</p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/09/errornumber.txt">errornumber</a></p>
<p>类似</p>
<p>(0, &#8220;S_OK&#8221;, &#8220;The function completed successfully&#8221;)<br />
(0&#215;1, &#8220;S_FALSE&#8221;, &#8220;Call successful, but returned FALSE&#8221;)<br />
(0&#215;2, &#8220;DXERROR_FILE_NOT_FOUND&#8221;, &#8220;The system cannot find the file specified.&#8221;)<br />
(0&#215;3, &#8220;DXERROR_PATH_NOT_FOUND&#8221;, &#8220;The system cannot find the path specified.&#8221;)<br />
(0&#215;4, &#8220;DXERROR_TOO_MANY_OPEN_FILES&#8221;, &#8220;The system cannot open the file.&#8221;)<br />
(0&#215;5, &#8220;DXERROR_ACCESS_DENIED&#8221;, &#8220;Access is denied.&#8221;)<br />
(0&#215;6, &#8220;DXERROR_INVALID_HANDLE&#8221;, &#8220;The handle is invalid.&#8221;)<br />
(0&#215;8, &#8220;DXERROR_NOT_ENOUGH_MEMORY&#8221;, &#8220;Not enough storage is available to process this command.&#8221;)<br />
(0&#215;9, &#8220;DXERROR_INVALID_BLOCK&#8221;, &#8220;The storage control block address is invalid.&#8221;)<br />
(0xa, &#8220;DXERROR_BAD_ENVIRONMENT&#8221;, &#8220;The environment is incorrect.&#8221;)<br />
(0xb, &#8220;DXERROR_BAD_FORMAT&#8221;, &#8220;An attempt was made to load a program with an incorrect format.&#8221;)<br />
(0xe, &#8220;DXERROR_OUTOFMEMORY&#8221;, &#8220;The system cannot find the drive specified.&#8221;)<br />
(0&#215;40003, &#8220;Unknown&#8221;, &#8220;End of stream. Sample not updated.&#8221;)<br />
(0&#215;40103, &#8220;VFW_S_NO_MORE_ITEMS&#8221;, &#8220;The end of the list has been reached.&#8221;)<br />
(0&#215;4022d, &#8220;VFW_S_DUPLICATE_NAME&#8221;, &#8220;An attempt to add a filter with a duplicate name succeeded with a modified name.&#8221;)<br />
(0&#215;40237, &#8220;VFW_S_STATE_INTERMEDIATE&#8221;, &#8220;The state transition has not completed.&#8221;)<br />
(0&#215;40242, &#8220;VFW_S_PARTIAL_RENDER&#8221;, &#8220;Some of the streams in this movie are in an unsupported format.&#8221;)<br />
(0&#215;40245, &#8220;VFW_S_SOME_DATA_IGNORED&#8221;, &#8220;The file contained some property settings that were not used.&#8221;)<br />
(0&#215;40246, &#8220;VFW_S_CONNECTIONS_DEFERRED&#8221;, &#8220;Some connections have failed and have been deferred.&#8221;)<br />
(0&#215;40250, &#8220;VFW_S_RESOURCE_NOT_NEEDED&#8221;, &#8220;The resource specified is no longer needed.&#8221;)<br />
(0&#215;40254, &#8220;VFW_S_MEDIA_TYPE_IGNORED&#8221;, &#8220;A connection could not be made with the media type in the persistent graph, but has been made with a negotiated media type.&#8221;)<br />
(0&#215;40257, &#8220;VFW_S_VIDEO_NOT_RENDERED&#8221;, &#8220;Cannot play back the video stream: no suitable decompressor could be found.&#8221;)<br />
(0&#215;40258, &#8220;VFW_S_AUDIO_NOT_RENDERED&#8221;, &#8220;Cannot play back the audio stream: no audio hardware is available.&#8221;)<br />
(0&#215;4025a, &#8220;VFW_S_RPZA&#8221;, &#8220;Cannot play back the video stream: format &#8216;RPZA&#8217; is not supported.&#8221;)<br />
(0&#215;40260, &#8220;VFW_S_ESTIMATED&#8221;, &#8220;The value returned had to be estimated.  It&#8217;s accuracy can not be guaranteed.&#8221;)<br />
(0&#215;40263, &#8220;VFW_S_RESERVED&#8221;, &#8220;This success code is reserved for internal purposes within ActiveMovie.&#8221;)<br />
(0&#215;40267, &#8220;VFW_S_STREAM_OFF&#8221;, &#8220;The stream has been turned off.&#8221;)<br />
(0&#215;40268, &#8220;VFW_S_CANT_CUE&#8221;, &#8220;The graph can&#8217;t be cued because of lack of or corrupt data.&#8221;)<br />
(0&#215;40270, &#8220;VFW_S_NO_STOP_TIME&#8221;, &#8220;The stop time for the sample was not set.&#8221;)<br />
(0&#215;4027e, &#8220;VFW_S_NOPREVIEWPIN&#8221;, &#8220;There was no preview pin available, so the capture pin output is being split to provide both capture and preview.&#8221;)<br />
(0&#215;40280, &#8220;VFW_S_DVD_NON_ONE_SEQUENTIAL&#8221;, &#8220;The current title was not a sequential set of chapters (PGC) and the returned timing information might not be continuous.&#8221;)<br />
(0&#215;4028c, &#8220;VFW_S_DVD_CHANNEL_CONTENTS_NOT_AVAILABLE&#8221;, &#8220;The audio stream did not contain sufficient information to determine the contents of each channel.&#8221;)<br />
(0&#215;4028d, &#8220;VFW_S_DVD_NOT_ACCURATE&#8221;, &#8220;The seek into the movie was not frame accurate.&#8221;)<br />
(0&#215;150005, &#8220;DV_FULLDUPLEX&#8221;, &#8220;Full duplex&#8221;)<br />
(0&#215;15000a, &#8220;DV_HALFDUPLEX&#8221;, &#8220;Half duplex&#8221;)<br />
(0&#215;150010, &#8220;DV_PENDING&#8221;, &#8220;Pending&#8221;)<br />
(0&#215;876086f, &#8220;D3DOK_NOAUTOGEN&#8221;, &#8220;The call succeeded but there won&#8217;t be any mipmaps generated&#8221;)<br />
(0&#215;878000a, &#8220;DS_NO_VIRTUALIZATION&#8221;, &#8220;The call succeeded, but we had to substitute the 3D algorithm&#8221;)<br />
DXERROR8(0&#215;8780014, &#8220;DS_INCOMPLETE&#8221;, &#8220;The call succeeded, but not all of the optional effects were obtained.&#8221;)<br />
(0&#215;8781091, &#8220;DMUS_S_PARTIALLOAD&#8221;, &#8220;The object could only load partially. This can happen if some components are not registered properly, such as embedded tracks and tools. This can also happen if some content is missing. For example, if a segment uses a DLS collection that is not in the loader&#8217;s current search directory.&#8221;)<br />
(0&#215;8781092, &#8220;DMUS_S_PARTIALDOWNLOAD&#8221;, &#8220;Return value from IDirectMusicBand::Download() which indicates that some of the instruments safely downloaded, but others failed. This usually occurs when some instruments are on PChannels not supported by the performance or port.&#8221;)<br />
(0&#215;8781200, &#8220;DMUS_S_REQUEUE&#8221;, &#8220;Return value from IDirectMusicTool::ProcessPMsg() which indicates to the performance that it should cue the PMsg again automatically.&#8221;)<br />
(0&#215;8781201, &#8220;DMUS_S_FREE&#8221;, &#8220;Return value from IDirectMusicTool::ProcessPMsg() which indicates to the performance that it should free the PMsg automatically.&#8221;)<br />
(0&#215;8781202, &#8220;DMUS_S_END&#8221;, &#8220;Return value from IDirectMusicTrack::Play() which indicates to the segment that the track has no more data after mtEnd.&#8221;)<br />
(0&#215;8781210, &#8220;DMUS_S_STRING_TRUNCATED&#8221;, &#8220;Returned string has been truncated to fit the buffer size.&#8221;)<br />
(0&#215;8781211, &#8220;DMUS_S_LAST_TOOL&#8221;, &#8220;Returned from IDirectMusicGraph::StampPMsg() this indicates that the PMsg is already stamped with the last tool in the graph. The returned PMsg&#8217;s tool pointer is now NULL.&#8221;)<br />
(0&#215;8781212, &#8220;DMUS_S_OVER_CHORD&#8221;, &#8220;Returned from IDirectMusicPerformance::MusicToMIDI() this indicates  that no note has been calculated because the music value has the note  at a position higher than the top note of the chord. This applies only to DMUS_PLAYMODE_NORMALCHORD play mode. This success code indicates that the caller should not do anything with the note. It is not meant to be played against this chord.&#8221;)<br />
(0&#215;8781213, &#8220;DMUS_S_UP_OCTAVE&#8221;, &#8220;Returned from IDirectMusicPerformance::MIDIToMusic()  and IDirectMusicPerformance::MusicToMIDI() this indicates  that the note conversion generated a note value that is below 0,  so it has been bumped up one or more octaves to be in the proper MIDI range of 0 through 127.  Note that this is valid for MIDIToMusic() when using play modes DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of which store MIDI values in wMusicValue. With MusicToMIDI() it is valid for all play modes. Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code.&#8221;)<br />
(0&#215;8781214, &#8220;DMUS_S_DOWN_OCTAVE&#8221;, &#8220;Returned from IDirectMusicPerformance::MIDIToMusic()  and IDirectMusicPerformance::MusicToMIDI() this indicates  that the note conversion generated a note value that is above 127, so it has been bumped down one or more octaves to be in the proper MIDI range of 0 through 127.  Note that this is valid for MIDIToMusic() when using play modes DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of which store MIDI values in wMusicValue. With MusicToMIDI() it is valid for all play modes. Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code.&#8221;)<br />
(0&#215;8781215, &#8220;DMUS_S_NOBUFFERCONTROL&#8221;, &#8220;Although the audio output from the port will be routed to the same device as the given DirectSound buffer, buffer controls such as pan and volume will not affect the output.&#8221;)<br />
(0&#215;8781216, &#8220;DMUS_S_GARBAGE_COLLECTED&#8221;, &#8220;The requested operation was not performed because during CollectGarbage the loader determined that the object had been released.&#8221;)<br />
(0&#215;8000000a, &#8220;E_PENDING&#8221;, &#8220;The data necessary to complete this operation is not yet available.&#8221;)<br />
(0&#215;80004001, &#8220;E_NOTIMPL&#8221;, &#8220;The function called is not supported at this time&#8221;)<br />
(0&#215;80004002, &#8220;E_NOINTERFACE&#8221;, &#8220;The requested COM interface is not available&#8221;)<br />
(0&#215;80004003, &#8220;E_POINTER&#8221;, &#8220;Invalid pointer&#8221;)<br />
(0&#215;80004004, &#8220;E_ABORT&#8221;, &#8220;Operation aborted&#8221;)<br />
(0&#215;80004005, &#8220;E_FAIL&#8221;, &#8220;An undetermined error occurred&#8221;)<br />
(0&#215;8000ffff, &#8220;E_UNEXPECTED&#8221;, &#8220;Catastrophic failure&#8221;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/09/directdraw-error%e4%bf%a1%e6%81%af%e6%b1%87%e6%80%bb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Windows mobile双camera切换流程</title>
		<link>http://www.ilived.cn/wordpress/2009/09/windows-mobile%e5%8f%8ccamera%e5%88%87%e6%8d%a2%e6%b5%81%e7%a8%8b/</link>
		<comments>http://www.ilived.cn/wordpress/2009/09/windows-mobile%e5%8f%8ccamera%e5%88%87%e6%8d%a2%e6%b5%81%e7%a8%8b/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 10:56:53 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[技术资料]]></category>

		<category><![CDATA[源代码分析]]></category>

		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=555</guid>
		<description><![CDATA[所有内容是根据http://blog.csdn.net/moonsunearth/archive/2007/09/25/1800790.aspx整理得来的。 
首先Windows mobile自带的camera程序是不支持双camera的，如果要加入双camera一个方法是在原来的程序中插入一个菜单来实现调用（经验证菜单的加入是可以实现的），另一个比较推荐的做法是使用directshow自己写一个camera程序。 
切换的关键部分是通过directshow控制camera，然后驱动对切换消息进行响应，切换sensor。 
Directshow对camera控制的接口如下： 
LRESULT hr;
&#160;&#160;&#160;&#160; CComPtr&#60;IAMCameraControl&#62; pCameraControl;
long lCurrentVal,lCurrentFlags;
long CameraControl_Switch=CameraControl_Flash+0xff;
if(sensor&#62;=SENSOR_MAX)return FALSE;
&#160;&#160;&#160;&#160; CHK(m_pVideoCapFilter-&#62;QueryInterface(&#38;pCameraControl));
&#160;&#160;&#160;&#160; CHK(pCameraControl-&#62;Get(CameraControl_Switch, &#38;lCurrentVal, &#38;lCurrentFlags));if(lCurrentVal == sensor)&#8230;{//return TRUE;&#160;&#160;&#160;&#160; }&#160;&#160; CHK(pCameraControl-&#62;Set(CameraControl_Switch, sensor, CameraControl_Flags_Manual)); 
IAMCameraControl::Set函数会调用CAM_IOControl，Ioctl=IOCTL_CS_PROPERTY这个是让驱动进行响应的关键。 
在CAM_IOControl函数中对应的IOCTL_CS_PROPERTY中的部分是 
else if ( TRUE == IsEqualGUID( pCsProp-&#62;Set, PROPSETID_VIDCAP_CAMERACONTROL ) ) 
{ 
dwErr = pCamDevice-&#62;AdapterHandleCamControlRequests( pInBuf,InBufLen, pOutBuf, OutBufLen, pdwBytesTransferred ); 
} 
对于我们代码的添加一个是在这里添加一个自己的customer函数，另一个方法是继续向上层走，然后在上层添加自己的函数。不过因为这里是mdd层，所以最好不要修改，放到pdd层。 
整个的流程的修改基本上就是这么多了。 
在驱动层需要实现不同camera sensor的切换，然后上层通过directshow的IAMStreamConfig实现。 
CComPtr&#60;IAMStreamConfig&#62; pStremConfig;
&#160;&#160;&#160; CHK(m_pCapGraphBuilder-&#62;FindInterface(&#38;PIN_CATEGORY_CAPTURE, 0, m_pVideoCapFilter, IID_IAMStreamConfig, [...]]]></description>
			<content:encoded><![CDATA[<p><p>所有内容是根据<a href="http://blog.csdn.net/moonsunearth/archive/2007/09/25/1800790.aspx">http://blog.csdn.net/moonsunearth/archive/2007/09/25/1800790.aspx</a>整理得来的。 </p>
<p>首先Windows mobile自带的camera程序是不支持双camera的，如果要加入双camera一个方法是在原来的程序中插入一个菜单来实现调用（经验证菜单的加入是可以实现的），另一个比较推荐的做法是使用directshow自己写一个camera程序。 </p>
<p>切换的关键部分是通过directshow控制camera，然后驱动对切换消息进行响应，切换sensor。 </p>
<p>Directshow对camera控制的接口如下： </p>
<p>LRESULT hr;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; CComPtr&lt;IAMCameraControl&gt; pCameraControl;</p>
<p>long lCurrentVal,lCurrentFlags;</p>
<p>long CameraControl_Switch=CameraControl_Flash+0xff;</p>
<p>if(sensor&gt;=SENSOR_MAX)<br />return FALSE;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; CHK(m_pVideoCapFilter-&gt;QueryInterface(&amp;pCameraControl));</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; CHK(pCameraControl-&gt;Get(CameraControl_Switch, &amp;lCurrentVal, &amp;lCurrentFlags));<br />if(lCurrentVal == sensor)<br />&#8230;{<br />//return TRUE;<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp; CHK(pCameraControl-&gt;Set(CameraControl_Switch, sensor, CameraControl_Flags_Manual)); </p>
<p>IAMCameraControl::Set函数会调用CAM_IOControl，Ioctl=IOCTL_CS_PROPERTY这个是让驱动进行响应的关键。 </p>
<p>在CAM_IOControl函数中对应的IOCTL_CS_PROPERTY中的部分是 </p>
<p>else if ( TRUE == IsEqualGUID( pCsProp-&gt;Set, PROPSETID_VIDCAP_CAMERACONTROL ) ) </p>
<p>{ </p>
<p>dwErr = pCamDevice-&gt;AdapterHandleCamControlRequests( pInBuf,InBufLen, pOutBuf, OutBufLen, pdwBytesTransferred ); </p>
<p>} </p>
<p>对于我们代码的添加一个是在这里添加一个自己的customer函数，另一个方法是继续向上层走，然后在上层添加自己的函数。不过因为这里是mdd层，所以最好不要修改，放到pdd层。 </p>
<p>整个的流程的修改基本上就是这么多了。 </p>
<p>在驱动层需要实现不同camera sensor的切换，然后上层通过directshow的IAMStreamConfig实现。 </p>
<p>CComPtr&lt;IAMStreamConfig&gt; pStremConfig;</p>
<p>&nbsp;&nbsp;&nbsp; CHK(m_pCapGraphBuilder-&gt;FindInterface(&amp;PIN_CATEGORY_CAPTURE, 0, m_pVideoCapFilter, IID_IAMStreamConfig, (void **)&amp;pStremConfig))</p>
<p>&nbsp;&nbsp;&nbsp; CHK(pStremConfig-&gt;GetNumberOfCapabilities(&amp;iCount, &amp;iSize));</p>
<p> if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))<br />&#8230;{<br />for (int iFormat = 0; iFormat &lt; iCount; iFormat++)<br />&#8230;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VIDEO_STREAM_CONFIG_CAPS scc;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AM_MEDIA_TYPE *pmtConfig;</p>
<p>CHK(pStremConfig-&gt;GetStreamCaps(iFormat, &amp;pmtConfig, (BYTE*)&amp;scc));<br />if (SUCCEEDED(hr))<br />&#8230;{<br />if(scc.MinOutputSize.cx == pSize-&gt;cx &amp;&amp; scc.MinOutputSize.cy == pSize-&gt;cy) <br />&#8230;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CHK(pStremConfig-&gt;SetFormat(pmtConfig));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeleteMediaType(pmtConfig);<br />break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeleteMediaType(pmtConfig);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; } </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/09/windows-mobile%e5%8f%8ccamera%e5%88%87%e6%8d%a2%e6%b5%81%e7%a8%8b/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RR功能概述</title>
		<link>http://www.ilived.cn/wordpress/2009/08/rr%e5%8a%9f%e8%83%bd%e6%a6%82%e8%bf%b0/</link>
		<comments>http://www.ilived.cn/wordpress/2009/08/rr%e5%8a%9f%e8%83%bd%e6%a6%82%e8%bf%b0/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 10:48:30 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[GSM协议栈]]></category>

		<category><![CDATA[RR]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=551</guid>
		<description><![CDATA[无线资源管理RR（Radio Resource Management）的作用主要是建立、维护及释放无线连接，从而允许MS（Mobile Station）与网络进行点到点通信。主要包括：小区的的选择和重选，以及切换等。RR子层还包括守听单向BCCH和CCCH通道的功能，从而实现自动小区切换。
如果支持GPRS（General Packet Radio Service）点到点服务功能，RR子层还包括管理包数据物理通道（Packet data physical channels）。
如果支持VGCS（Voice Group Call Service）和VBS（Voice Broadcast Service）功能，RR子层还包括守听NCH（Notification Channel）通道的功能，以及获取及释放组呼（Voice Group Call）通道的功能。
]]></description>
			<content:encoded><![CDATA[<p>无线资源管理RR（Radio Resource Management）的作用主要是建立、维护及释放无线连接，从而允许MS（Mobile Station）与网络进行点到点通信。主要包括：小区的的选择和重选，以及切换等。RR子层还包括守听单向BCCH和CCCH通道的功能，从而实现自动小区切换。</p>
<p>如果支持GPRS（General Packet Radio Service）点到点服务功能，RR子层还包括管理包数据物理通道（Packet data physical channels）。</p>
<p>如果支持VGCS（Voice Group Call Service）和VBS（Voice Broadcast Service）功能，RR子层还包括守听NCH（Notification Channel）通道的功能，以及获取及释放组呼（Voice Group Call）通道的功能。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/08/rr%e5%8a%9f%e8%83%bd%e6%a6%82%e8%bf%b0/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MM的一个情况处理</title>
		<link>http://www.ilived.cn/wordpress/2009/08/mm%e7%9a%84%e4%b8%80%e4%b8%aa%e6%83%85%e5%86%b5%e5%a4%84%e7%90%86/</link>
		<comments>http://www.ilived.cn/wordpress/2009/08/mm%e7%9a%84%e4%b8%80%e4%b8%aa%e6%83%85%e5%86%b5%e5%a4%84%e7%90%86/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 11:47:37 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[Featured]]></category>

		<category><![CDATA[GSM协议栈]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=549</guid>
		<description><![CDATA[当一些请求发起时，MM可能暂时无法执行，但是后续状态有是有可能允许执行该命令时。例如当mm正在等待网络回复时，此时mmi有发起了一个网络搜索命令，这个命令在现在的状态发起也不是错误的。MM此时不能对该命令返回错误。与此对应例如在无sim卡情况下发起的非紧急的call，mm就会对该命令返回错误，此命令无法被执行。
对于这些mm暂时无法执行的请求,mm会调用mm_write_entry函数将这些命令放入一张表中，等待合适的时机对其进行执行。可以执行这些等待命令的时机有mm处理完其他发送给他的原语后，mm的timer超时执行完对应的操作后。
当mm可以执行表中的命令时，mm会将整个表中的命令从头开始都执行，而不是一次只执行一个命令。在这张命令表中，存有这些消息的发起者，ti，以及命令含义。mm能够根据这些信息来重新执行这些命令。
]]></description>
			<content:encoded><![CDATA[<p>当一些请求发起时，MM可能暂时无法执行，但是后续状态有是有可能允许执行该命令时。例如当mm正在等待网络回复时，此时mmi有发起了一个网络搜索命令，这个命令在现在的状态发起也不是错误的。MM此时不能对该命令返回错误。与此对应例如在无sim卡情况下发起的非紧急的call，mm就会对该命令返回错误，此命令无法被执行。<br />
对于这些mm暂时无法执行的请求,mm会调用mm_write_entry函数将这些命令放入一张表中，等待合适的时机对其进行执行。可以执行这些等待命令的时机有mm处理完其他发送给他的原语后，mm的timer超时执行完对应的操作后。<br />
当mm可以执行表中的命令时，mm会将整个表中的命令从头开始都执行，而不是一次只执行一个命令。在这张命令表中，存有这些消息的发起者，ti，以及命令含义。mm能够根据这些信息来重新执行这些命令。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/08/mm%e7%9a%84%e4%b8%80%e4%b8%aa%e6%83%85%e5%86%b5%e5%a4%84%e7%90%86/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MM-Connection Management</title>
		<link>http://www.ilived.cn/wordpress/2009/08/mm-connection-management/</link>
		<comments>http://www.ilived.cn/wordpress/2009/08/mm-connection-management/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 10:45:54 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[GSM协议栈]]></category>

		<category><![CDATA[TI]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=547</guid>
		<description><![CDATA[1. MMI/CM发送MMXX_ESTABLISH_REQ给MM。XX可能是CC, SS 或 SMS。使用的ti（transaction identifier）从0到6.
2. 当有RR connection存在时MM发送RR_DATA_REQ给RR，当没有RR connection存在时MM发送RR_ESTABLISH_REQ给RR。
3. 当RR connection确立时，MM会开启T3240 timer同时等待网络的回应。
4. 当一切正确时，网络会通过RR返回RR_ESTABLISH_CNF给MM。
5. 当网络可以提供MMI/CM所要求的服务时，RR/DL会发送RR_DATA_IND(CM SERVICE ACCEPT)给MM。
6. 接着RR/DL会发送RR_SYNC_IND(ciphering on)给MM。
7. MM返回MMXX_ESTABLISH_CNF给MMI/CM。
如果T3240超时而网络没有响应时，MM会向RR发送RR_ABORT_REQ，然后向MMI/CM发送MMXX_RELEASE_IND
]]></description>
			<content:encoded><![CDATA[<p>1. MMI/CM发送MMXX_ESTABLISH_REQ给MM。XX可能是CC, SS 或 SMS。使用的ti（transaction identifier）从0到6.</p>
<p>2. 当有RR connection存在时MM发送RR_DATA_REQ给RR，当没有RR connection存在时MM发送RR_ESTABLISH_REQ给RR。</p>
<p>3. 当RR connection确立时，MM会开启T3240 timer同时等待网络的回应。</p>
<p>4. 当一切正确时，网络会通过RR返回RR_ESTABLISH_CNF给MM。</p>
<p>5. 当网络可以提供MMI/CM所要求的服务时，RR/DL会发送RR_DATA_IND(CM SERVICE ACCEPT)给MM。</p>
<p>6. 接着RR/DL会发送RR_SYNC_IND(ciphering on)给MM。</p>
<p>7. MM返回MMXX_ESTABLISH_CNF给MMI/CM。</p>
<p>如果T3240超时而网络没有响应时，MM会向RR发送RR_ABORT_REQ，然后向MMI/CM发送MMXX_RELEASE_IND</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/08/mm-connection-management/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Authentication</title>
		<link>http://www.ilived.cn/wordpress/2009/08/authentication/</link>
		<comments>http://www.ilived.cn/wordpress/2009/08/authentication/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 10:54:01 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[GSM协议栈]]></category>

		<category><![CDATA[TI]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=545</guid>
		<description><![CDATA[Authentication
当MM在注册网络时，网络会发送Authentication的请求。这个请求是通过RR_DATA_IND（AUTHENTICATION REQUEST)发送给MM。在这个原语中带有从网络发送过来的Random Number (RAND)。MM会通过SIM_AUTHENTICATION_REQ这个原语将RAND发送给SIM。SIM会执行RUN GSM ALGORITHM.这个命令，根据得到的RAND计算出SRES 和Kc，然后通过SIM_AUTHENTICATION_CNF发送给MM。MM得到这些数据后会通过RR_DATA_REQ(AUTHENTICATION RESPONSE)，RR_SYNC_REQ (ciphering parameters)发送给RR，然后传送给网络。网络会比较传送过来的SRES 和自己计算出来的SRES 来作为Authentication的依据。Kc会被ME端用作以后同网络进行enciphered。
SIM响应MM的SIM_AUTHENTICATION_REQ代码流程如下：
if (SIM_IS_FLAG_SET (GSM_DATAFIELD))
error = FKT_Select (SIM_DF_GSM, NULL, 0);
else
error = FKT_Select (SIM_DF_1800, NULL, 0);
//需要注意的是SIM在执行RUN GSM ALGORITHM时需要先选中DFGSM
if (error EQ SIM_NO_ERROR)
error = FKT_RunGSMAlgo (sim_authentication_req-&#62;rand, response, SIM_GSM_ALG_LEN);
////////////////////////////////////
// FKT_RunGSMAlgo这个函数的实现如下
sw1sw2 = SIM_RunGSMAlgo ((UBYTE *)response,
(UBYTE *)rand,
&#38;size);
error = FKT_convert_error (sw1sw2, size);
if (error EQ SIM_NO_ERROR)
error = FKT_GetResponse (data, len);
return error;
// SIM_RunGSMAlgo函数就是直接封装SIM的COMMAND SIM_RUN_GSM_ALGO然后发送给SIM
///////////////////////////////////////////
PSENDX (MM, [...]]]></description>
			<content:encoded><![CDATA[<p>Authentication</p>
<p>当MM在注册网络时，网络会发送Authentication的请求。这个请求是通过RR_DATA_IND（AUTHENTICATION REQUEST)发送给MM。在这个原语中带有从网络发送过来的Random Number (RAND)。MM会通过SIM_AUTHENTICATION_REQ这个原语将RAND发送给SIM。SIM会执行RUN GSM ALGORITHM.这个命令，根据得到的RAND计算出SRES 和Kc，然后通过SIM_AUTHENTICATION_CNF发送给MM。MM得到这些数据后会通过RR_DATA_REQ(AUTHENTICATION RESPONSE)，RR_SYNC_REQ (ciphering parameters)发送给RR，然后传送给网络。网络会比较传送过来的SRES 和自己计算出来的SRES 来作为Authentication的依据。Kc会被ME端用作以后同网络进行enciphered。</p>
<p>SIM响应MM的SIM_AUTHENTICATION_REQ代码流程如下：</p>
<p>if (SIM_IS_FLAG_SET (GSM_DATAFIELD))</p>
<p>error = FKT_Select (SIM_DF_GSM, NULL, 0);</p>
<p>else</p>
<p>error = FKT_Select (SIM_DF_1800, NULL, 0);</p>
<p>//需要注意的是SIM在执行RUN GSM ALGORITHM时需要先选中DFGSM</p>
<p>if (error EQ SIM_NO_ERROR)</p>
<p>error = FKT_RunGSMAlgo (sim_authentication_req-&gt;rand, response, SIM_GSM_ALG_LEN);</p>
<p>////////////////////////////////////</p>
<p>// FKT_RunGSMAlgo这个函数的实现如下</p>
<p>sw1sw2 = SIM_RunGSMAlgo ((UBYTE *)response,</p>
<p>(UBYTE *)rand,</p>
<p>&amp;size);</p>
<p>error = FKT_convert_error (sw1sw2, size);</p>
<p>if (error EQ SIM_NO_ERROR)</p>
<p>error = FKT_GetResponse (data, len);</p>
<p>return error;</p>
<p>// SIM_RunGSMAlgo函数就是直接封装SIM的COMMAND SIM_RUN_GSM_ALGO然后发送给SIM</p>
<p>///////////////////////////////////////////</p>
<p>PSENDX (MM, sim_authentication_cnf);</p>
<p>error = FKT_Select (SIM_KC, NULL, 0);</p>
<p>if (error EQ SIM_NO_ERROR)</p>
<p>{</p>
<p>kc_n.c_kc = MAX_KC_N;</p>
<p>FKT_UpdateBinary (kc_n.kc, (USHORT)kc_n.c_kc, 0);</p>
<p>}</p>
<p>//发送给MM后，会继续选中SIM_KC更新该EF。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/08/authentication/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MM Normal Location Updating</title>
		<link>http://www.ilived.cn/wordpress/2009/07/mm-normal-location-updating/</link>
		<comments>http://www.ilived.cn/wordpress/2009/07/mm-normal-location-updating/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 09:11:20 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[GSM协议栈]]></category>

		<category><![CDATA[TI]]></category>

		<category><![CDATA[MM]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=534</guid>
		<description><![CDATA[当MS选择了一个不同的小区后，MM就需要开始进行location updating.此时MM的状态应该是IDLE ATTEMPT TO UPDATE.。

如果Location Update被接受，则RR会返回如下原语

MM在处理RR_DATA_IND（Location Update Accept）是会先停掉Timer T3212，T3210，然后将MM的 mm_data-&#62;reg.update_stat = MS_UPDATED;
在RR_DATA_IND中会带有Mobile Identity的类型。Mobile Identity的类型可能是TMSI，IMSI，IMEI或者为空
MM对应不同的Mobile Identity处理如下：

MM会先reallocation TMSI，然后将RR_DATA_IND中的TMSI保存在MM信息的reg.tmsi中，然后向RR发送BSIZE_U_TMSI_REALLOC_COMP，保存RR_DATA_IND的lai信息，然后发送RR_SYNC_REQ（rr_sync_req_tmsi），最后发送RR_SYNC_REQ (Location Area allowed)。
对应代码如下：
MCAST (tmsi_realloc_comp, U_TMSI_REALLOC_COMP);
/* Save TMSI in MM registration data */
mm_store_tmsi (&#38;loc_upd_accept-&#62;mob_id);
/* Send RR_DATA_REQ (TMSI_REALLOC_COMPLETE) */
tmsi_realloc_comp-&#62;msg_type = U_TMSI_REALLOC_COMP;
for_data_req (BSIZE_U_TMSI_REALLOC_COMP);
mm_data-&#62;reg.lai = loc_upd_accept-&#62;loc_area_ident;
/* Send RR_SYNC_REQ */
mm_build_rr_sync_req_tmsi ();
/* Send RR_SYNC_REQ (Location Area allowed) */
mm_build_rr_sync_req_cause (SYNCCS_LAI_ALLOW);

MM会先删除存储的TMSI，保存RR_DATA_IND的lai信息，然后通过RR_SYNC_REQ向RR说明TMSI已经失效，最后发送RR_SYNC_REQ (Location Area allowed)。
对应代码如下：
mm_data-&#62;reg.tmsi = TMSI_INVALID_VALUE;
mm_build_rr_sync_req_cause (SYNCCS_TMSI_INVAL);
mm_data-&#62;reg.lai [...]]]></description>
			<content:encoded><![CDATA[<p>当MS选择了一个不同的小区后，MM就需要开始进行location updating.此时MM的状态应该是IDLE ATTEMPT TO UPDATE.。</p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlustart.png"><img class="alignnone size-full wp-image-535" title="mmlustart" src="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlustart.png" alt="" width="500" height="102" /></a></p>
<p>如果Location Update被接受，则RR会返回如下原语</p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcaccept.png"><img class="alignnone size-full wp-image-536" title="mmlcaccept" src="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcaccept.png" alt="" width="499" height="150" /></a></p>
<p>MM在处理RR_DATA_IND（Location Update Accept）是会先停掉Timer T3212，T3210，然后将MM的 mm_data-&gt;reg.update_stat = MS_UPDATED;</p>
<p>在RR_DATA_IND中会带有Mobile Identity的类型。Mobile Identity的类型可能是TMSI，IMSI，IMEI或者为空</p>
<p>MM对应不同的Mobile Identity处理如下：</p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmitmsi.png"><img class="alignnone size-full wp-image-537" title="mmlcmitmsi" src="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmitmsi.png" alt="" width="500" height="207" /></a></p>
<p>MM会先reallocation TMSI，然后将RR_DATA_IND中的TMSI保存在MM信息的reg.tmsi中，然后向RR发送BSIZE_U_TMSI_REALLOC_COMP，保存RR_DATA_IND的lai信息，然后发送RR_SYNC_REQ（rr_sync_req_tmsi），最后发送RR_SYNC_REQ (Location Area allowed)。</p>
<p>对应代码如下：</p>
<p><span style="color: #99ccff;">MCAST (tmsi_realloc_comp, U_TMSI_REALLOC_COMP);</span></p>
<p><span style="color: #99ccff;">/* Save TMSI in MM registration data */</span></p>
<p><span style="color: #99ccff;">mm_store_tmsi (&amp;loc_upd_accept-&gt;mob_id);</span></p>
<p><span style="color: #99ccff;">/* Send RR_DATA_REQ (TMSI_REALLOC_COMPLETE) */</span></p>
<p><span style="color: #99ccff;">tmsi_realloc_comp-&gt;msg_type = U_TMSI_REALLOC_COMP;</span></p>
<p><span style="color: #99ccff;">for_data_req (BSIZE_U_TMSI_REALLOC_COMP);</span></p>
<p><span style="color: #99ccff;">mm_data-&gt;reg.lai = loc_upd_accept-&gt;loc_area_ident;</span></p>
<p><span style="color: #99ccff;">/* Send RR_SYNC_REQ */</span></p>
<p><span style="color: #99ccff;">mm_build_rr_sync_req_tmsi ();</span></p>
<p><span style="color: #99ccff;">/* Send RR_SYNC_REQ (Location Area allowed) */</span></p>
<p><span style="color: #99ccff;">mm_build_rr_sync_req_cause (SYNCCS_LAI_ALLOW);</span></p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmiimsi.png"><img class="alignnone size-full wp-image-539" title="mmlcmiimsi" src="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmiimsi.png" alt="" width="500" height="158" /></a></p>
<p>MM会先删除存储的TMSI，保存RR_DATA_IND的lai信息，然后通过RR_SYNC_REQ向RR说明TMSI已经失效，最后发送RR_SYNC_REQ (Location Area allowed)。</p>
<p>对应代码如下：</p>
<p><span style="color: #99ccff;">mm_data-&gt;reg.tmsi = TMSI_INVALID_VALUE;</span></p>
<p><span style="color: #99ccff;">mm_build_rr_sync_req_cause (SYNCCS_TMSI_INVAL);</span></p>
<p><span style="color: #99ccff;">mm_data-&gt;reg.lai = loc_upd_accept-&gt;loc_area_ident;</span></p>
<p><span style="color: #99ccff;">mm_build_rr_sync_req_cause (SYNCCS_LAI_ALLOW);</span></p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmiimei.png"><img class="alignnone size-full wp-image-538" title="mmlcmiimei" src="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmiimei.png" alt="" width="500" height="101" /></a><br />
MM只会创建一个BSIZE_B_MM_STATUS发送给RR,MM似乎会将这个mobile identity忽略掉。</p>
<p>对应代码如下:</p>
<p><span style="color: #99ccff;">MCAST (mm_status, B_MM_STATUS);</span></p>
<p><span style="color: #99ccff;">mm_build_mm_status (RC_INCORRECT_MESSAGE, mm_status);</span></p>
<p><span style="color: #99ccff;">for_data_req (BSIZE_B_MM_STATUS);</span></p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmiempty.png"><img class="alignnone size-full wp-image-540" title="mmlcmiempty" src="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcmiempty.png" alt="" width="500" height="89" /></a></p>
<p>MM直接向RR发送RR_SYNC_REQ (Location Area allowed)。</p>
<p>对应代码如下：</p>
<p><span style="color: #99ccff;">mm_data-&gt;reg.lai = loc_upd_accept-&gt;loc_area_ident;</span></p>
<p><span style="color: #99ccff;">mm_build_rr_sync_req_cause (SYNCCS_LAI_ALLOW);</span></p>
<p><a href="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcend.png"><img class="alignnone size-full wp-image-541" title="mmlcend" src="http://www.ilived.cn/wordpress/wp-content/uploads/2009/07/mmlcend.png" alt="" width="500" height="112" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/07/mm-normal-location-updating/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MM Detach</title>
		<link>http://www.ilived.cn/wordpress/2009/07/mm-detach/</link>
		<comments>http://www.ilived.cn/wordpress/2009/07/mm-detach/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:52:44 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[GSM协议栈]]></category>

		<category><![CDATA[TI]]></category>

		<category><![CDATA[源代码分析]]></category>

		<category><![CDATA[MM]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=529</guid>
		<description><![CDATA[MMR_NREG_REQ
需要发送MMR_NREG_REQ的情况有如下3种。CS_SIM_REM，CS_POW_OFF，CS_SOFT_OFF。
这个过程将会进行如下操作
TIMERSTOP (T3212);
然后调用mm_mmr_nreg_req函数进行处理。
对于此时MM处于不同的状态，MM会执行对应的操作。
MM_NULL:
CS_POW_OFF和CS_SOFT_OFF会先清除register data，复制sim发给mm的sim_insert_info到mm的register data中，然后清除sim_insert_info然后向GMM发送MMGMM_NREG_CNF原语。
CS_SIM_REM也会清除register data，然后会对是否需要再次注册进行判断，然后向GMM发送MMGMM_NREG_IND原语，最后如果STATE_REG_TYPE为REG_REMOTE_CONTROLLED的话，会将STATE_REG_TYPE设置为REG_CELL_SEARCH_ONLY，STATE_GPRS_CM_EST为CM_GPRS_EST_IDLE。
MM_LUP_INITIATED，MM_LUP_REJECTED：
先向RR发送RR_SYNC_REQ，然后设置状态为MM无效的update state。然后执行同MM状态为MM_WAIT_FOR_OUTG_MM_CONN，MM_CONN_ACTIVE，MM_PROCESS_PROMPT，MM_WAIT_FOR_NW_CMD一样的操作。
MM_WAIT_FOR_OUTG_MM_CONN，MM_CONN_ACTIVE，MM_PROCESS_PROMPT，MM_WAIT_FOR_NW_CMD：
如果MM此时允许attach，ms已经updated，detach_done为MMGMM_PERFORM_DETACH则进行如下操作
先将所有CM connections的类型为CM_NOT_IDLE的连接释放。停止timer T3210，T3211，T3212，T3213，T3230，T3240，然后向RR发送imsi_detach_message，启动timer T3220，将MM状态设置为MM_IMSI_DETACH_INIT。
如果MM状态不满足要求则执行同MM状态为MM_WAIT_FOR_RR_CONN_LUP，MM_WAIT_FOR_RR_CONN_MM，MM_WAIT_FOR_REESTABLISH一样的操作。
MM_WAIT_FOR_RR_CONN_LUP，MM_WAIT_FOR_RR_CONN_MM，MM_WAIT_FOR_REESTABLISH：
依然先将所有CM connections的类型为CM_NOT_IDLE的连接释放，停止timer T3210，T3211，T3212，T3213，T3230，T3240，如果是CS_POW_OFF和CS_SOFT_OFF则会向RR发送RR_ABORT_REQ，原因设置为normal abort，而CS_SIM_REM则会将原因设置为sim remove。最后将MM状态设置为MM_IMSI_DETACH_INIT。
MM_IMSI_DETACH_INIT，MM_WAIT_FOR_RR_CONN_DETACH：
设置mm_data-&#62;nreg_cause = nreg_cause;
MM_WAIT_FOR_RR_ACTIVE：RR is searching for a cell
为什么此时RR is searching for a cell？根据04.08
&#8220;If no RR connection exists, the MM sublayer within the mobile
* station will request the RR sublayer to establish a RR
* connection. If establishment of the RR connection is not possible
* [...]]]></description>
			<content:encoded><![CDATA[<p>MMR_NREG_REQ</p>
<p>需要发送MMR_NREG_REQ的情况有如下3种。CS_SIM_REM，CS_POW_OFF，CS_SOFT_OFF。</p>
<p>这个过程将会进行如下操作</p>
<p>TIMERSTOP (T3212);</p>
<p>然后调用mm_mmr_nreg_req函数进行处理。</p>
<p>对于此时MM处于不同的状态，MM会执行对应的操作。</p>
<p><strong><span style="color: #99ccff;">MM_NULL:</span></strong></p>
<p>CS_POW_OFF和CS_SOFT_OFF会先清除register data，复制sim发给mm的sim_insert_info到mm的register data中，然后清除sim_insert_info然后向GMM发送MMGMM_NREG_CNF原语。</p>
<p>CS_SIM_REM也会清除register data，然后会对是否需要再次注册进行判断，然后向GMM发送MMGMM_NREG_IND原语，最后如果STATE_REG_TYPE为REG_REMOTE_CONTROLLED的话，会将STATE_REG_TYPE设置为REG_CELL_SEARCH_ONLY，STATE_GPRS_CM_EST为CM_GPRS_EST_IDLE。</p>
<p><strong><span style="color: #99ccff;">MM_LUP_INITIATED，MM_LUP_REJECTED：</span></strong></p>
<p>先向RR发送RR_SYNC_REQ，然后设置状态为MM无效的update state。然后执行同MM状态为MM_WAIT_FOR_OUTG_MM_CONN，MM_CONN_ACTIVE，MM_PROCESS_PROMPT，MM_WAIT_FOR_NW_CMD一样的操作。</p>
<p><strong><span style="color: #99ccff;">MM_WAIT_FOR_OUTG_MM_CONN，MM_CONN_ACTIVE，MM_PROCESS_PROMPT，MM_WAIT_FOR_NW_CMD：</span></strong></p>
<p>如果MM此时允许attach，ms已经updated，detach_done为MMGMM_PERFORM_DETACH则进行如下操作</p>
<p>先将所有CM connections的类型为CM_NOT_IDLE的连接释放。停止timer T3210，T3211，T3212，T3213，T3230，T3240，然后向RR发送imsi_detach_message，启动timer T3220，将MM状态设置为MM_IMSI_DETACH_INIT。</p>
<p>如果MM状态不满足要求则执行同MM状态为MM_WAIT_FOR_RR_CONN_LUP，MM_WAIT_FOR_RR_CONN_MM，MM_WAIT_FOR_REESTABLISH一样的操作。</p>
<p><strong><span style="color: #99ccff;">MM_WAIT_FOR_RR_CONN_LUP，MM_WAIT_FOR_RR_CONN_MM，MM_WAIT_FOR_REESTABLISH：</span></strong></p>
<p>依然先将所有CM connections的类型为CM_NOT_IDLE的连接释放，停止timer T3210，T3211，T3212，T3213，T3230，T3240，如果是CS_POW_OFF和CS_SOFT_OFF则会向RR发送RR_ABORT_REQ，原因设置为normal abort，而CS_SIM_REM则会将原因设置为sim remove。最后将MM状态设置为MM_IMSI_DETACH_INIT。</p>
<p><strong><span style="color: #99ccff;">MM_IMSI_DETACH_INIT，MM_WAIT_FOR_RR_CONN_DETACH：</span></strong></p>
<p>设置mm_data-&gt;nreg_cause = nreg_cause;</p>
<p>MM_WAIT_FOR_RR_ACTIVE：RR is searching for a cell</p>
<p>为什么此时RR is searching for a cell？根据04.08</p>
<p>&#8220;If no RR connection exists, the MM sublayer within the mobile</p>
<p>* station will request the RR sublayer to establish a RR</p>
<p>* connection. If establishment of the RR connection is not possible</p>
<p>* because a suitable cell is not (or not yet) available then, the</p>
<p>* mobile station shall try for a period of at least 5 seconds and for</p>
<p>* not more than a period of 20 seconds to find a suitable cell. If a</p>
<p>* suitable cell is found during this time then, the mobile station shall</p>
<p>* request the RR sublayer to establish an RR connection, otherwise the</p>
<p>* IMSI detach is aborted.</p>
<p>CS_POW_OFF和CS_SOFT_OFF向DL层发送MDL_RELEASE_REQ（SAPI 0），这个其实应该是RR层做的。接着向RR发送RR_DEACTIVATE_REQ，清除register data，停止所有MM timer，最后将MM状态设置为MM_NULL。最后还会执行MM状态为MM_NULL同样的操作。</p>
<p>CS_SIM_REM先向RR发送RR_ABORT_REQ，原因是sim remove，然后执行MM状态为MM_NULL同样的操作。</p>
<p><strong><span style="color: #99ccff;">MM_LOCATION_UPDATING_PENDING，MM_IMSI_DETACH_PENDING，MM_IDLE_LUP_NEEDED，<br />
MM_IDLE_NORMAL_SERVICE，MM_IDLE_ATTEMPT_TO_UPDATE：</span></strong><br />
停止timer T3212，T3213。如果MM此时允许attach，ms已经updated，detach_done为MMGMM_PERFORM_DETACH则创建imsi_detach_message，然后处理mobile originated call by SS or SMS，设置状态为MM_WAIT_FOR_RR_CONN_DETACH。</p>
<p>如果MM状态不满足要求则执行同MM状态为MM_IDLE_LIMITED_SERVICE，MM_IDLE_NO_IMSI同样的操作。</p>
<p><strong><span style="color: #99ccff;">MM_IDLE_LIMITED_SERVICE，MM_IDLE_NO_IMSI：</span></strong></p>
<p>停止timer T3211，T3212，T3213。CS_POW_OFF和CS_SOFT_OFF先向DL层发送MDL_RELEASE_REQ（SAPI 0），接着向RR发送RR_DEACTIVATE_REQ，清除register data，设置MM状态为NO_SERVICE。</p>
<p>CS_SIM_REM先向DL层发送MDL_RELEASE_REQ（SAPI 0），然后向RR发送RR_ABORT_REQ，原因是sim remove，清除register data，如果(mm_data-&gt;mm_idle_no_imsi_marker EQ 0)则mm_data-&gt;mm_idle_no_imsi_marker = 17;设置MM状态为MM_IDLE_NO_IMSI，执行同MM状态为MM_NULL同样的操作，不过将service改为LIMITED_SERVICE。</p>
<p><strong><span style="color: #99ccff;">MM_IDLE_NO_CELL_AVAILABLE：</span></strong></p>
<p>基本上同MM_IDLE_LIMITED_SERVICE，MM_IDLE_NO_IMSI一样，只是CS_SIM_REM最后的service不是LIMITED_SERVICE而是NO_SERVICE。</p>
<p>MM_IDLE_PLMN_SEARCH，MM_PLMN_SEARCH_NORMAL_SERVICE：</p>
<p>返回network search开始时MM的状态</p>
<p>SET_STATE (STATE_MM, mm_data-&gt;idle_substate);</p>
<p>然后再次调用本函数进行状态处理。</p>
<p>mm_mmr_nreg_req (nreg_cause, detach_done);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/07/mm-detach/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RR_ACTIVATE_CNF的处理</title>
		<link>http://www.ilived.cn/wordpress/2009/07/rr_activate_cnf%e7%9a%84%e5%a4%84%e7%90%86/</link>
		<comments>http://www.ilived.cn/wordpress/2009/07/rr_activate_cnf%e7%9a%84%e5%a4%84%e7%90%86/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 09:57:12 +0000</pubDate>
		<dc:creator>iLived</dc:creator>
		
		<category><![CDATA[GSM协议栈]]></category>

		<category><![CDATA[TI]]></category>

		<category><![CDATA[源代码分析]]></category>

		<category><![CDATA[MM]]></category>

		<category><![CDATA[协议栈]]></category>

		<guid isPermaLink="false">http://www.ilived.cn/wordpress/?p=526</guid>
		<description><![CDATA[

GLOBAL const void mm_rr_activate_cnf (T_RR_ACTIVATE_CNF *rr_activate_cnf)

{

mm_data-&#62;rf_power = rr_activate_cnf-&#62;power;

mm_data-&#62;reg.new_cell_ind = TRUE;

//如果mnc和mcc是请求的则复制plmn。

if (reg_plmn_equal_eqv (&#38;rr_activate_cnf-&#62;plmn, &#38;mm_data-&#62;reg.actual_plmn))

{

mm_data-&#62;reg.actual_plmn = rr_activate_cnf-&#62;plmn; /* Struct copy */

}

//此时MM的状态如果是MM_WAIT_FOR_RR_ACTIVE，同时(mm_data-&#62;reg.op.func EQ rr_activate_cnf-&#62;op.func)

//rr_activate_cnf-&#62;op.service中返回了当前的service类型是LIMITED_SERVICE或FULL_SERVICE。

//当时FULL_SERVICE时会进行如下的操作。

//将mm_info，lai，lac，cid，gprs_indication赋值到MM对应的变量中。

mm_copy_rr_act_cnf_data (rr_activate_cnf);

//此时会判断需不需要location updating，判读函数如下

mm_normal_upd_needed()

if (mm_data-&#62;reg.update_stat EQ MS_UPDATED AND

mm_check_lai (&#38;mm_data-&#62;reg.lai, &#38;mm_data-&#62;mm.lai))

return FALSE;

return TRUE;

mm_attach_upd_needed()

if (mm_data-&#62;mm.mm_info.att EQ ATT_ALLOW AND mm_data-&#62;first_attach) 

return TRUE;

return FALSE;

mm_periodic_upd_needed (void)

if (mm_data-&#62;t3212_timeout AND mm_data-&#62;mm.mm_info.t3212 NEQ 0)

return TRUE;

return FALSE;

当不需要location updating时

{

TIMERSTOP (T3213);

mm_data-&#62;t3213_restart = 0;

mm_change_t3212();

//然后向GMM发送MMGMM_REG_CNF原语

reg_mm_success (FULL_SERVICE);

//向SIM发送 SIM_MM_UPDATE_REQ 原语 其中主要需要更新的有loc_info，bcch_info，forb_plmns，kc。

reg_build_sim_update [...]]]></description>
			<content:encoded><![CDATA[<pre name="code" class="C++">

GLOBAL const void mm_rr_activate_cnf (T_RR_ACTIVATE_CNF *rr_activate_cnf)

{

mm_data-&gt;rf_power = rr_activate_cnf-&gt;power;

mm_data-&gt;reg.new_cell_ind = TRUE;

//如果mnc和mcc是请求的则复制plmn。

if (reg_plmn_equal_eqv (&amp;rr_activate_cnf-&gt;plmn, &amp;mm_data-&gt;reg.actual_plmn))

{

mm_data-&gt;reg.actual_plmn = rr_activate_cnf-&gt;plmn; /* Struct copy */

}

//此时MM的状态如果是MM_WAIT_FOR_RR_ACTIVE，同时(mm_data-&gt;reg.op.func EQ rr_activate_cnf-&gt;op.func)

//rr_activate_cnf-&gt;op.service中返回了当前的service类型是LIMITED_SERVICE或FULL_SERVICE。

//当时FULL_SERVICE时会进行如下的操作。

//将mm_info，lai，lac，cid，gprs_indication赋值到MM对应的变量中。

mm_copy_rr_act_cnf_data (rr_activate_cnf);

//此时会判断需不需要location updating，判读函数如下

mm_normal_upd_needed()

if (mm_data-&gt;reg.update_stat EQ MS_UPDATED AND

mm_check_lai (&amp;mm_data-&gt;reg.lai, &amp;mm_data-&gt;mm.lai))

return FALSE;

return TRUE;

mm_attach_upd_needed()

if (mm_data-&gt;mm.mm_info.att EQ ATT_ALLOW AND mm_data-&gt;first_attach) 

return TRUE;

return FALSE;

mm_periodic_upd_needed (void)

if (mm_data-&gt;t3212_timeout AND mm_data-&gt;mm.mm_info.t3212 NEQ 0)

return TRUE;

return FALSE;

当不需要location updating时

{

TIMERSTOP (T3213);

mm_data-&gt;t3213_restart = 0;

mm_change_t3212();

//然后向GMM发送MMGMM_REG_CNF原语

reg_mm_success (FULL_SERVICE);

//向SIM发送 SIM_MM_UPDATE_REQ 原语 其中主要需要更新的有loc_info，bcch_info，forb_plmns，kc。

reg_build_sim_update (); /* Update cell id */

//同时如果不是gsm only此时还要向GMM发送MMGMM_ACTIVATE_IND。传递的参数有plmn,lac,cid,status, gprs_indicator,同时3212timer时间如下设置

if (mm_data-&gt;t3212_cfg_counter NEQ 0 AND 

mm_data-&gt;mm.mm_info.t3212 NEQ 0)

mmgmm_activate_ind-&gt;t3212_val = mm_data-&gt;t3212_cfg_counter * 10000;

else

mmgmm_activate_ind-&gt;t3212_val = mm_data-&gt;mm.mm_info.t3212 * 360000;

mm_mmgmm_activate_ind (MMGMM_FULL_SERVICE);

/* Back to MM_IDLE_NORMAL_SERVICE */

mm_data-&gt;idle_entry = RRCS_INT_NOT_PRESENT;

/* Remember MM doesn't need any IMSI ATTACH anymore */

if (mm_lup_allowed_by_gmm() AND mm_data-&gt;first_attach )

{

mm_data-&gt;first_attach_mem = mm_data-&gt;first_attach;

mm_data-&gt;first_attach = FALSE;

}

mm_data-&gt;t3212_timeout = FALSE;

mm_data-&gt;loc_upd_type.lut = NOT_RUNNING;

SET_STATE (STATE_MM, MM_IDLE_NORMAL_SERVICE);

/* Check HPLMN timer state */

reg_check_hplmn_tim (mm_data-&gt;reg.thplmn);

USE_STORED_ENTRIES();

//当需要location updating时进行如下操作。

reg_mm_cell_selected ();//gsm only情况下

mm_data-&gt;attempt_cnt = 0;

//然后判断mm_normal_upd_needed()还是mm_attach_upd_needed()还是其他

if (mm_normal_upd_needed())

{

/*

* If updating is allowed by GMM, start procedure,

* otherwise enter state MM_IDLE_LUP_NEEDED.

*/

mm_normal_loc_upd ();

//如果GMM允许location update，此时会向RR发送RR_ESTABLISH_REQ原语，当然此时需要一个RR的连接。

mm_rr_est_req (ESTCS_SERV_REQ_BY_MM, NO_CM_SERVICE, 0);

TIMERSTOP (T3211);

TIMERSTOP (T3213);

mm_data-&gt;t3213_restart = 0;

SET_STATE (STATE_MM, MM_WAIT_FOR_RR_CONN_LUP);

}

else if (mm_attach_upd_needed())

{

/*

* If updating is allowed by GMM, start procedure,

* otherwise enter state MM_IDLE_LUP_NEEDED.

*/

mm_attach_loc_upd ();

//此时同mm_normal_upd_needed一样，只是mm_start_loc_upd的参数由NORMAL_LUP变为了IMSI_ATTACH_LUP，依然是发送RR_ESTABLISH_REQ原语

}

//除了mm_normal_upd_needed和mm_attach_upd_needed其他情况mm_start_loc_upd的参数变为了PERIODIC_LUP。

//最后也会进行如下调用

mm_mmgmm_activate_ind (MMGMM_WAIT_FOR_UPDATE);

}
</pre>
<p>总的从代码中看来，当MM接收到从RR传送过来的RR_ACTIVATE_CNF原语后，MM会存储RR传过来的一些诸如plmn，lac，mm_info等信息，同时会通知SIM更新plmn，bcch，kc等等信息，如果此时不需要location update，MM会向GMM发送MMGMM_ACTIVATE_IND，此时是MMGMM_FULL_SERVICE。当需要location update时，根据update的类型，向RR发送RR_ESTABLISH_REQ原语。</p>
<p>MM接收到该原语后会根据自己当前的状态进行状态的更新，MM_IDLE_NORMAL_SERVICE或MMGMM_WAIT_FOR_UPDATE，或者没有sim或sim无效的MM_IDLE_LIMITED_SERVICE，MM_IDLE_NO_IMSI。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilived.cn/wordpress/2009/07/rr_activate_cnf%e7%9a%84%e5%a4%84%e7%90%86/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
